1use std::sync::Arc;
2use std::time::Duration;
3
4use rns_transport::hash::AddressHash;
5use rns_transport::identity::PrivateIdentity;
6use rns_transport::transport::Transport;
7use tokio::runtime::Handle;
8
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub struct InProcessBackendLimits {
11 pub event_retention: usize,
12 pub delivery_retention: usize,
13 pub send_report_retention: usize,
14}
15
16impl Default for InProcessBackendLimits {
17 fn default() -> Self {
18 Self { event_retention: 2_048, delivery_retention: 1_024, send_report_retention: 512 }
19 }
20}
21
22#[derive(Clone)]
23pub struct InProcessBackendConfig {
24 pub runtime_id: String,
25 pub runtime_handle: Handle,
26 pub transport: Arc<Transport>,
27 pub identity: PrivateIdentity,
28 pub source_destination: AddressHash,
29 pub propagation_relay: Option<AddressHash>,
30 pub link_connect_timeout: Duration,
31 pub link_connect_attempts: usize,
32 pub resource_transfer_timeout: Duration,
33 pub limits: InProcessBackendLimits,
34}
35
36impl InProcessBackendConfig {
37 pub fn new(
38 runtime_id: impl Into<String>,
39 runtime_handle: Handle,
40 transport: Arc<Transport>,
41 identity: PrivateIdentity,
42 source_destination: AddressHash,
43 ) -> Self {
44 Self {
45 runtime_id: runtime_id.into(),
46 runtime_handle,
47 transport,
48 identity,
49 source_destination,
50 propagation_relay: None,
51 link_connect_timeout: Duration::from_secs(20),
52 link_connect_attempts: 3,
53 resource_transfer_timeout: Duration::from_secs(120),
54 limits: InProcessBackendLimits::default(),
55 }
56 }
57}