pub struct FeedHandler { /* private fields */ }Expand description
Processes incoming WebSocket messages and converts them to Nautilus domain objects.
The handler owns the WebSocketClient exclusively within the lock-free I/O boundary, eliminating RwLock contention on the hot path.
Implementations§
Source§impl FeedHandler
impl FeedHandler
Sourcepub fn new(
account_id: Option<AccountId>,
cmd_rx: UnboundedReceiver<HandlerCommand>,
out_tx: UnboundedSender<NautilusWsMessage>,
raw_rx: UnboundedReceiver<Message>,
client: WebSocketClient,
signal: Arc<AtomicBool>,
subscriptions: SubscriptionState,
bars_timestamp_on_close: bool,
) -> Self
pub fn new( account_id: Option<AccountId>, cmd_rx: UnboundedReceiver<HandlerCommand>, out_tx: UnboundedSender<NautilusWsMessage>, raw_rx: UnboundedReceiver<Message>, client: WebSocketClient, signal: Arc<AtomicBool>, subscriptions: SubscriptionState, bars_timestamp_on_close: bool, ) -> Self
Creates a new FeedHandler.
Sourcepub async fn run(&mut self)
pub async fn run(&mut self)
Main processing loop for the handler.
§Panics
This method will not panic. The expect call on iter.next() is safe
because we explicitly check that nautilus_msgs is not empty before
calling it.
Sourcepub fn register_bar_type(&mut self, topic: String, bar_type: BarType)
pub fn register_bar_type(&mut self, topic: String, bar_type: BarType)
Registers a bar type for a specific topic (e.g., “BTC-USD/1MIN”).
Sourcepub fn unregister_bar_type(&mut self, topic: &str)
pub fn unregister_bar_type(&mut self, topic: &str)
Unregisters a bar type for a specific topic.
Sourcepub async fn handle_message(
&mut self,
msg: DydxWsMessage,
) -> DydxWsResult<Vec<NautilusWsMessage>>
pub async fn handle_message( &mut self, msg: DydxWsMessage, ) -> DydxWsResult<Vec<NautilusWsMessage>>
Handles control messages from the fallback parsing path.
Channel data is handled directly via handle_feed_message().
§Errors
Returns an error if the message cannot be processed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FeedHandler
impl !RefUnwindSafe for FeedHandler
impl Send for FeedHandler
impl Sync for FeedHandler
impl Unpin for FeedHandler
impl UnsafeUnpin for FeedHandler
impl !UnwindSafe for FeedHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].