1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_MASTER_SERVICE_IMPL_H_
17 #define TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_MASTER_SERVICE_IMPL_H_
18 
19 #include "grpcpp/impl/codegen/async_stream.h"
20 #include "grpcpp/impl/codegen/async_unary_call.h"
21 #include "grpcpp/impl/codegen/proto_utils.h"
22 #include "grpcpp/impl/codegen/rpc_method.h"
23 #include "grpcpp/impl/codegen/service_type.h"
24 #include "grpcpp/impl/codegen/status.h"
25 #include "grpcpp/impl/codegen/stub_options.h"
26 #include "grpcpp/impl/codegen/sync_stream.h"
27 
28 #include "tensorflow/core/protobuf/master.pb.h"
29 
30 namespace tensorflow {
31 
32 namespace grpc {
33 
34 // Implementation of `tensorflow.MasterService`, based on the
35 // definition in "//tensorflow/core/protobuf/master_service.proto",
36 // and the gRPC generated stub and service classes.
37 // See that file for the definition of methods and messages.
38 class MasterService final {
39  public:
40   class StubInterface {
41    public:
~StubInterface()42     virtual ~StubInterface() {}
43     virtual ::grpc::Status CreateSession(::grpc::ClientContext* context,
44                                          const CreateSessionRequest& request,
45                                          CreateSessionResponse* response) = 0;
46     virtual ::grpc::Status ExtendSession(::grpc::ClientContext* context,
47                                          const ExtendSessionRequest& request,
48                                          ExtendSessionResponse* response) = 0;
49     virtual ::grpc::Status PartialRunSetup(
50         ::grpc::ClientContext* context, const PartialRunSetupRequest& request,
51         PartialRunSetupResponse* response) = 0;
52     virtual ::grpc::Status RunStep(::grpc::ClientContext* context,
53                                    const RunStepRequest& request,
54                                    RunStepResponse* response) = 0;
55     virtual ::grpc::Status CloseSession(::grpc::ClientContext* context,
56                                         const CloseSessionRequest& request,
57                                         CloseSessionResponse* response) = 0;
58     virtual ::grpc::Status ListDevices(::grpc::ClientContext* context,
59                                        const ListDevicesRequest& request,
60                                        ListDevicesResponse* response) = 0;
61     virtual ::grpc::Status Reset(::grpc::ClientContext* context,
62                                  const ResetRequest& request,
63                                  ResetResponse* response) = 0;
64     virtual ::grpc::Status MakeCallable(::grpc::ClientContext* context,
65                                         const MakeCallableRequest& request,
66                                         MakeCallableResponse* response) = 0;
67     virtual ::grpc::Status RunCallable(::grpc::ClientContext* context,
68                                        const RunCallableRequest& request,
69                                        RunCallableResponse* response) = 0;
70     virtual ::grpc::Status ReleaseCallable(
71         ::grpc::ClientContext* context, const ReleaseCallableRequest& request,
72         ReleaseCallableResponse* response) = 0;
73   };
74   class Stub final : public StubInterface {
75    public:
76     Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
77     ::grpc::Status CreateSession(::grpc::ClientContext* context,
78                                  const CreateSessionRequest& request,
79                                  CreateSessionResponse* response) override;
80     ::grpc::Status ExtendSession(::grpc::ClientContext* context,
81                                  const ExtendSessionRequest& request,
82                                  ExtendSessionResponse* response) override;
83     ::grpc::Status PartialRunSetup(::grpc::ClientContext* context,
84                                    const PartialRunSetupRequest& request,
85                                    PartialRunSetupResponse* response) override;
86     ::grpc::Status RunStep(::grpc::ClientContext* context,
87                            const RunStepRequest& request,
88                            RunStepResponse* response) override;
89     ::grpc::Status CloseSession(::grpc::ClientContext* context,
90                                 const CloseSessionRequest& request,
91                                 CloseSessionResponse* response) override;
92     ::grpc::Status ListDevices(::grpc::ClientContext* context,
93                                const ListDevicesRequest& request,
94                                ListDevicesResponse* response) override;
95     ::grpc::Status Reset(::grpc::ClientContext* context,
96                          const ResetRequest& request,
97                          ResetResponse* response) override;
98     ::grpc::Status MakeCallable(::grpc::ClientContext* context,
99                                 const MakeCallableRequest& request,
100                                 MakeCallableResponse* response) override;
101     ::grpc::Status RunCallable(::grpc::ClientContext* context,
102                                const RunCallableRequest& request,
103                                RunCallableResponse* response) override;
104     ::grpc::Status ReleaseCallable(::grpc::ClientContext* context,
105                                    const ReleaseCallableRequest& request,
106                                    ReleaseCallableResponse* response) override;
107 
108    private:
109     std::shared_ptr< ::grpc::ChannelInterface> channel_;
110     const ::grpc::internal::RpcMethod rpcmethod_CreateSession_;
111     const ::grpc::internal::RpcMethod rpcmethod_ExtendSession_;
112     const ::grpc::internal::RpcMethod rpcmethod_PartialRunSetup_;
113     const ::grpc::internal::RpcMethod rpcmethod_RunStep_;
114     const ::grpc::internal::RpcMethod rpcmethod_CloseSession_;
115     const ::grpc::internal::RpcMethod rpcmethod_ListDevices_;
116     const ::grpc::internal::RpcMethod rpcmethod_Reset_;
117     const ::grpc::internal::RpcMethod rpcmethod_MakeCallable_;
118     const ::grpc::internal::RpcMethod rpcmethod_RunCallable_;
119     const ::grpc::internal::RpcMethod rpcmethod_ReleaseCallable_;
120   };
121   static std::unique_ptr<Stub> NewStub(
122       const std::shared_ptr< ::grpc::ChannelInterface>& channel,
123       const ::grpc::StubOptions& options = ::grpc::StubOptions());
124 
125   class AsyncService : public ::grpc::Service {
126    public:
127     AsyncService();
128     virtual ~AsyncService();
RequestCreateSession(::grpc::ServerContext * context,CreateSessionRequest * request,::grpc::ServerAsyncResponseWriter<CreateSessionResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)129     void RequestCreateSession(
130         ::grpc::ServerContext* context, CreateSessionRequest* request,
131         ::grpc::ServerAsyncResponseWriter<CreateSessionResponse>* response,
132         ::grpc::CompletionQueue* new_call_cq,
133         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
134       ::grpc::Service::RequestAsyncUnary(0, context, request, response,
135                                          new_call_cq, notification_cq, tag);
136     }
RequestExtendSession(::grpc::ServerContext * context,ExtendSessionRequest * request,::grpc::ServerAsyncResponseWriter<ExtendSessionResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)137     void RequestExtendSession(
138         ::grpc::ServerContext* context, ExtendSessionRequest* request,
139         ::grpc::ServerAsyncResponseWriter<ExtendSessionResponse>* response,
140         ::grpc::CompletionQueue* new_call_cq,
141         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
142       ::grpc::Service::RequestAsyncUnary(1, context, request, response,
143                                          new_call_cq, notification_cq, tag);
144     }
RequestPartialRunSetup(::grpc::ServerContext * context,PartialRunSetupRequest * request,::grpc::ServerAsyncResponseWriter<PartialRunSetupResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)145     void RequestPartialRunSetup(
146         ::grpc::ServerContext* context, PartialRunSetupRequest* request,
147         ::grpc::ServerAsyncResponseWriter<PartialRunSetupResponse>* response,
148         ::grpc::CompletionQueue* new_call_cq,
149         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
150       ::grpc::Service::RequestAsyncUnary(2, context, request, response,
151                                          new_call_cq, notification_cq, tag);
152     }
RequestRunStep(::grpc::ServerContext * context,RunStepRequest * request,::grpc::ServerAsyncResponseWriter<RunStepResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)153     void RequestRunStep(
154         ::grpc::ServerContext* context, RunStepRequest* request,
155         ::grpc::ServerAsyncResponseWriter<RunStepResponse>* response,
156         ::grpc::CompletionQueue* new_call_cq,
157         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
158       ::grpc::Service::RequestAsyncUnary(3, context, request, response,
159                                          new_call_cq, notification_cq, tag);
160     }
RequestCloseSession(::grpc::ServerContext * context,CloseSessionRequest * request,::grpc::ServerAsyncResponseWriter<CloseSessionResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)161     void RequestCloseSession(
162         ::grpc::ServerContext* context, CloseSessionRequest* request,
163         ::grpc::ServerAsyncResponseWriter<CloseSessionResponse>* response,
164         ::grpc::CompletionQueue* new_call_cq,
165         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
166       ::grpc::Service::RequestAsyncUnary(4, context, request, response,
167                                          new_call_cq, notification_cq, tag);
168     }
RequestListDevices(::grpc::ServerContext * context,ListDevicesRequest * request,::grpc::ServerAsyncResponseWriter<ListDevicesResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)169     void RequestListDevices(
170         ::grpc::ServerContext* context, ListDevicesRequest* request,
171         ::grpc::ServerAsyncResponseWriter<ListDevicesResponse>* response,
172         ::grpc::CompletionQueue* new_call_cq,
173         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
174       ::grpc::Service::RequestAsyncUnary(5, context, request, response,
175                                          new_call_cq, notification_cq, tag);
176     }
RequestReset(::grpc::ServerContext * context,ResetRequest * request,::grpc::ServerAsyncResponseWriter<ResetResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)177     void RequestReset(
178         ::grpc::ServerContext* context, ResetRequest* request,
179         ::grpc::ServerAsyncResponseWriter<ResetResponse>* response,
180         ::grpc::CompletionQueue* new_call_cq,
181         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
182       ::grpc::Service::RequestAsyncUnary(6, context, request, response,
183                                          new_call_cq, notification_cq, tag);
184     }
RequestMakeCallable(::grpc::ServerContext * context,MakeCallableRequest * request,::grpc::ServerAsyncResponseWriter<MakeCallableResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)185     void RequestMakeCallable(
186         ::grpc::ServerContext* context, MakeCallableRequest* request,
187         ::grpc::ServerAsyncResponseWriter<MakeCallableResponse>* response,
188         ::grpc::CompletionQueue* new_call_cq,
189         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
190       ::grpc::Service::RequestAsyncUnary(7, context, request, response,
191                                          new_call_cq, notification_cq, tag);
192     }
RequestRunCallable(::grpc::ServerContext * context,RunCallableRequest * request,::grpc::ServerAsyncResponseWriter<RunCallableResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)193     void RequestRunCallable(
194         ::grpc::ServerContext* context, RunCallableRequest* request,
195         ::grpc::ServerAsyncResponseWriter<RunCallableResponse>* response,
196         ::grpc::CompletionQueue* new_call_cq,
197         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
198       ::grpc::Service::RequestAsyncUnary(8, context, request, response,
199                                          new_call_cq, notification_cq, tag);
200     }
RequestReleaseCallable(::grpc::ServerContext * context,ReleaseCallableRequest * request,::grpc::ServerAsyncResponseWriter<ReleaseCallableResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)201     void RequestReleaseCallable(
202         ::grpc::ServerContext* context, ReleaseCallableRequest* request,
203         ::grpc::ServerAsyncResponseWriter<ReleaseCallableResponse>* response,
204         ::grpc::CompletionQueue* new_call_cq,
205         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
206       ::grpc::Service::RequestAsyncUnary(9, context, request, response,
207                                          new_call_cq, notification_cq, tag);
208     }
209   };
210 };
211 
212 }  // namespace grpc
213 
214 }  // namespace tensorflow
215 
216 #endif  // TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_MASTER_SERVICE_IMPL_H_
217