Skip to content

Commit

Permalink
feat: arisu unsub
Browse files Browse the repository at this point in the history
  • Loading branch information
pxseu committed Oct 2, 2023
1 parent 18f9f14 commit 43fc370
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/utils/arisu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ impl ArisuClient {
}

#[allow(dead_code)]
pub async fn unsubscribe_logs(&self) -> Result<()> {
if !self.logs_requested.load(Relaxed) {
return Ok(());
}

self.tx.send(json!({
"op": OpCode::UnsubscribeLogs,
}))?;

while self.logs_requested.load(Relaxed) {
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
}

Ok(())
}

pub async fn request_metrics(&self) -> Result<()> {
if self.metrics_requested.load(Relaxed) {
return Ok(());
Expand All @@ -90,6 +106,23 @@ impl ArisuClient {

Ok(())
}

#[allow(dead_code)]
pub async fn unsubscribe_metrics(&self) -> Result<()> {
if !self.metrics_requested.load(Relaxed) {
return Ok(());
}

self.tx.send(json!({
"op": OpCode::UnsubscribeMetrics,
}))?;

while self.metrics_requested.load(Relaxed) {
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
}

Ok(())
}
}

impl Stream for ArisuClient {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/arisu/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub enum OpCode {
Metrics,
RequestLogs,
RequestLogsAck,
UnsubscribeLogs,
UnsubscribeMetrics,
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down

0 comments on commit 43fc370

Please sign in to comment.