client-cpp  0.7.4
IFailoverStrategy.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2015 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 Failover {
31 };
32 
34  NOOP = 0,
35  RETRY,
38  STOP_APP
39 };
40 
42 
43 public:
44  FailoverStrategyDecision(const FailoverStrategyAction& action, const std::int32_t& retryPeriod)
45  : action_(action), retryPeriod_(retryPeriod) {}
46 
48  : action_(action), retryPeriod_(0) {}
49 
51  return action_;
52  }
53 
54  std::size_t getRetryPeriod() const {
55  return retryPeriod_;
56  }
57 
58 private:
59  FailoverStrategyAction action_;
60  std::size_t retryPeriod_;
61 };
62 
64 public:
65 
66  virtual FailoverStrategyDecision onFailover(Failover failover) = 0;
67 
68  virtual ~IFailoverStrategy() {}
69 
70 };
71 
72 typedef std::shared_ptr<IFailoverStrategy> IFailoverStrategyPtr;
73 
74 }
75 
76 #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(Failover failover)=0
FailoverStrategyAction