View Source Jido.Signal (Jido v1.0.0)

Defines the structure and behavior of a Signal in the Jido system. Implements CloudEvents specification v1.0.2 with Jido-specific extensions.

Summary

Functions

Creates a new Signal struct from a map.

Creates a new Signal struct.

Types

t()

@type t() :: %Jido.Signal{
  data: term() | nil,
  datacontenttype: String.t() | nil,
  dataschema: String.t() | nil,
  id: String.t(),
  jidoaction: [{atom(), map()}] | nil,
  jidoopts: map() | nil,
  source: String.t(),
  specversion: String.t(),
  subject: String.t() | nil,
  time: String.t() | nil,
  type: String.t()
}

Functions

from_map(map)

@spec from_map(map()) :: {:ok, t()} | {:error, String.t()}

Creates a new Signal struct from a map.

Parameters

  • map: A map containing the Signal attributes.

Returns

{:ok, Signal.t()} if the map is valid, {:error, String.t()} otherwise.

Examples

iex> Jido.Signal.from_map(%{"type" => "example.event", "source" => "/example", "id" => "123"})
{:ok, %Jido.Signal{type: "example.event", source: "/example", id: "123", ...}}

new(attrs)

@spec new(map()) :: {:ok, t()} | {:error, String.t()}

Creates a new Signal struct.

Parameters

  • attrs: A map containing the Signal attributes.

Returns

{:ok, Signal.t()} if the attributes are valid, {:error, String.t()} otherwise.

Examples

iex> Jido.Signal.new(%{type: "example.event", source: "/example", id: "123"})
{:ok, %Jido.Signal{type: "example.event", source: "/example", id: "123", ...}}