GRPC Core  18.0.0
service_config_parser.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SERVICE_CONFIG_PARSER_H
18 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SERVICE_CONFIG_PARSER_H
19 
21 
22 #include <memory>
23 
24 #include "absl/container/inlined_vector.h"
25 
27 
29 #include "src/core/lib/json/json.h"
30 
31 namespace grpc_core {
32 
33 // Service config parser registry.
34 // See service_config.h for more information.
36  public:
39  class ParsedConfig {
40  public:
41  virtual ~ParsedConfig() = default;
42  };
43 
45  class Parser {
46  public:
47  virtual ~Parser() = default;
48 
49  virtual std::unique_ptr<ParsedConfig> ParseGlobalParams(
50  const grpc_channel_args*, const Json& /* json */,
52  // Avoid unused parameter warning on debug-only parameter
53  (void)error;
54  GPR_DEBUG_ASSERT(error != nullptr);
55  return nullptr;
56  }
57 
58  virtual std::unique_ptr<ParsedConfig> ParsePerMethodParams(
59  const grpc_channel_args*, const Json& /* json */,
61  // Avoid unused parameter warning on debug-only parameter
62  (void)error;
63  GPR_DEBUG_ASSERT(error != nullptr);
64  return nullptr;
65  }
66  };
67 
68  static constexpr int kNumPreallocatedParsers = 4;
69  typedef absl::InlinedVector<std::unique_ptr<ParsedConfig>,
72 
73  static void Init();
74  static void Shutdown();
75 
82  static size_t RegisterParser(std::unique_ptr<Parser> parser);
83 
85  const Json& json,
87 
89  const grpc_channel_args* args, const Json& json,
91 };
92 
93 } // namespace grpc_core
94 
95 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SERVICE_CONFIG_PARSER_H */
Definition: json.h:38
This is the base class that all service config parsers MUST use to store parsed service config data.
Definition: service_config_parser.h:39
This is the base class that all service config parsers should derive from.
Definition: service_config_parser.h:45
virtual std::unique_ptr< ParsedConfig > ParseGlobalParams(const grpc_channel_args *, const Json &, grpc_error_handle *error)
Definition: service_config_parser.h:49
virtual std::unique_ptr< ParsedConfig > ParsePerMethodParams(const grpc_channel_args *, const Json &, grpc_error_handle *error)
Definition: service_config_parser.h:58
Definition: service_config_parser.h:35
static ParsedConfigVector ParseGlobalParameters(const grpc_channel_args *args, const Json &json, grpc_error_handle *error)
Definition: service_config_parser.cc:48
static constexpr int kNumPreallocatedParsers
Definition: service_config_parser.h:68
static size_t RegisterParser(std::unique_ptr< Parser > parser)
Globally register a service config parser.
Definition: service_config_parser.cc:42
static void Shutdown()
Definition: service_config_parser.cc:37
absl::InlinedVector< std::unique_ptr< ParsedConfig >, kNumPreallocatedParsers > ParsedConfigVector
Definition: service_config_parser.h:71
static ParsedConfigVector ParsePerMethodParameters(const grpc_channel_args *args, const Json &json, grpc_error_handle *error)
Definition: service_config_parser.cc:69
static void Init()
Definition: service_config_parser.cc:32
#define GPR_DEBUG_ASSERT(x)
Definition: log.h:101
grpc_error_handle error
Definition: lame_client.cc:54
Round Robin Policy.
Definition: backend_metric.cc:26
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: error_internal.h:41