Bourse.WS.MessageRouter (bourse v0.1.0)

Copy Markdown View Source

Routes decoded WS frames to payload families using envelope extraction.

Channel → family resolution reads websocket.dispatch via Bourse.WS.Dispatch.

Summary

Functions

Extracts the channel name using the envelope's discriminator_field.

Extracts payload data using the envelope's data_field.

Extracts a market id segment from a dot-delimited channel string.

Resolves a dot-notation path in a nested map.

Routes a decoded WS message for an exchange.

Routes a decoded WS message using an explicit envelope config.

Types

route_result()

@type route_result() ::
  {:routed, atom(), term(), String.t()} | {:system, map()} | {:unknown, map()}

Functions

extract_channel(raw_msg, envelope)

@spec extract_channel(map(), map()) :: String.t() | nil

Extracts the channel name using the envelope's discriminator_field.

extract_data(raw_msg, envelope)

@spec extract_data(map(), map()) :: term()

Extracts payload data using the envelope's data_field.

extract_market_id(channel)

@spec extract_market_id(String.t() | nil) :: String.t() | nil

Extracts a market id segment from a dot-delimited channel string.

get_nested(map, path)

@spec get_nested(map(), String.t() | nil) :: term()

Resolves a dot-notation path in a nested map.

route(raw_msg, exchange)

@spec route(map(), Bourse.Exchange.t()) :: route_result()

Routes a decoded WS message for an exchange.

route(raw_msg, envelope, exchange)

@spec route(map(), map() | nil, Bourse.Exchange.t()) :: route_result()

Routes a decoded WS message using an explicit envelope config.