Jido.Messaging.OutboundRouter (Jido Messaging v1.0.0)

Copy Markdown View Source

Outbound bridge router for runtime-configurable adapter delivery.

Resolves RoomBinding + BridgeConfig + RoutingPolicy, then dispatches through Jido.Messaging.OutboundGateway.

Summary

Functions

Resolves outbound routes for a room from bindings + bridge configs.

Routes an outbound text payload for a room.

Types

delivery_failure()

@type delivery_failure() :: %{
  route: route(),
  reason: term(),
  error: Jido.Messaging.OutboundGateway.error_response() | term()
}

delivery_success()

@type delivery_success() :: %{
  route: route(),
  result: Jido.Messaging.OutboundGateway.success_response()
}

delivery_summary()

@type delivery_summary() :: %{
  room_id: String.t(),
  policy: Jido.Messaging.RoutingPolicy.t(),
  attempted: non_neg_integer(),
  delivered: [delivery_success()],
  failed: [delivery_failure()]
}

route()

@type route() :: %{
  binding_id: String.t(),
  bridge_id: String.t(),
  adapter_module: module(),
  channel: atom(),
  external_room_id: String.t()
}

Functions

resolve_routes(instance_module, room_id, opts \\ [])

@spec resolve_routes(module(), String.t(), keyword()) ::
  {:ok, [route()]} | {:error, term()}

Resolves outbound routes for a room from bindings + bridge configs.

The returned list is ordered according to routing policy fallback order.

route_outbound(instance_module, room_id, text, opts \\ [])

@spec route_outbound(module(), String.t(), String.t(), keyword()) ::
  {:ok, delivery_summary()}
  | {:error, :no_routes | {:delivery_failed, delivery_summary()} | term()}

Routes an outbound text payload for a room.

Options

  • :gateway_opts - options passed to OutboundGateway.send_message/4
  • :bridge_id - force a specific bridge id
  • :routing_policy - override stored routing policy (RoutingPolicy or map)