• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2015 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 GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_METHOD_PARAMS_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_METHOD_PARAMS_H
21 
22 #include <grpc/support/port_platform.h>
23 
24 #include "src/core/lib/channel/status_util.h"
25 #include "src/core/lib/gprpp/ref_counted.h"
26 #include "src/core/lib/gprpp/ref_counted_ptr.h"
27 #include "src/core/lib/iomgr/exec_ctx.h"  // for grpc_millis
28 #include "src/core/lib/json/json.h"
29 
30 namespace grpc_core {
31 namespace internal {
32 
33 class ClientChannelMethodParams : public RefCounted<ClientChannelMethodParams> {
34  public:
35   enum WaitForReady {
36     WAIT_FOR_READY_UNSET = 0,
37     WAIT_FOR_READY_FALSE,
38     WAIT_FOR_READY_TRUE
39   };
40 
41   struct RetryPolicy {
42     int max_attempts = 0;
43     grpc_millis initial_backoff = 0;
44     grpc_millis max_backoff = 0;
45     float backoff_multiplier = 0;
46     StatusCodeSet retryable_status_codes;
47   };
48 
49   /// Creates a method_parameters object from \a json.
50   /// Intended for use with ServiceConfig::CreateMethodConfigTable().
51   static RefCountedPtr<ClientChannelMethodParams> CreateFromJson(
52       const grpc_json* json);
53 
timeout()54   grpc_millis timeout() const { return timeout_; }
wait_for_ready()55   WaitForReady wait_for_ready() const { return wait_for_ready_; }
retry_policy()56   const RetryPolicy* retry_policy() const { return retry_policy_.get(); }
57 
58  private:
59   // So New() can call our private ctor.
60   template <typename T, typename... Args>
61   friend T* grpc_core::New(Args&&... args);
62 
63   // So Delete() can call our private dtor.
64   template <typename T>
65   friend void grpc_core::Delete(T*);
66 
ClientChannelMethodParams()67   ClientChannelMethodParams() {}
~ClientChannelMethodParams()68   virtual ~ClientChannelMethodParams() {}
69 
70   grpc_millis timeout_ = 0;
71   WaitForReady wait_for_ready_ = WAIT_FOR_READY_UNSET;
72   UniquePtr<RetryPolicy> retry_policy_;
73 };
74 
75 }  // namespace internal
76 }  // namespace grpc_core
77 
78 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_METHOD_PARAMS_H */
79