Object.MessageRouter (object v0.1.2)

High-performance message routing service using GenStage for backpressure. Handles message delivery between objects with priority queuing and load balancing.

Summary

Functions

Gets active dyads from router state.

Gets objects from router state.

Gets performance statistics for the message router.

Creates a new message router for the given objects and dyads.

Processes a batch of messages through the router.

Routes a message through the system with priority queuing.

Starts the message router GenStage producer.

Updates the router topology with new dyads.

Functions

get_active_dyads(router_state)

Gets active dyads from router state.

get_objects(router_state)

Gets objects from router state.

get_routing_stats()

Gets performance statistics for the message router.

Returns

Map with pending messages, delivery rate, success/failure counts

new(objects, initial_dyads \\ %{})

Creates a new message router for the given objects and dyads.

Parameters

  • objects: List of objects to route messages between
  • initial_dyads: Initial dyad connections

Returns

Router state with initialized routing state

process_message_batch(router_state, message_batch)

Processes a batch of messages through the router.

Parameters

  • router_state: Current router state
  • message_batch: List of messages to process

Returns

{updated_router_state, batch_results} where batch_results contains delivery statistics

route_message(message)

Routes a message through the system with priority queuing.

Parameters

  • message: Message struct with routing information

Returns

:ok - message is queued for delivery

Examples

iex> message = %{id: "msg1", from: "obj1", to: "obj2", ...}
iex> Object.MessageRouter.route_message(message)
:ok

start_link(_)

Starts the message router GenStage producer.

Returns

{:ok, pid} on successful startup

update_topology(router_state, new_dyads)

Updates the router topology with new dyads.