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
//! Subscription engine configuration.
use std::time::Duration;
/// Configuration for the subscription engine.
#[derive(Debug, Clone)]
pub struct SubscriptionConfig {
/// Maximum number of retry attempts for failed deliveries.
pub max_retries: u32,
/// Initial delay before the first retry.
pub retry_initial_delay: Duration,
/// Maximum delay between retries.
pub retry_max_delay: Duration,
/// Backoff multiplier for exponential backoff.
pub retry_backoff_factor: f64,
/// Delay before the first activation handshake attempt.
pub handshake_initial_delay: Duration,
/// Maximum number of activation handshake attempts.
pub handshake_max_attempts: u32,
/// Initial delay before retrying a failed activation handshake.
pub handshake_retry_initial_delay: Duration,
/// Maximum delay between activation handshake retries.
pub handshake_retry_max_delay: Duration,
/// How often to check for heartbeats that are due.
pub heartbeat_check_interval: Duration,
/// Number of consecutive failures before transitioning to `error` status.
pub error_threshold: u32,
/// Number of consecutive failures before transitioning to `off` status.
pub off_threshold: u32,
/// Supported channel types.
pub supported_channel_types: Vec<String>,
/// Lifetime of WebSocket binding tokens in seconds.
pub ws_token_lifetime_secs: i64,
/// SMTP settings for the email channel. `None` disables the email dispatcher.
pub smtp: Option<SmtpSettings>,
/// FHIR Messaging channel settings. `None` disables the messaging dispatcher.
pub messaging: Option<MessagingSettings>,
}
/// FHIR Messaging channel configuration.
#[derive(Debug, Clone)]
pub struct MessagingSettings {
/// Endpoint URL placed in `MessageHeader.source.endpoint`. Typically the
/// HFS base URL (`HFS_BASE_URL`).
pub source_endpoint: String,
/// When `true`, dispatch to private/loopback/link-local IPs is permitted.
/// Default `false` (SSRF guard on). Set
/// `HFS_SUBSCRIPTION_ALLOW_PRIVATE_ENDPOINTS=true` to opt in.
pub allow_private_endpoints: bool,
}
impl Default for SubscriptionConfig {
fn default() -> Self {
Self {
max_retries: 10,
retry_initial_delay: Duration::from_secs(1),
retry_max_delay: Duration::from_secs(60),
retry_backoff_factor: 2.0,
handshake_initial_delay: Duration::ZERO,
handshake_max_attempts: 1,
handshake_retry_initial_delay: Duration::from_secs(1),
handshake_retry_max_delay: Duration::from_secs(60),
heartbeat_check_interval: Duration::from_secs(30),
error_threshold: 3,
off_threshold: 10,
supported_channel_types: vec!["rest-hook".to_string()],
ws_token_lifetime_secs: 30,
smtp: None,
messaging: None,
}
}
}
/// SMTP transport encryption mode.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SmtpEncryption {
/// Plain SMTP with no transport encryption.
None,
/// STARTTLS — begin in plaintext and upgrade before AUTH.
StartTls,
/// Implicit TLS from connect (SMTPS, typically port 465).
Tls,
}
/// SMTP client configuration for the email channel.
#[derive(Debug, Clone)]
pub struct SmtpSettings {
/// SMTP relay host.
pub host: String,
/// SMTP relay port.
pub port: u16,
/// Optional SMTP auth username.
pub username: Option<String>,
/// Optional SMTP auth password.
pub password: Option<String>,
/// Transport encryption mode.
pub encryption: SmtpEncryption,
/// Default `From:` mailbox (RFC 5322). Required when email is enabled;
/// subscription headers may override on a per-message basis.
pub from_address: String,
/// Optional default subject template. If absent, a built-in template is used.
pub default_subject: Option<String>,
/// Per-send timeout in seconds.
pub timeout_secs: u64,
}