1 /* 2 Copyright (c) DataStax, 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 __TEST_RETRY_POLICY_HPP__ 18 #define __TEST_RETRY_POLICY_HPP__ 19 #include "cassandra.h" 20 21 #include "objects/object_base.hpp" 22 23 namespace test { namespace driver { 24 25 /** 26 * Wrapped retry policy object 27 */ 28 class RetryPolicy : public Object<CassRetryPolicy, cass_retry_policy_free> { 29 public: 30 /** 31 * Create the retry policy object from the native driver retry policy object 32 * 33 * @param retry_policy Native driver object 34 */ RetryPolicy(CassRetryPolicy * retry_policy)35 RetryPolicy(CassRetryPolicy* retry_policy) 36 : Object<CassRetryPolicy, cass_retry_policy_free>(retry_policy) {} 37 38 /** 39 * Create the retry policy object from the shared reference 40 * 41 * @param retry_policy Shared reference 42 */ RetryPolicy(Ptr retry_policy)43 RetryPolicy(Ptr retry_policy) 44 : Object<CassRetryPolicy, cass_retry_policy_free>(retry_policy) {} 45 }; 46 47 /** 48 * Wrapped default retry policy 49 */ 50 class DefaultRetryPolicy : public RetryPolicy { 51 public: 52 /** 53 * Create the default retry policy object from the native driver default retry 54 * policy object 55 */ DefaultRetryPolicy()56 DefaultRetryPolicy() 57 : RetryPolicy(cass_retry_policy_default_new()) {} 58 }; 59 60 /** 61 * Wrapped downgrading consistency retry policy 62 */ 63 class DowngradingConsistencyRetryPolicy : public RetryPolicy { 64 public: 65 /** 66 * Create the downgrading consistency retry policy object from the native 67 * driver downgrading consistency retry policy object 68 */ 69 DowngradingConsistencyRetryPolicy(); 70 }; 71 72 /** 73 * Wrapped fallthrough retry policy 74 */ 75 class FallthroughRetryPolicy : public RetryPolicy { 76 public: 77 /** 78 * Create the fallthrough retry policy object from the native driver 79 * fallthrough retry policy object 80 */ FallthroughRetryPolicy()81 FallthroughRetryPolicy() 82 : RetryPolicy(cass_retry_policy_fallthrough_new()) {} 83 }; 84 85 /** 86 * Wrapped logging retry policy 87 */ 88 class LoggingRetryPolicy : public RetryPolicy { 89 public: 90 /** 91 * Create the logging retry policy object from the native driver logging retry 92 * policy object with the given child policy 93 * 94 * @param child_policy Child retry policy being logged (CASS_LOG_INFO) 95 */ LoggingRetryPolicy(RetryPolicy child_policy)96 LoggingRetryPolicy(RetryPolicy child_policy) 97 : RetryPolicy(cass_retry_policy_logging_new(child_policy.get())) {} 98 }; 99 100 }} // namespace test::driver 101 102 #endif // __TEST_RETRY_POLICY_HPP__ 103