• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2019 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 
19 #import <GRPCClient/GRPCInterceptor.h>
20 #import <GRPCClient/GRPCTransport.h>
21 
22 NS_ASSUME_NONNULL_BEGIN
23 
24 /**
25  * Private interfaces of the transport registry.
26  */
27 @interface GRPCTransportRegistry (Private)
28 
29 /**
30  * Get a transport implementation's factory by its transport id. If the transport id was not
31  * registered with the registry, the default transport factory (core + secure) is returned. If the
32  * default transport does not exist, an exception is thrown.
33  */
34 - (id<GRPCTransportFactory>)getTransportFactoryWithID:(GRPCTransportID)transportID;
35 
36 @end
37 
38 /**
39  * GRPCTransportManager is a helper class to forward messages between the last interceptor and the
40  * transport instance.
41  *
42  * All methods except the initializer of the class can only be called on the manager's dispatch
43  * queue. Since the manager's dispatch queue is the same as the transport's dispatch queue, it is
44  * also safe to call the manager's methods in the corresponding transport instance's methods that
45  * implement GRPCInterceptorInterface.
46  *
47  * When a transport instance is shutting down, it must call -shutDown method of its associated
48  * transport manager for proper clean-up.
49  */
50 @interface GRPCTransportManager : NSObject <GRPCInterceptorInterface>
51 
52 - (instancetype)initWithTransportID:(GRPCTransportID)transportID
53                 previousInterceptor:(id<GRPCResponseHandler>)previousInterceptor;
54 
55 /**
56  * Notify the manager that the transport has shut down and the manager should release references to
57  * its response handler and stop forwarding requests/responses.
58  */
59 - (void)shutDown;
60 
61 /** Forward initial metadata to the previous interceptor in the interceptor chain */
62 - (void)forwardPreviousInterceptorWithInitialMetadata:(nullable NSDictionary *)initialMetadata;
63 
64 /** Forward a received message to the previous interceptor in the interceptor chain */
65 - (void)forwardPreviousInterceptorWithData:(nullable id)data;
66 
67 /** Forward call close and trailing metadata to the previous interceptor in the interceptor chain */
68 - (void)forwardPreviousInterceptorCloseWithTrailingMetadata:
69             (nullable NSDictionary *)trailingMetadata
70                                                       error:(nullable NSError *)error;
71 
72 /** Forward write completion to the previous interceptor in the interceptor chain */
73 - (void)forwardPreviousInterceptorDidWriteData;
74 
75 @end
76 
77 NS_ASSUME_NONNULL_END
78