Mesh.Request (Mesh v0.1.4)

View Source

Request structure for invoking processes in Mesh.

Fields

  • :module - The GenServer module to invoke (required)
  • :id - The actor ID that identifies this specific process instance (required)
  • :payload - The payload to send to the process (required)
  • :capability - The capability that determines routing (required)
  • :init_arg - Optional argument passed to the process's start_link/2 on creation

Examples

# Simple request
%Mesh.Request{
  module: MyApp.Counter,
  id: "counter_1",
  payload: %{action: :increment},
  capability: :counter
}

# With custom initialization argument
%Mesh.Request{
  module: MyApp.GameActor,
  id: "player_123",
  payload: %{action: :get_state},
  capability: :game,
  init_arg: %{starting_level: 5}
}

Summary

Types

t()

@type t() :: %Mesh.Request{
  capability: atom(),
  id: String.t(),
  init_arg: any(),
  module: module(),
  payload: any()
}

Functions

new(module, id, payload, capability, opts \\ [])

Creates a new Request struct.

Examples

iex> Mesh.Request.new(MyApp.Counter, "counter_1", %{action: :increment}, :counter)
%Mesh.Request{module: MyApp.Counter, id: "counter_1", payload: %{action: :increment}, capability: :counter}

iex> Mesh.Request.new(MyApp.GameActor, "player_1", %{}, :game, init_arg: %{level: 10})
%Mesh.Request{module: MyApp.GameActor, id: "player_1", payload: %{}, capability: :game, init_arg: %{level: 10}}