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
// Copyright AGNTCY Contributors (https://github.com/agntcy)
// SPDX-License-Identifier: Apache-2.0
use slim_auth::traits::{TokenProvider, Verifier};
use slim_datapath::api::ProtoName;
use crate::{
Direction, SessionError, SlimChannelSender,
common::{AppChannelSender, SessionMessage},
session_config::SessionConfig,
subscription_manager::{SubscriptionManager, SubscriptionOps},
};
/// Settings struct for constructing session components.
///
/// This struct encapsulates all the parameters needed to construct
/// `SessionParticipant`, `SessionModerator`, and `SessionController`.
/// It reduces the number of parameters passed to internal constructors
/// and provides a clean internal API.
///
/// # Note
///
/// This struct is primarily for internal use. External users should use
/// the `SessionBuilder` for a more ergonomic API.
#[derive(Clone)]
pub(crate) struct SessionSettings<P, V, M = SubscriptionManager>
where
P: TokenProvider + Send + Sync + Clone + 'static,
V: Verifier + Send + Sync + Clone + 'static,
M: SubscriptionOps,
{
/// Session ID
pub(crate) id: u32,
/// Local endpoint name
pub(crate) source: ProtoName,
/// Remote endpoint or group name
/// used to send application data
pub(crate) destination: ProtoName,
/// Group name for control messages
/// in P2P session is the same as destination
pub(crate) control: ProtoName,
/// Session configuration
pub(crate) config: SessionConfig,
/// Direction for data message flow (send, receive, both, or none)
pub(crate) direction: Direction,
/// Channel for sending messages to SLIM
pub(crate) slim_tx: SlimChannelSender,
/// Channel for sending messages to the application
pub(crate) app_tx: AppChannelSender,
/// Tx channel for sending messages to session queue
pub(crate) tx_session: tokio::sync::mpsc::Sender<SessionMessage>,
/// Channel to send messages to the session layer
pub(crate) tx_to_session_layer: tokio::sync::mpsc::Sender<Result<SessionMessage, SessionError>>,
/// Identity token provider
pub(crate) identity_provider: P,
/// Identity token verifier
pub(crate) identity_verifier: V,
/// Graceful shutdown timeout - time to drain pending messages during shutdown
pub(crate) graceful_shutdown_timeout: Option<std::time::Duration>,
/// Subscription manager for ACK-aware subscribe/unsubscribe operations
pub(crate) subscription_manager: M,
/// Service ID for tracing — identifies which service instance owns this session
pub(crate) service_id: String,
}