-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
src/app/janus.rs
Outdated
@@ -34,6 +37,135 @@ use crate::util::{from_base64, generate_correlation_data, to_base64}; | |||
|
|||
const STREAM_UPLOAD_METHOD: &str = "stream.upload"; | |||
|
|||
lazy_static! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move these parameters to the app configuration. [backend]
section for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[backend]
section would also be a nice place for backend_id
, meaning
[backend]
id = "janus-gateway.svc.example.org"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/backend
would probably be a better place for this entire file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also refactored it into smaller modules.
e7c7129
to
123df01
Compare
src/app/context.rs
Outdated
@@ -67,6 +76,7 @@ pub(crate) trait Context: Sync { | |||
fn config(&self) -> &Config; | |||
fn db(&self) -> &Db; | |||
fn agent_id(&self) -> &AgentId; | |||
fn janus_client(&self) -> &Arc<JanusClient>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why return pointer to arc?
payload.handle_id.janus_handle_id(), | ||
payload.handle_id.rtc_id(), | ||
payload.jsep.clone(), | ||
payload.handle_id.backend_id(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok to pass 4 args coming from payload.handle_id
instead of just payload.handle_id
itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not OK. There's a lot of room for refactoring. I've just moved code as is for now.
authz_time, | ||
) | ||
.map(|req| Box::new(req) as Box<dyn IntoPublishableMessage + Send>) | ||
.map_err(|err| format!("error creating a backend request: {}", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{:?}
here
authz_time, | ||
) | ||
.map(|req| Box::new(req) as Box<dyn IntoPublishableMessage + Send>) | ||
.map_err(|err| format!("error creating a backend request: {}", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{:?}
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about error. There's another task for improving them.
backend.id(), | ||
start_timestamp, | ||
) | ||
.map_err(|err| format!("error creating a backend request: {}", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{:?}
.build(); | ||
|
||
sentry::send(svc_error).unwrap_or_else(|err| { | ||
warn!("Error sending error to Sentry: {}", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{:?}
reqp.correlation_data().to_owned(), | ||
request_info, | ||
)) | ||
.unwrap_or_else(|err| error!("Failed to register janus client transaction: {}", err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{:?}
|
||
self.transaction_watchdog_tx | ||
.send(TransactionWatchdogMessage::Remove(corr_data)) | ||
.unwrap_or_else(|err| error!("Failed to remove janus client transaction: {}", err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{:?}
let period = StdDuration::from_secs(config.transaction_watchdog_check_period); | ||
let (tx, rx) = crossbeam_channel::unbounded(); | ||
|
||
thread::spawn(move || { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets give this thread a name
https://doc.rust-lang.org/std/thread/struct.Builder.html#method.name
123df01
to
c69b6e6
Compare
No description provided.