LemonChannels.PresentationState (lemon_channels v0.1.0)

View Source

Tracks channel presentation state per {route, run, surface}.

State is owned by :lemon_channels so router processes can stay semantic and avoid platform-specific message-id bookkeeping.

Summary

Types

entry()

@type entry() :: %{
  route: LemonCore.DeliveryRoute.t(),
  run_id: binary(),
  surface: surface(),
  platform_message_id: integer() | binary() | nil,
  pending_create_ref: reference() | nil,
  pending_create_at: integer() | nil,
  pending_edit_ref: reference() | nil,
  pending_edit_at: integer() | nil,
  last_seq: non_neg_integer(),
  last_text_hash: integer() | nil,
  deferred_text: binary() | nil,
  deferred_chunks: [binary()] | nil,
  pending_followup_chunks: [binary()] | nil,
  deferred_seq: non_neg_integer() | nil,
  deferred_hash: integer() | nil,
  deferred_meta: map(),
  pending_followup_meta: map(),
  pending_resume: term() | nil
}

surface()

@type surface() :: term()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear(route, run_id, surface)

@spec clear(LemonCore.DeliveryRoute.t(), binary(), surface()) :: :ok

defer_chunks(route, run_id, surface, chunks, seq, text_hash, deferred_meta \\ %{})

@spec defer_chunks(
  LemonCore.DeliveryRoute.t(),
  binary(),
  surface(),
  [binary()],
  non_neg_integer(),
  integer() | nil,
  map()
) :: :ok

defer_text(route, run_id, surface, text, seq, text_hash, deferred_meta \\ %{})

@spec defer_text(
  LemonCore.DeliveryRoute.t(),
  binary(),
  surface(),
  binary(),
  non_neg_integer(),
  integer() | nil,
  map()
) :: :ok

get(route, run_id, surface)

@spec get(LemonCore.DeliveryRoute.t(), binary(), surface()) :: entry()

mark_sent(route, run_id, surface, seq, text_hash, message_id \\ nil)

@spec mark_sent(
  LemonCore.DeliveryRoute.t(),
  binary(),
  surface(),
  non_neg_integer(),
  integer() | nil,
  integer() | binary() | nil
) :: :ok

move(route, run_id, from_surface, to_surface)

@spec move(LemonCore.DeliveryRoute.t(), binary(), surface(), surface()) :: :ok

notify_tag()

@spec notify_tag() :: atom()

register_pending_create(route, run_id, surface, ref, seq, text_hash, pending_resume \\ nil)

@spec register_pending_create(
  LemonCore.DeliveryRoute.t(),
  binary(),
  surface(),
  reference(),
  non_neg_integer(),
  integer() | nil,
  term() | nil
) :: :ok

register_pending_edit(route, run_id, surface, ref, seq, text_hash, message_id)

@spec register_pending_edit(
  LemonCore.DeliveryRoute.t(),
  binary(),
  surface(),
  reference(),
  non_neg_integer(),
  integer() | nil,
  integer() | binary() | nil
) :: :ok

reserve_pending_create(route, run_id, surface, seq, text_hash, pending_resume \\ nil)

@spec reserve_pending_create(
  LemonCore.DeliveryRoute.t(),
  binary(),
  surface(),
  non_neg_integer(),
  integer() | nil,
  term() | nil
) :: {:reserved, reference()} | {:duplicate, entry()} | {:existing, entry()}

stage_followups(route, run_id, surface, chunks, followup_meta \\ %{})

@spec stage_followups(
  LemonCore.DeliveryRoute.t(),
  binary(),
  surface(),
  [binary()],
  map()
) :: :ok

start_link(opts \\ [])