ORE Studio 0.0.4
Loading...
Searching...
No Matches
client_options.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_COMMS_NET_CLIENT_OPTIONS_HPP
21#define ORES_COMMS_NET_CLIENT_OPTIONS_HPP
22
23#include <iosfwd>
24#include <string>
25#include <chrono>
26#include <cstdint>
27#include "ores.comms/messaging/handshake_protocol.hpp"
28
29namespace ores::comms::net {
30
34struct retry_options final {
40 std::uint32_t max_attempts{5};
41
47 std::chrono::milliseconds base_delay{10 * 100};
48
54 std::chrono::milliseconds max_delay{60 * 1000};
55
62 double jitter_factor{0.2};
63
70 bool auto_reconnect{true};
71};
72
73std::ostream& operator<<(std::ostream& s, const retry_options& v);
74
78struct client_options final {
82 std::string host = "localhost";
83
87 std::uint16_t port = 55555;
88
92 std::string client_identifier = "ores-client";
93
97 bool verify_certificate = true;
98
105 bool heartbeat_enabled = true;
106
113 std::uint32_t heartbeat_interval_seconds = 30;
114
119
127 std::uint8_t supported_compression = messaging::COMPRESSION_SUPPORT_ALL;
128};
129
130std::ostream& operator<<(std::ostream& s, const client_options& v);
131
132}
133
134#endif
Contains the networking elements of the comms library.
Definition client.hpp:42
Configuration for client retry and reconnection behavior.
Definition client_options.hpp:34
double jitter_factor
Jitter factor for randomizing retry delays.
Definition client_options.hpp:62
bool auto_reconnect
Whether to automatically reconnect after disconnect.
Definition client_options.hpp:70
std::chrono::milliseconds max_delay
Maximum delay between retry attempts.
Definition client_options.hpp:54
std::chrono::milliseconds base_delay
Base delay for exponential backoff.
Definition client_options.hpp:47
std::uint32_t max_attempts
Maximum number of connection attempts before giving up.
Definition client_options.hpp:40
Configuration for the client.
Definition client_options.hpp:78
bool verify_certificate
Whether to verify the server's certificate.
Definition client_options.hpp:97
std::string client_identifier
Client identifier to send when performing the handshake.
Definition client_options.hpp:92
std::string host
Host to connect to.
Definition client_options.hpp:82
std::uint16_t port
Port to connect to.
Definition client_options.hpp:87
retry_options retry
Retry and reconnection options.
Definition client_options.hpp:118
bool heartbeat_enabled
Whether to enable heartbeat (ping/pong) for connection monitoring.
Definition client_options.hpp:105
std::uint8_t supported_compression
Bitmask of compression types supported by this client.
Definition client_options.hpp:127
std::uint32_t heartbeat_interval_seconds
Interval between heartbeat pings in seconds.
Definition client_options.hpp:113