rightsize_modules/lib.rs
1#![warn(missing_docs)]
2#![forbid(unsafe_code)]
3
4//! `rightsize-modules` ships eighteen preconfigured containers on top of the
5//! `rightsize` core: Redis, Memcached, ArangoDB, MongoDB, Redpanda, Kafka,
6//! SpringCloudConfig, PostgreSQL, MySQL, Apache Pinot, RabbitMQ, MariaDB, WireMock,
7//! ClickHouse, Keycloak, Neo4j, Floci, and Apache Flink. Each module is a thin
8//! newtype wrapping [`rightsize`]'s `Container` builder — no subclassing, just the
9//! spec-customizer and post-start hooks the core exposes — with connection helpers on
10//! its guard.
11//!
12//! Backend wiring is a Cargo feature choice, not a runtime one: `backend-msb` and
13//! `backend-docker` (both on by default) pull in `rightsize-msb` and
14//! `rightsize-docker` respectively so consumers can trim the dependency they don't
15//! need. The feature-enabled backends register themselves the first time any module
16//! starts — no `register_provider` boilerplate; see [`register_default_backends`]
17//! for the one case where calling it yourself is still useful.
18
19/// Registers the feature-enabled backend providers (`backend-msb`, `backend-docker`)
20/// with [`rightsize::backends`]. Runs its body once per process, and the core
21/// registry is itself idempotent by provider name, so calling this again — or also
22/// registering a provider by hand — is harmless.
23///
24/// Every module's `start` calls this on its way into the core, so consumers of this
25/// crate write no backend wiring at all. Call it yourself only when the **first**
26/// container your process starts is a plain [`rightsize::Container`] rather than one
27/// of these modules (backend resolution happens at that first start and is cached
28/// for the life of the process).
29pub fn register_default_backends() {
30 static ONCE: std::sync::Once = std::sync::Once::new();
31 ONCE.call_once(|| {
32 #[cfg(feature = "backend-msb")]
33 rightsize::backends::register_provider(Box::new(rightsize_msb::MsbBackendProvider));
34 #[cfg(feature = "backend-docker")]
35 rightsize::backends::register_provider(Box::new(rightsize_docker::DockerBackendProvider));
36 });
37}
38
39pub mod arango;
40pub mod clickhouse;
41pub mod flink;
42pub mod floci;
43pub mod kafka;
44pub mod keycloak;
45pub mod mariadb;
46pub mod memcached;
47pub mod mongodb;
48pub mod mysql;
49pub mod neo4j;
50pub mod pinot;
51pub mod postgres;
52pub mod rabbitmq;
53pub mod redis;
54pub mod redpanda;
55pub mod spring_cloud_config;
56pub mod wiremock;
57
58pub use arango::{ArangoContainer, ArangoGuard};
59pub use clickhouse::{ClickHouseContainer, ClickHouseGuard};
60pub use flink::{FlinkContainer, FlinkGuard};
61pub use floci::{FlociContainer, FlociGuard};
62pub use kafka::{KafkaContainer, KafkaGuard};
63pub use keycloak::{KeycloakContainer, KeycloakGuard};
64pub use mariadb::{MariaDbContainer, MariaDbGuard};
65pub use memcached::{MemcachedContainer, MemcachedGuard};
66pub use mongodb::{MongoDbContainer, MongoDbGuard};
67pub use mysql::{MySqlContainer, MySqlGuard};
68pub use neo4j::{Neo4jContainer, Neo4jGuard};
69pub use pinot::{PinotContainer, PinotGuard};
70pub use postgres::{PostgresContainer, PostgresGuard};
71pub use rabbitmq::{RabbitMqContainer, RabbitMqGuard};
72pub use redis::{RedisContainer, RedisGuard};
73pub use redpanda::{RedpandaContainer, RedpandaGuard};
74pub use spring_cloud_config::{SpringCloudConfigContainer, SpringCloudConfigGuard};
75pub use wiremock::{WireMockContainer, WireMockGuard};