forked from praxis-proxy/praxis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
71 lines (60 loc) · 2.2 KB
/
Copy pathlib.rs
File metadata and controls
71 lines (60 loc) · 2.2 KB
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
// SPDX-License-Identifier: MIT
// Copyright (c) 2024 Praxis Contributors
#![deny(unreachable_pub)]
//! Protocol adapters for Praxis.
use praxis_core::{PingoraServerRuntime, ProxyError, config::Config};
use tokio::sync::watch;
mod pipelines;
pub use pipelines::ListenerPipelines;
/// Process-wide connection limit.
pub mod connections;
/// HTTP protocol implementations.
pub mod http;
/// Raw TCP/L4 forwarding protocol.
pub mod tcp;
/// Shared TLS settings builder for HTTP and TCP listeners.
pub(crate) mod tls_setup;
// -----------------------------------------------------------------------------
// CertWatcherShutdowns
// -----------------------------------------------------------------------------
/// Collected TLS certificate watcher shutdown senders.
///
/// Keeps [`watch::Sender`]s alive so that background [`CertWatcher`]
/// tasks run until the process exits. Dropping these senders signals
/// the watchers to stop.
///
/// [`watch::Sender`]: tokio::sync::watch::Sender
/// [`CertWatcher`]: praxis_tls::watcher::CertWatcher
pub struct CertWatcherShutdowns {
/// Shutdown senders kept alive for the server lifetime.
_senders: Vec<watch::Sender<bool>>,
}
impl CertWatcherShutdowns {
/// Wrap collected shutdown senders.
pub fn new(senders: Vec<watch::Sender<bool>>) -> Self {
Self { _senders: senders }
}
}
// -----------------------------------------------------------------------------
// Protocol
// -----------------------------------------------------------------------------
/// A protocol implementation that registers services onto a shared server runtime.
pub trait Protocol: Send {
/// Register this protocol's services. Does not block.
///
/// Returns any TLS certificate watcher shutdown senders. The
/// caller must keep these alive until server shutdown; dropping
/// them signals the watcher tasks to stop.
///
/// # Errors
///
/// Returns [`ProxyError`] if listener binding or setup fails.
///
/// [`ProxyError`]: praxis_core::ProxyError
fn register(
self: Box<Self>,
server: &mut PingoraServerRuntime,
config: &Config,
pipelines: &ListenerPipelines,
) -> Result<Vec<watch::Sender<bool>>, ProxyError>;
}