File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,29 @@ an RPC. Users may set a time limit (either a deadline or a timeout) on the
130130completed before the time limit will be failed with status code 4
131131('deadline exceeded').
132132
133+ ## Compression
134+
135+ gRPC Swift supports compression.
136+
137+ ### How to enable compression for the Client
138+
139+ You can configure compression via the messageEncoding property on CallOptions:
140+
141+ ``` swift
142+ // Configure encoding
143+ let encodingConfiguration = ClientMessageEncoding.Configuration (
144+ forRequests : .gzip , // use gzip for requests
145+ acceptableForResponses : .all , // accept all supported algorithms for responses
146+ decompressionLimit : .ratio (20 ) // reject messages and fail the RPC if a response decompresses to over 20x its compressed size
147+ )
148+
149+ // Enable compression with configuration
150+ let options = CallOptions (messageEncoding : .enabled (encodingConfiguration))
151+
152+ // Use the options to make a request
153+ let rpc = echo.get (request, callOptions : options)
154+ // ...
155+ ```
133156
134157[ grpc-conn-states ] : connectivity-semantics-and-api.md
135158[ grpc-keepalive ] : keepalive.md
You can’t perform that action at this time.
0 commit comments