| 1 |
#ifndef PROTON_RECONNECT_OPTIONS_HPP |
| 2 |
#define PROTON_RECONNECT_OPTIONS_HPP |
| 3 |
|
| 4 |
/* |
| 5 |
* |
| 6 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 7 |
* or more contributor license agreements. See the NOTICE file |
| 8 |
* distributed with this work for additional information |
| 9 |
* regarding copyright ownership. The ASF licenses this file |
| 10 |
* to you under the Apache License, Version 2.0 (the |
| 11 |
* "License"); you may not use this file except in compliance |
| 12 |
* with the License. You may obtain a copy of the License at |
| 13 |
* |
| 14 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
* |
| 16 |
* Unless required by applicable law or agreed to in writing, |
| 17 |
* software distributed under the License is distributed on an |
| 18 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 19 |
* KIND, either express or implied. See the License for the |
| 20 |
* specific language governing permissions and limitations |
| 21 |
* under the License. |
| 22 |
* |
| 23 |
*/ |
| 24 |
|
| 25 |
#include "./internal/export.hpp" |
| 26 |
#include "./duration.hpp" |
| 27 |
#include "./source.hpp" |
| 28 |
|
| 29 |
#include <memory> |
| 30 |
#include <string> |
| 31 |
#include <vector> |
| 32 |
|
| 33 |
/// @file |
| 34 |
/// @copybrief proton::reconnect_options |
| 35 |
|
| 36 |
namespace proton { |
| 37 |
|
| 38 |
/// **Unsettled API** - Options for reconnect and failover after |
| 39 |
/// connection loss. |
| 40 |
/// |
| 41 |
/// These options determine a series of delays to coordinate |
| 42 |
/// reconnection attempts. They may be open-ended or limited in time. |
| 43 |
/// They may be evenly spaced or increasing at an exponential rate. |
| 44 |
/// |
| 45 |
/// Normal value semantics: copy or assign creates a separate copy of |
| 46 |
/// the options. |
| 47 |
/// |
| 48 |
/// @see messaging_handler, connection_options::reconnect() |
| 49 |
class reconnect_options { |
| 50 |
public: |
| 51 |
/// Create an empty set of options. |
| 52 |
PN_CPP_EXTERN reconnect_options(); |
| 53 |
|
| 54 |
/// Copy options. |
| 55 |
PN_CPP_EXTERN reconnect_options(const reconnect_options&); |
| 56 |
|
| 57 |
PN_CPP_EXTERN ~reconnect_options(); |
| 58 |
|
| 59 |
/// Copy options. |
| 60 |
PN_CPP_EXTERN reconnect_options& operator=(const reconnect_options&); |
| 61 |
|
| 62 |
/// The base value for recurring delays. The default is 10 |
| 63 |
/// milliseconds. |
| 64 |
PN_CPP_EXTERN reconnect_options& delay(duration); |
| 65 |
|
| 66 |
/// The scaling multiplier for successive reconnect delays. The |
| 67 |
/// default is 2.0. |
| 68 |
PN_CPP_EXTERN reconnect_options& delay_multiplier(float); |
| 69 |
|
| 70 |
/// The maximum delay between successive connect attempts. The |
| 71 |
/// default duration::FOREVER, meaning no limit. |
| 72 |
PN_CPP_EXTERN reconnect_options& max_delay(duration); |
| 73 |
|
| 74 |
/// The maximum number of reconnect attempts. The default is 0, |
| 75 |
/// meaning no limit. |
| 76 |
PN_CPP_EXTERN reconnect_options& max_attempts(int); |
| 77 |
|
| 78 |
/// Deprecated - use connection_options::failover_urls |
| 79 |
/// Alternative connection URLs used for failover. There are none |
| 80 |
/// by default. |
| 81 |
PN_CPP_DEPRECATED("use connection_options::failover_urls()") |
| 82 |
PN_CPP_EXTERN reconnect_options& failover_urls(const std::vector<std::string>& conn_urls); |
| 83 |
|
| 84 |
private: |
| 85 |
class impl; |
| 86 |
std::unique_ptr<impl> impl_; |
| 87 |
|
| 88 |
/// @cond INTERNAL |
| 89 |
friend class connection_options; |
| 90 |
friend class container; |
| 91 |
/// @endcond |
| 92 |
}; |
| 93 |
|
| 94 |
} // proton |
| 95 |
|
| 96 |
#endif // PROTON_RECONNECT_OPTIONS_HPP |