Skip to content

Commit 93500d6

Browse files
authored
use config object instead of single val (#181)
1 parent 28dd963 commit 93500d6

4 files changed

Lines changed: 11 additions & 17 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

application/xiu/src/service.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ impl Service {
7070
None
7171
} else {
7272
Some(Arc::new(HttpNotifier::new(
73-
httpnotifier.on_publish.clone(),
74-
httpnotifier.on_unpublish.clone(),
75-
httpnotifier.on_play.clone(),
76-
httpnotifier.on_stop.clone(),
77-
httpnotifier.on_hls.clone(),
73+
httpnotifier.clone(),
7874
event_producer.clone(),
7975
)))
8076
}

library/streamhub/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ serde_json = { version = "1", default-features = false, features = [
2626
"std",
2727
] }
2828
serde = { version = "1.0", features = ["derive", "rc"] }
29+
config = { path = "../../library/config/" }
2930

3031
bytesio = { path = "../../library/bytesio/" }
3132
xflv = { path = "../../library/container/flv/" }

library/streamhub/src/notify/http.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::notify::Notifier;
22
use reqwest::Client;
33
use async_trait::async_trait;
4-
use crate::define::{PublisherInfo, StreamHubEventMessage, StreamHubEventSender, StreamHubEvent};
4+
use crate::define::{StreamHubEventMessage, StreamHubEventSender, StreamHubEvent};
5+
use config::HttpNotifierConfig;
56

67
macro_rules! serialize_event {
78
($message:expr) => {{
@@ -29,21 +30,16 @@ pub struct HttpNotifier {
2930

3031
impl HttpNotifier {
3132
pub fn new(
32-
on_publish_url: Option<String>,
33-
on_unpublish_url: Option<String>,
34-
on_play_url: Option<String>,
35-
on_stop_url: Option<String>,
36-
on_hls_url: Option<String>,
33+
config: HttpNotifierConfig,
3734
event_producer: StreamHubEventSender,
38-
3935
) -> Self {
4036
Self {
4137
request_client: reqwest::Client::new(),
42-
on_publish_url,
43-
on_unpublish_url,
44-
on_play_url,
45-
on_stop_url,
46-
on_hls_url,
38+
on_publish_url: config.on_publish,
39+
on_unpublish_url: config.on_unpublish,
40+
on_play_url: config.on_play,
41+
on_stop_url: config.on_stop,
42+
on_hls_url: config.on_hls,
4743
event_producer,
4844
}
4945
}

0 commit comments

Comments
 (0)