Hazelcast C++ Client
Hazelcast C++ Client Library
All Classes Functions Variables Enumerations Enumerator Pages
connection_retry_config.h
1 /*
2  * Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
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 #pragma once
17 
18 #include <chrono>
19 
20 #include "hazelcast/util/export.h"
21 
22 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
23 #pragma warning(push)
24 #pragma warning(disable: 4251) //for dll export
25 #endif
26 
27 namespace hazelcast {
28  namespace client {
29  namespace config {
34  class HAZELCAST_API connection_retry_config {
35  public:
41  std::chrono::milliseconds get_initial_backoff_duration() const;
42 
48  set_initial_backoff_duration(std::chrono::milliseconds initial_backoff_duration);
49 
55  std::chrono::milliseconds get_max_backoff_duration() const;
56 
63  connection_retry_config &set_max_backoff_duration(std::chrono::milliseconds max_backoff_duration);
64 
70  double get_multiplier() const;
71 
76  connection_retry_config &set_multiplier(double multiplier);
77 
84  std::chrono::milliseconds get_cluster_connect_timeout() const;
85 
92  set_cluster_connect_timeout(std::chrono::milliseconds cluster_connect_timeout);
93 
101  double get_jitter() const;
102 
110  connection_retry_config &set_jitter(double jitter);
111 
112  private:
113  static constexpr std::chrono::milliseconds INITIAL_BACKOFF{1000};
114  static constexpr std::chrono::milliseconds MAX_BACKOFF{30000};
115  static constexpr std::chrono::milliseconds CLUSTER_CONNECT_TIMEOUT{(std::chrono::milliseconds::max)()};
116  static constexpr double JITTER = 0;
117  std::chrono::milliseconds initial_backoff_duration_ = INITIAL_BACKOFF;
118  std::chrono::milliseconds max_backoff_duration_ = MAX_BACKOFF;
119  double multiplier_ = 1.05;
120  std::chrono::milliseconds cluster_connect_timeout_ = CLUSTER_CONNECT_TIMEOUT;
121  double jitter_ = JITTER;
122  };
123 
124  }
125  }
126 }
127 
128 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
129 #pragma warning(pop)
130 #endif
Connection Retry Config is controls the period among the retries and when should a client gave up ret...