Skip to content

Commit

Permalink
tweak public interface
Browse files Browse the repository at this point in the history
  • Loading branch information
CAGS295 committed Sep 22, 2024
1 parent 157d1b9 commit 41c0c22
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/connectors/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::providers::Endpoints;
use std::{fmt::Debug, future::Future};
pub(crate) use tokio_tungstenite::tungstenite::protocol::Message;

pub(crate) trait EventHandler<Monitorable> {
pub trait EventHandler<Monitorable> {
type Error: Debug;
type Context;
type Update;
Expand Down
5 changes: 4 additions & 1 deletion src/monitor/depth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ impl super::Monitor for DepthConfig {
>(
provider,
tx,
self.symbols.iter().map(|s| s.to_uppercase()).collect(),
self.symbols
.iter()
.map(|s| s.to_uppercase())
.collect::<Vec<_>>(),
)
.await
})
Expand Down
2 changes: 1 addition & 1 deletion src/monitor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod depth;
mod order_book;
pub mod order_book;

use clap::{Subcommand, ValueEnum};
pub use depth::{Depth, DepthConfig, DepthHandler, DepthUpdate};
Expand Down
2 changes: 1 addition & 1 deletion src/net/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub(crate) mod streaming;
pub(crate) mod ws_adapter;

pub use streaming::Message;
pub use streaming::{Message, MultiSymbolStream};
10 changes: 5 additions & 5 deletions src/net/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ use tokio_tungstenite::WebSocketStream;
use tracing::debug;
use tracing::{error, info};

pub(crate) struct MultiSymbolStream;
pub struct MultiSymbolStream;

impl MultiSymbolStream {
pub(crate) async fn stream<Monitorable, Handle, P, Context>(
pub async fn stream<Monitorable, Handle, P, Context>(
provider: P,
context: Context,
symbols: Vec<String>,
symbols: impl AsRef<[String]>,
) where
P: Endpoints<Monitorable> + Sync + Clone + 'static,
Context: Sync + Clone + 'static,
Handle: EventHandler<Monitorable, Context = Context> + 'static,
{
let ctrl_c = Terminate::new();

let mut stream = Self::subscribe(&provider, &symbols).await;
let mut stream = Self::subscribe(&provider, symbols.as_ref()).await;

let mut handler =
MonitorMultiplexor::<Handle, Monitorable>::build(provider, &symbols, context)
MonitorMultiplexor::<Handle, Monitorable>::build(provider, symbols.as_ref(), context)
.await
.unwrap();

Expand Down

0 comments on commit 41c0c22

Please sign in to comment.