Home | History | Annotate | Download | only in GRPCClient
      1 /*
      2  *
      3  * Copyright 2016 gRPC authors.
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  *
     17  */
     18 #import "GRPCCall.h"
     19 
     20 #include <AvailabilityMacros.h>
     21 
     22 typedef NS_ENUM(NSInteger, GRPCCompressAlgorithm) {
     23   GRPCCompressNone,
     24   GRPCCompressDeflate,
     25   GRPCCompressGzip,
     26 };
     27 
     28 /**
     29  * Methods to configure GRPC channel options.
     30  */
     31 @interface GRPCCall (ChannelArg)
     32 
     33 /**
     34  * Use the provided @c userAgentPrefix at the beginning of the HTTP User Agent string for all calls
     35  * to the specified @c host.
     36  */
     37 + (void)setUserAgentPrefix:(nonnull NSString *)userAgentPrefix forHost:(nonnull NSString *)host;
     38 
     39 /** The default response size limit is 4MB. Set this to override that default. */
     40 + (void)setResponseSizeLimit:(NSUInteger)limit forHost:(nonnull NSString *)host;
     41 
     42 + (void)closeOpenConnections DEPRECATED_MSG_ATTRIBUTE(
     43     "The API for this feature is experimental, "
     44     "and might be removed or modified at any "
     45     "time.");
     46 
     47 + (void)setDefaultCompressMethod:(GRPCCompressAlgorithm)algorithm forhost:(nonnull NSString *)host;
     48 
     49 /** Enable keepalive and configure keepalive parameters. A user should call this function once to
     50  * enable keepalive for a particular host. gRPC client sends a ping after every \a interval ms to
     51  * check if the transport is still alive. After waiting for \a timeout ms, if the client does not
     52  * receive the ping ack, it closes the transport; all pending calls to this host will fail with
     53  * error GRPC_STATUS_INTERNAL with error information "keepalive watchdog timeout". */
     54 + (void)setKeepaliveWithInterval:(int)interval
     55                          timeout:(int)timeout
     56                          forHost:(nonnull NSString *)host;
     57 
     58 /** Enable/Disable automatic retry of gRPC calls on the channel. If automatic retry is enabled, the
     59  * retry is controlled by server's service config. If automatic retry is disabled, failed calls are
     60  * immediately returned to the application layer. */
     61 + (void)enableRetry:(BOOL)enabled forHost:(nonnull NSString *)host;
     62 
     63 /** Set channel connection timeout and backoff parameters. All parameters are positive integers in
     64  * milliseconds. Set a parameter to 0 to make gRPC use default value for that parameter.
     65  *
     66  * Refer to gRPC's doc at https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md for the
     67  * details of each parameter. */
     68 + (void)setMinConnectTimeout:(unsigned int)timeout
     69               initialBackoff:(unsigned int)initialBackoff
     70                   maxBackoff:(unsigned int)maxBackoff
     71                      forHost:(nonnull NSString *)host;
     72 
     73 @end
     74