aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2016-10-02 14:32:06 -0700
committerGravatar Muxi Yan <mxyan@google.com>2016-10-02 14:32:06 -0700
commit6c0b960a45915227410d417bee5965712331bcf9 (patch)
tree4fbfc3b7c50146756389bd14966bda72eea16aa9
parent0814e3cb179513a1ef96141f51e410416c2fea62 (diff)
Name revision
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.h18
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m24
2 files changed, 19 insertions, 23 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h
index 4b28cade42..7645bb1d34 100644
--- a/src/objective-c/GRPCClient/GRPCCall.h
+++ b/src/objective-c/GRPCClient/GRPCCall.h
@@ -155,15 +155,15 @@ typedef NS_ENUM(NSUInteger, GRPCErrorCode) {
};
/**
- * Flags for options of a gRPC call
- *
+ * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1
*/
-typedef NS_ENUM(NSUInteger, GRPCCallAttr) {
- GRPCCallAttrDefault = 0,
- /** Signal that the call is idempotent */
- GRPCCallAttrIdempotentRequest = 1,
- /** Signal that the call is cacheable. GRPC is free to use GET verb */
- GRPCCallAttrCacheableRequest = 2,
+typedef NS_ENUM(NSUInteger, GRPCCallSafety) {
+ /** Signal that there is no guarantees on how the call affects the server state. */
+ GRPCCallSafetyDefault = 0,
+ /** Signal that the call is idempotent. gRPC is free to use PUT verb. */
+ GRPCCallSafetyIdempotentRequest = 1,
+ /** Signal that the call is cacheable and will not affect server state. gRPC is free to use GET verb. */
+ GRPCCallSafetyCacheableRequest = 2,
};
/**
@@ -251,7 +251,7 @@ extern id const kGRPCTrailersKey;
* Host parameter should not contain the scheme (http:// or https://), only the name or IP addr
* and the port number, for example @"localhost:5050".
*/
-+ (void)setCallAttribute:(GRPCCallAttr)callAttr host:(NSString *)host path:(NSString *)path;
++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path;
// TODO(jcanizales): Let specify a deadline. As a category of GRXWriter?
@end
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index 2c0b779945..43204345f5 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -110,16 +110,16 @@ static NSMutableDictionary *callFlags;
callFlags = [NSMutableDictionary dictionary];
}
-+ (void)setCallAttribute:(GRPCCallAttr)callAttr host:(NSString *)host path:(NSString *)path {
- NSString *hostAndPath = [NSString stringWithFormat:@"%@%@", host, path];
- switch (callAttr) {
- case GRPCCallAttrDefault:
++ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path {
+ NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path];
+ switch (callSafety) {
+ case GRPCCallSafetyDefault:
callFlags[hostAndPath] = @0;
break;
- case GRPCCallAttrIdempotentRequest:
+ case GRPCCallSafetyIdempotentRequest:
callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
break;
- case GRPCCallAttrCacheableRequest:
+ case GRPCCallSafetyCacheableRequest:
callFlags[hostAndPath] = @GRPC_INITIAL_METADATA_CACHEABLE_REQUEST;
break;
default:
@@ -127,13 +127,9 @@ static NSMutableDictionary *callFlags;
}
}
-+ (uint32_t)getCallFlag:(NSString *)host path:(NSString *)path {
- NSString *hostAndPath = [NSString stringWithFormat:@"%@%@", host, path];
- if (nil != [callFlags objectForKey:hostAndPath]) {
- return [callFlags[hostAndPath] intValue];
- } else {
- return 0;
- }
++ (uint32_t)callFlagsForHost:(NSString *)host path:(NSString *)path {
+ NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path];
+ return [callFlags[hostAndPath] intValue];
}
- (instancetype)init {
@@ -259,7 +255,7 @@ static NSMutableDictionary *callFlags;
- (void)sendHeaders:(NSDictionary *)headers {
// TODO(jcanizales): Add error handlers for async failures
[_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMetadata alloc] initWithMetadata:headers
- flags:(uint32_t)[GRPCCall getCallFlag:_host path:_path]
+ flags:[GRPCCall callFlagsForHost:_host path:_path]
handler:nil]]];
}