-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathcontext.rs
More file actions
50 lines (45 loc) · 1.76 KB
/
context.rs
File metadata and controls
50 lines (45 loc) · 1.76 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
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::Mutex as StdMutex;
use std::sync::atomic::{AtomicBool, AtomicI64};
use crate::async_counter::AsyncCounter;
use rivet_envoy_protocol as protocol;
use tokio::sync::Mutex;
use tokio::sync::Notify;
use tokio::sync::mpsc;
use tokio::sync::watch;
use crate::actor::ToActor;
use crate::config::EnvoyConfig;
use crate::envoy::ToEnvoyMessage;
use crate::tunnel::HibernatingWebSocketMetadata;
pub struct SharedActorEntry {
pub handle: mpsc::UnboundedSender<ToActor>,
pub active_http_request_count: Arc<AsyncCounter>,
}
pub struct SharedContext {
pub config: EnvoyConfig,
pub envoy_key: String,
pub envoy_tx: mpsc::UnboundedSender<ToEnvoyMessage>,
pub actors: Arc<StdMutex<HashMap<String, HashMap<u32, SharedActorEntry>>>>,
pub actors_notify: Arc<Notify>,
pub live_tunnel_requests: Arc<StdMutex<HashMap<[u8; 8], String>>>,
pub pending_hibernation_restores:
Arc<StdMutex<HashMap<String, Vec<HibernatingWebSocketMetadata>>>>,
pub ws_tx: Arc<Mutex<Option<mpsc::UnboundedSender<WsTxMessage>>>>,
pub protocol_metadata: Arc<Mutex<Option<protocol::ProtocolMetadata>>>,
pub shutting_down: AtomicBool,
/// Epoch ms timestamp of the most recent ping packet received from the engine. Used by
/// `EnvoyHandle::is_ping_healthy` to surface a dead engine link to upstream health checks.
/// Zero means no ping has been received yet.
pub last_ping_ts: AtomicI64,
// Latched signal fired by `envoy_loop` after its cleanup block completes.
// Waiters observing `true` are guaranteed that the loop has exited and
// every pending KV/SQLite request has been resolved (with `EnvoyShutdownError`
// if it didn't complete naturally).
pub stopped_tx: watch::Sender<bool>,
}
#[derive(Debug)]
pub enum WsTxMessage {
Send(Vec<u8>),
Close,
}