client-cpp  0.9.0
IFailoverStrategy.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
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 IFAILOVERSTRATEGY_HPP_
18 #define IFAILOVERSTRATEGY_HPP_
19 
20 #include <memory>
21 #include <cstdint>
22 
23 namespace kaa {
24 
25 enum class KaaFailoverReason {
33 };
34 
36  NOOP = 0,
37  RETRY,
41 };
42 
44 
45 public:
46  FailoverStrategyDecision(const FailoverStrategyAction& action, const std::int32_t& retryPeriod)
47  : action_(action), retryPeriod_(retryPeriod) {}
48 
50  : action_(action), retryPeriod_(0) {}
51 
53  return action_;
54  }
55 
56  std::size_t getRetryPeriod() const {
57  return retryPeriod_;
58  }
59 
60 private:
61  FailoverStrategyAction action_;
62  std::size_t retryPeriod_;
63 };
64 
66 public:
67 
69 
70  virtual ~IFailoverStrategy() {}
71 
72 };
73 
74 typedef std::shared_ptr<IFailoverStrategy> IFailoverStrategyPtr;
75 
76 }
77 
78 #endif /* IFAILOVERSTRATEGY_HPP_ */
std::shared_ptr< IFailoverStrategy > IFailoverStrategyPtr
FailoverStrategyDecision(const FailoverStrategyAction &action)
FailoverStrategyDecision(const FailoverStrategyAction &action, const std::int32_t &retryPeriod)
FailoverStrategyAction getAction() const
std::size_t getRetryPeriod() const
virtual FailoverStrategyDecision onFailover(KaaFailoverReason failover)=0
FailoverStrategyAction