Chronicle.EventSources.Routing (cratis_chronicle v3.16.1)

Copy Markdown View Source

The routing of an append that has been resolved from an event source definition.

Resolution errors are returned as tuples so appends never send a partial request:

  • {:unknown_event_source, reference}
  • {:event_stream_does_not_belong_to_event_source, source, stream}
  • {:event_routing_contradicts_event_source, source, dimension, expected, actual}

Summary

Functions

The concurrency dimensions that apply to the append.

The event source name recorded as the EventSource metadata of the event.

Resolves an event source (module or name) and optional stream name against the registered event source modules.

The event source type to write on the event.

The event stream type to write on the event.

Types

t()

@type t() :: %Chronicle.EventSources.Routing{
  definition: Chronicle.EventSources.EventSourceDefinition.t(),
  stream: Chronicle.EventSources.EventStream.t() | nil
}

Functions

dimensions(routing)

The concurrency dimensions that apply to the append.

event_source(routing)

@spec event_source(t()) :: String.t()

The event source name recorded as the EventSource metadata of the event.

resolve(registered, reference, stream, explicit_source_type, explicit_stream_type)

@spec resolve(
  [module()],
  module() | String.t(),
  String.t() | nil,
  String.t() | nil,
  String.t() | nil
) ::
  {:ok, t()} | {:error, term()}

Resolves an event source (module or name) and optional stream name against the registered event source modules.

Explicit source type / stream type values that contradict the definition are rejected; empty, "Default" (source type) and "All" (stream type) values mean "not specified".

source_type(routing)

@spec source_type(t()) :: String.t()

The event source type to write on the event.

stream_type(routing)

@spec stream_type(t()) :: String.t()

The event stream type to write on the event.