Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ ws = [
"dep:hyper",
"dep:hyper-util",
"dep:http-body-util",
"dep:httpdate",
"dep:webpki-roots",
# "dep:",
]
database = [
Expand Down Expand Up @@ -77,7 +79,7 @@ log_throttling = ["dep:tracing-throttle"]

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_json = { version = "1.0", features = ["raw_value"] }
eyre = "0.6"
convert_case = "0.6"
itertools = "0.12"
Expand Down Expand Up @@ -127,10 +129,12 @@ regex = { version = "1.5", optional = true }
rev_lines = { version = "0.3", optional = true }
lazy_static = { version = "1.5", optional = true }
async-trait = { version = "0.1", optional = true }
hyper = { version = "1", features = ["http1", "server"], optional = true }
hyper-util = { version = "0.1", features = ["tokio"], optional = true }
hyper = { version = "1", features = ["http1", "http2", "server", "client"], optional = true }
hyper-util = { version = "0.1", features = ["tokio", "server-auto"], optional = true }
http-body-util = { version = "0.1", optional = true }
httpdate = { version = "1.0", optional = true }
tracing-throttle = { version = "0.4", features = ["async"], optional = true }
webpki-roots = { version = "0.26", optional = true }

# OpenTelemetry dependencies (default feature)
opentelemetry = { version = "0.31", features = ["logs"] }
Expand Down
14 changes: 8 additions & 6 deletions src/libs/ws/basics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use parking_lot::RwLock;
use serde::*;
use serde_json::Value;
use serde_json::value::RawValue;
use std::collections::HashSet;
use std::fmt::Debug;
use std::net::SocketAddr;
use std::sync::Arc;
Expand Down Expand Up @@ -43,9 +45,8 @@ impl WsConnection {
self.user_id.load(std::sync::atomic::Ordering::Acquire)
}

pub fn get_roles(&self) -> Vec<u32> {
let roles = self.roles.read();
roles.as_ref().clone()
pub fn get_roles(&self) -> Arc<Vec<u32>> {
self.roles.read().clone()
}

pub fn set_user_id(&self, user_id: u64) {
Expand All @@ -59,8 +60,8 @@ impl WsConnection {
}
}

pub type WsSuccessResponse = WsSuccessResponseGeneric<Value>;
pub type WsStreamResponse = WsStreamResponseGeneric<Value>;
pub type WsSuccessResponse = WsSuccessResponseGeneric<Box<RawValue>>;
pub type WsStreamResponse = WsStreamResponseGeneric<Box<RawValue>>;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct WsForwardedResponse {
Expand Down Expand Up @@ -101,11 +102,12 @@ pub enum WsResponseGeneric<Resp> {
Close,
}

pub type WsResponseValue = WsResponseGeneric<Value>;
pub type WsResponseValue = WsResponseGeneric<Box<RawValue>>;

pub struct WsEndpoint {
pub schema: EndpointSchema,
pub handler: Arc<dyn RequestHandlerErased>,
pub allowed_roles: HashSet<u32>,
}

pub fn internal_error_to_resp(
Expand Down
Loading