Loading...
Searching...
No Matches
ATAS.DataFeedsCore.ConnectorWebsocket.SnapshotMessageThrottle Class Reference

Drops snapshot-type websocket messages that arrive for the same key more often than Period. The first message for a key and every message received after the period has elapsed pass through, so the consumer always sees a fresh full snapshot and nothing is lost for channels where every message carries the complete state (exchange tickers pushed by a timer). Must not be used for delta channels (order book updates, delta tickers), where every message matters. More...

Public Member Functions

delegate bool KeySelector (ReadOnlySpan< byte > message, out ReadOnlySpan< byte > key)
 Extracts the throttling key (usually the instrument id) from a raw message. Returns false for messages that must never be throttled.
 
 SnapshotMessageThrottle (KeySelector keySelector, Func< TimeSpan > periodProvider, TimeProvider? timeProvider=null)
 
bool Accept (ReadOnlyMemory< byte > message)
 Returns true if the message should be processed, false if it is a redundant snapshot.
 

Properties

TimeSpan Period [get]
 Current period. TimeSpan.Zero or negative disables throttling.
 
long Accepted [get]
 
long Dropped [get]
 

Detailed Description

Drops snapshot-type websocket messages that arrive for the same key more often than Period. The first message for a key and every message received after the period has elapsed pass through, so the consumer always sees a fresh full snapshot and nothing is lost for channels where every message carries the complete state (exchange tickers pushed by a timer). Must not be used for delta channels (order book updates, delta tickers), where every message matters.

Not thread-safe by design: one instance serves one websocket whose read loop delivers messages sequentially.

Constructor & Destructor Documentation

◆ SnapshotMessageThrottle()

ATAS.DataFeedsCore.ConnectorWebsocket.SnapshotMessageThrottle.SnapshotMessageThrottle ( KeySelector  keySelector,
Func< TimeSpan >  periodProvider,
TimeProvider?  timeProvider = null 
)
Parameters
keySelectorExtracts the key from a raw message; messages without a key always pass.
periodProviderRead on every message so the period can come from connector settings that are applied after the socket is created.
timeProviderClock override for tests.

Member Function Documentation

◆ Accept()

bool ATAS.DataFeedsCore.ConnectorWebsocket.SnapshotMessageThrottle.Accept ( ReadOnlyMemory< byte >  message)

Returns true if the message should be processed, false if it is a redundant snapshot.

◆ KeySelector()

delegate bool ATAS.DataFeedsCore.ConnectorWebsocket.SnapshotMessageThrottle.KeySelector ( ReadOnlySpan< byte >  message,
out ReadOnlySpan< byte >  key 
)

Extracts the throttling key (usually the instrument id) from a raw message. Returns false for messages that must never be throttled.

Property Documentation

◆ Accepted

long ATAS.DataFeedsCore.ConnectorWebsocket.SnapshotMessageThrottle.Accepted
get

◆ Dropped

long ATAS.DataFeedsCore.ConnectorWebsocket.SnapshotMessageThrottle.Dropped
get

◆ Period

TimeSpan ATAS.DataFeedsCore.ConnectorWebsocket.SnapshotMessageThrottle.Period
get

Current period. TimeSpan.Zero or negative disables throttling.


The documentation for this class was generated from the following file: