nautilus_tardis/common/consts.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Tardis adapter constants.
17
18use std::{num::NonZeroU32, sync::LazyLock};
19
20use nautilus_model::identifiers::{ClientId, Venue};
21use nautilus_network::ratelimiter::quota::Quota;
22use ustr::Ustr;
23
24/// The Tardis adapter identifier string.
25pub const TARDIS: &str = "TARDIS";
26
27/// Static venue instance.
28pub static TARDIS_VENUE: LazyLock<Venue> = LazyLock::new(|| Venue::new(Ustr::from(TARDIS)));
29
30/// Static client ID instance.
31pub static TARDIS_CLIENT_ID: LazyLock<ClientId> =
32 LazyLock::new(|| ClientId::new(Ustr::from(TARDIS)));
33
34/// Environment variable name for the Tardis API key.
35pub const TARDIS_API_KEY: &str = "TARDIS_API_KEY";
36
37/// Environment variable name for the Tardis Machine WebSocket URL.
38pub const TARDIS_MACHINE_WS_URL: &str = "TARDIS_MACHINE_WS_URL";
39
40/// Rate limit key for Tardis REST API requests.
41pub const TARDIS_REST_RATE_KEY: &str = "tardis_rest";
42
43/// Default rate limit for Tardis REST API (10 requests per second).
44pub static TARDIS_REST_QUOTA: LazyLock<Quota> = LazyLock::new(|| {
45 Quota::per_second(NonZeroU32::new(10).expect("non-zero")).expect("valid quota")
46});
47
48/// Maximum reconnection delay for the Tardis Machine WebSocket in seconds.
49pub const WS_MAX_RECONNECT_DELAY_SECS: u64 = 30;
50
51/// Initial reconnection delay for the Tardis Machine WebSocket in seconds.
52pub const WS_INITIAL_RECONNECT_DELAY_SECS: u64 = 1;
53
54/// Heartbeat (ping) interval for the Tardis Machine WebSocket in seconds.
55pub const WS_HEARTBEAT_INTERVAL_SECS: u64 = 10;