mirror of
https://github.com/telemt/telemt.git
synced 2026-10-10 19:35:58 +03:00
Proxy Shared User Drafts
This commit is contained in:
@@ -75,6 +75,7 @@ fn test_runtime_with_dc(
|
||||
carriers: Arc::from([carrier]),
|
||||
carrier_negotiation_deadlines_secs: [3, 5, 8, 12],
|
||||
capability: [7; 32],
|
||||
credential_id: [0; 16],
|
||||
key_fingerprint: "0000000000000000".to_string(),
|
||||
max_sessions: 4,
|
||||
max_streams: 16,
|
||||
@@ -134,6 +135,7 @@ fn test_runtime_with_dc(
|
||||
false,
|
||||
limits,
|
||||
timeouts,
|
||||
None,
|
||||
);
|
||||
TestRuntime {
|
||||
session,
|
||||
|
||||
@@ -24,6 +24,7 @@ fn session() -> (Arc<WebSession>, Arc<WebProcessRuntime>) {
|
||||
carriers: Arc::from([WebCarrier::Https]),
|
||||
carrier_negotiation_deadlines_secs: [3, 5, 8, 12],
|
||||
capability: [0; 32],
|
||||
credential_id: [0; 16],
|
||||
key_fingerprint: "0000000000000000".to_string(),
|
||||
max_sessions: 1,
|
||||
max_streams: 1,
|
||||
@@ -50,6 +51,7 @@ fn session() -> (Arc<WebSession>, Arc<WebProcessRuntime>) {
|
||||
false,
|
||||
WebLimitsConfig::default(),
|
||||
timeouts,
|
||||
None,
|
||||
);
|
||||
(session, manager)
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ fn new_session_with_automatic(
|
||||
carriers: Arc::from([WebCarrier::HttpsLanes]),
|
||||
carrier_negotiation_deadlines_secs: [3, 5, 8, 12],
|
||||
capability: [0; 32],
|
||||
credential_id: [0; 16],
|
||||
key_fingerprint: "0000000000000000".to_string(),
|
||||
max_sessions: 1,
|
||||
max_streams: 2,
|
||||
@@ -65,6 +66,7 @@ fn new_session_with_automatic(
|
||||
false,
|
||||
limits,
|
||||
WebTimeoutsConfig::default(),
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ pub(crate) enum SessionCloseReason {
|
||||
WebSocketEnded,
|
||||
/// An authenticated control-plane request selected this session.
|
||||
ApiClose,
|
||||
/// Process user authority revoked or replaced the authenticated credential.
|
||||
UserDisabled,
|
||||
/// A graceful operator drain reached its force-close deadline.
|
||||
OperatorForce,
|
||||
/// Terminal process shutdown closed all remaining sessions.
|
||||
@@ -33,7 +35,7 @@ pub(crate) enum SessionCloseReason {
|
||||
|
||||
impl SessionCloseReason {
|
||||
/// Complete fixed reason set in stable API and metric order.
|
||||
pub(crate) const ALL: [Self; 11] = [
|
||||
pub(crate) const ALL: [Self; 12] = [
|
||||
Self::ClientDelete,
|
||||
Self::BridgeRecovery,
|
||||
Self::PeerIdle,
|
||||
@@ -43,6 +45,7 @@ impl SessionCloseReason {
|
||||
Self::Backpressure,
|
||||
Self::WebSocketEnded,
|
||||
Self::ApiClose,
|
||||
Self::UserDisabled,
|
||||
Self::OperatorForce,
|
||||
Self::RuntimeShutdown,
|
||||
];
|
||||
@@ -59,6 +62,7 @@ impl SessionCloseReason {
|
||||
Self::Backpressure => "backpressure",
|
||||
Self::WebSocketEnded => "websocket_ended",
|
||||
Self::ApiClose => "api_close",
|
||||
Self::UserDisabled => "user_disabled",
|
||||
Self::OperatorForce => "operator_force",
|
||||
Self::RuntimeShutdown => "runtime_shutdown",
|
||||
}
|
||||
@@ -217,6 +221,20 @@ impl WebSession {
|
||||
|
||||
/// Atomically closes a session only when reconnect grace is still due.
|
||||
pub(crate) fn close_if_due(&self, now: Instant) -> bool {
|
||||
if self.cancel.is_cancelled() {
|
||||
let released = {
|
||||
let mut state = self.state.lock();
|
||||
if state.closed || state.close_requested.is_some() {
|
||||
None
|
||||
} else {
|
||||
Some(self.release_on_close_locked(&mut state, SessionCloseReason::UserDisabled))
|
||||
}
|
||||
};
|
||||
if let Some(released) = released {
|
||||
self.finish_close(released);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
let healthy = {
|
||||
let mut state = self.state.lock();
|
||||
self.carrier_health_ready_locked(&mut state, now)
|
||||
|
||||
@@ -320,6 +320,7 @@ mod tests {
|
||||
carriers: Arc::from([carrier]),
|
||||
carrier_negotiation_deadlines_secs: [3, 5, 8, 12],
|
||||
capability: [0; 32],
|
||||
credential_id: [0; 16],
|
||||
key_fingerprint: "0000000000000000".to_string(),
|
||||
max_sessions: 1,
|
||||
max_streams: 1,
|
||||
@@ -342,6 +343,7 @@ mod tests {
|
||||
false,
|
||||
WebLimitsConfig::default(),
|
||||
WebTimeoutsConfig::default(),
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ fn session_with_automatic(automatic: bool) -> Arc<WebSession> {
|
||||
carriers: Arc::from([WebCarrier::Https]),
|
||||
carrier_negotiation_deadlines_secs: [3, 5, 8, 12],
|
||||
capability: [0; 32],
|
||||
credential_id: [0; 16],
|
||||
key_fingerprint: "0000000000000000".to_string(),
|
||||
max_sessions: 1,
|
||||
max_streams: 1,
|
||||
@@ -48,6 +49,7 @@ fn session_with_automatic(automatic: bool) -> Arc<WebSession> {
|
||||
false,
|
||||
WebLimitsConfig::default(),
|
||||
WebTimeoutsConfig::default(),
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ fn runtime(admission: bool) -> TestRuntime {
|
||||
carriers: Arc::from([WebCarrier::WebsocketLanes]),
|
||||
carrier_negotiation_deadlines_secs: [3, 5, 8, 12],
|
||||
capability: [7; 32],
|
||||
credential_id: [0; 16],
|
||||
key_fingerprint: "0000000000000000".to_string(),
|
||||
max_sessions: 2,
|
||||
max_streams: 1,
|
||||
@@ -75,6 +76,7 @@ fn runtime(admission: bool) -> TestRuntime {
|
||||
false,
|
||||
limits,
|
||||
timeouts,
|
||||
None,
|
||||
);
|
||||
TestRuntime {
|
||||
session,
|
||||
|
||||
Reference in New Issue
Block a user