Skip to main content

nautilus_infrastructure/
lib.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//! Database and messaging infrastructure for [NautilusTrader](https://nautilustrader.io).
17//!
18//! The `nautilus-infrastructure` crate provides backend database implementations and message bus adapters
19//! that enable NautilusTrader to scale from development to production deployments. This includes
20//! enterprise-grade data persistence and messaging capabilities:
21//!
22//! - **Redis integration**: Cache database and message bus implementations using Redis.
23//! - **PostgreSQL integration**: SQL-based cache database with full data models.
24//! - **Connection management**: Connection handling with retry logic and health monitoring.
25//! - **Serialization options**: Support for JSON and MessagePack encoding formats.
26//! - **Python bindings**: PyO3 integration for Python interoperability.
27//!
28//! The crate supports multiple database backends through feature flags, allowing users to choose
29//! the appropriate infrastructure components for their specific deployment requirements and scale.
30//!
31//! # NautilusTrader
32//!
33//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
34//! engine for multi-asset, multi-venue trading systems.
35//!
36//! The system spans research, deterministic simulation, and live execution within a single
37//! event-driven architecture, providing research-to-live semantic parity.
38//!
39//! # Feature Flags
40//!
41//! This crate provides feature flags to control source code inclusion during compilation,
42//! depending on the intended use case, i.e. whether to provide Python bindings
43//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
44//! or as part of a Rust only build.
45//!
46//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
47//! - `redis`: Enables the Redis cache database and message bus backing implementations.
48//! - `postgres`: Enables the PostgreSQL SQLx models and cache database backend.
49//! - `extension-module`: Builds the crate as a Python extension module.
50
51#![warn(rustc::all)]
52#![deny(unsafe_code)]
53#![deny(unsafe_op_in_unsafe_fn)]
54#![deny(nonstandard_style)]
55#![deny(missing_debug_implementations)]
56#![deny(clippy::missing_errors_doc)]
57#![deny(clippy::missing_panics_doc)]
58#![deny(rustdoc::broken_intra_doc_links)]
59
60#[cfg(feature = "python")]
61pub mod python;
62
63#[cfg(feature = "redis")]
64pub mod redis;
65
66#[cfg(feature = "postgres")]
67pub mod sql;