1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
//! Backend preset methods for [`RustvelloBuilder`].
use super::RustvelloBuilder;
impl RustvelloBuilder {
/// Use all in-memory backends (suitable for testing and development).
///
/// No connections are established — backends are created during
/// [`build()`](Self::build).
#[cfg(feature = "mem")]
#[cfg_attr(docsrs, doc(cfg(feature = "mem")))]
pub fn memory(mut self) -> Self {
self.backend_preset = Some(super::BackendPreset::Memory);
self
}
/// Use all SQLite backends with the given database path.
///
/// The database file is opened during [`build()`](Self::build), not here.
#[cfg(feature = "sqlite")]
#[cfg_attr(docsrs, doc(cfg(feature = "sqlite")))]
pub fn sqlite(self, path: &str, app_id: &str) -> Self {
self.sqlite_with_options(path, app_id, rustvello_sqlite::db::SqliteOptions::default())
}
/// Co-located atomic publication with explicit connection synchronization.
/// All producers/workers must use the same local path, app ID and FULL policy.
#[cfg(feature = "sqlite")]
pub fn sqlite_with_options(
mut self,
path: &str,
app_id: &str,
options: rustvello_sqlite::db::SqliteOptions,
) -> Self {
self.backend_preset = Some(super::BackendPreset::Sqlite {
path: path.to_string(),
app_id: app_id.to_string(),
options,
});
self
}
/// Use all Redis backends with the given connection URI.
///
/// The connection pool is created during [`build()`](Self::build), not here.
///
/// # Examples
///
/// ```rust,no_run
/// # use rustvello::prelude::*;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let app = Rustvello::builder()
/// .redis("redis://127.0.0.1/", "my_app")
/// .build().await?;
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "redis")]
#[cfg_attr(docsrs, doc(cfg(feature = "redis")))]
pub fn redis(self, uri: &str, app_id: &str) -> Self {
self.redis_with_options(
uri,
app_id,
rustvello_redis::prelude::RedisOptions::default(),
)
}
/// Use all Redis ports with bounded queue, lease and connection policy.
#[cfg(feature = "redis")]
pub fn redis_with_options(
mut self,
uri: &str,
app_id: &str,
options: rustvello_redis::prelude::RedisOptions,
) -> Self {
self.backend_preset = Some(super::BackendPreset::Redis {
uri: uri.to_string(),
app_id: app_id.to_string(),
options,
tls: None,
});
self
}
/// Use all Redis ports over TLS with explicit private trust roots.
#[cfg(feature = "redis")]
pub fn redis_tls_with_options(
mut self,
uri: &str,
app_id: &str,
options: rustvello_redis::prelude::RedisOptions,
tls: rustvello_redis::prelude::RedisTlsOptions,
) -> Self {
self.backend_preset = Some(super::BackendPreset::Redis {
uri: uri.to_string(),
app_id: app_id.to_string(),
options,
tls: Some(tls),
});
self
}
/// Use all MongoDB backends with the given connection URI and database name.
///
/// The connection pool is created during [`build()`](Self::build), not here.
///
/// # Examples
///
/// ```rust,no_run
/// # use rustvello::prelude::*;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let app = Rustvello::builder()
/// .mongodb("mongodb://localhost:27017", "rustvello_db", "my_app")
/// .build().await?;
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "mongodb")]
#[cfg_attr(docsrs, doc(cfg(feature = "mongodb")))]
pub fn mongodb(mut self, uri: &str, db_name: &str, app_id: &str) -> Self {
self.backend_preset = Some(super::BackendPreset::MongoDB {
uri: uri.to_string(),
db_name: db_name.to_string(),
app_id: app_id.to_string(),
});
self
}
/// Use a RabbitMQ broker with the given AMQP URI and queue prefix.
///
/// Only sets the broker — orchestrator, state backend, client data store,
/// and trigger store must be provided separately (e.g. via `.redis()` or
/// `.sqlite()`). This matches the Python `pynenc_rabbitmq` plugin which
/// only provides a broker implementation.
///
/// The connection is established during [`build()`](Self::build), not here.
///
/// # Examples
///
/// ```rust,no_run
/// # use rustvello::prelude::*;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let app = Rustvello::builder()
/// .rabbitmq("amqp://localhost:5672", "myapp")
/// .redis("redis://127.0.0.1/", "my_app")
/// .build().await?;
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "rabbitmq")]
#[cfg_attr(docsrs, doc(cfg(feature = "rabbitmq")))]
pub fn rabbitmq(mut self, uri: &str, prefix: &str) -> Self {
self.rabbitmq_config = Some(super::RabbitMqConfig {
uri: uri.to_string(),
prefix: prefix.to_string(),
});
self
}
/// Use all PostgreSQL backends with the given connection string.
///
/// The connection pool is created during [`build()`](Self::build), not here.
///
/// # Examples
///
/// ```rust,no_run
/// # use rustvello::prelude::*;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let app = Rustvello::builder()
/// .postgres("postgresql://user:pass@localhost/mydb", "my_app")
/// .build().await?;
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "postgres")]
#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))]
pub fn postgres(self, connection_string: &str, app_id: &str) -> Self {
self.postgres_with_options(
connection_string,
app_id,
rustvello_postgres::db::PostgresOptions::default(),
)
}
/// Networked atomic-publication profile with bounded I/O and admission.
#[cfg(feature = "postgres")]
pub fn postgres_with_options(
mut self,
connection_string: &str,
app_id: &str,
options: rustvello_postgres::db::PostgresOptions,
) -> Self {
self.backend_preset = Some(super::BackendPreset::Postgres {
connection_string: connection_string.to_string(),
app_id: app_id.to_string(),
options,
});
self
}
/// Use all PostgreSQL backends with TLS encryption.
///
/// Requires both the `postgres` and `tls` features.
#[cfg(all(feature = "postgres", feature = "tls"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "postgres", feature = "tls"))))]
pub fn postgres_tls(mut self, connection_string: &str, app_id: &str) -> Self {
self.backend_preset = Some(super::BackendPreset::PostgresTls {
connection_string: connection_string.to_string(),
app_id: app_id.to_string(),
options: rustvello_postgres::db::PostgresOptions::default(),
tls: None,
});
self
}
/// Use verified PostgreSQL TLS with complete runtime and trust policy.
#[cfg(all(feature = "postgres", feature = "tls"))]
pub fn postgres_tls_with_options(
mut self,
connection_string: &str,
app_id: &str,
options: rustvello_postgres::db::PostgresOptions,
tls: rustvello_postgres::db::PostgresTlsOptions,
) -> Self {
self.backend_preset = Some(super::BackendPreset::PostgresTls {
connection_string: connection_string.to_string(),
app_id: app_id.to_string(),
options,
tls: Some(tls),
});
self
}
/// Use all MongoDB 3.6+ backends with the given connection URI and database name.
///
/// The connection pool is created during [`build()`](Self::build), not here.
///
/// # Examples
///
/// ```rust,no_run
/// # use rustvello::prelude::*;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let app = Rustvello::builder()
/// .mongo3("mongodb://localhost:27017", "rustvello_db", "my_app")
/// .build().await?;
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "mongodb3")]
#[cfg_attr(docsrs, doc(cfg(feature = "mongodb3")))]
pub fn mongo3(mut self, uri: &str, db_name: &str, app_id: &str) -> Self {
self.backend_preset = Some(super::BackendPreset::Mongo3 {
uri: uri.to_string(),
db_name: db_name.to_string(),
app_id: app_id.to_string(),
});
self
}
}