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 | |
19 | #ifndef GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H |
20 | #define GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H |
21 | |
22 | #include <memory> |
23 | |
24 | #include <grpcpp/support/channel_arguments.h> |
25 | #include <grpcpp/support/config.h> |
26 | |
27 | namespace grpc_impl { |
28 | |
29 | class ServerBuilder; |
30 | class ServerInitializer; |
31 | } // namespace grpc_impl |
32 | namespace grpc { |
33 | |
34 | /// This interface is meant for internal usage only. Implementations of this |
35 | /// interface should add themselves to a \a ServerBuilder instance through the |
36 | /// \a InternalAddPluginFactory method. |
37 | class ServerBuilderPlugin { |
38 | public: |
39 | virtual ~ServerBuilderPlugin() {} |
40 | virtual grpc::string name() = 0; |
41 | |
42 | /// UpdateServerBuilder will be called at an early stage in |
43 | /// ServerBuilder::BuildAndStart(), right after the ServerBuilderOptions have |
44 | /// done their updates. |
45 | virtual void UpdateServerBuilder(grpc_impl::ServerBuilder* /*builder*/) {} |
46 | |
47 | /// InitServer will be called in ServerBuilder::BuildAndStart(), after the |
48 | /// Server instance is created. |
49 | virtual void InitServer(grpc_impl::ServerInitializer* si) = 0; |
50 | |
51 | /// Finish will be called at the end of ServerBuilder::BuildAndStart(). |
52 | virtual void Finish(grpc_impl::ServerInitializer* si) = 0; |
53 | |
54 | /// ChangeArguments is an interface that can be used in |
55 | /// ServerBuilderOption::UpdatePlugins |
56 | virtual void ChangeArguments(const grpc::string& name, void* value) = 0; |
57 | |
58 | /// UpdateChannelArguments will be called in ServerBuilder::BuildAndStart(), |
59 | /// before the Server instance is created. |
60 | virtual void UpdateChannelArguments(ChannelArguments* /*args*/) {} |
61 | |
62 | virtual bool has_sync_methods() const { return false; } |
63 | virtual bool has_async_methods() const { return false; } |
64 | }; |
65 | |
66 | } // namespace grpc |
67 | |
68 | #endif // GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H |
69 | |