Supabase.Realtime.Channel.Store (supabase_realtime v0.5.0)

Copy Markdown

ETS-based storage for Realtime channels.

This module provides a centralized store for channel data that can be accessed by both the Connection and Registry modules, eliminating the need for manual state management in each component.

Summary

Functions

Adds a pending acknowledgment to a channel.

Returns all channels in the store.

Returns a specification to start this module under a supervisor.

Finds all channels with a matching topic.

Finds a channel by its join reference.

Finds a channel by its reference.

Finds a channel by its topic.

Handles when an acknowledgment is received from the server.

Handles when an acknowledgment times out.

Inserts a new channel into the store.

Removes a channel from the store.

Starts the channel store.

Updates an existing channel in the store.

Updates the join reference of a channel.

Updates the state of a channel.

Functions

add_binding(store \\ __MODULE__, channel, type, filter, callback \\ nil)

Adds a binding to a channel.

Parameters

  • store - The store process
  • channel - The channel to update
  • type - The binding type
  • filter - The binding filter
  • callback - Optional callback function

add_pending_ack(store \\ __MODULE__, channel, ack_ref, caller)

Adds a pending acknowledgment to a channel.

Parameters

  • store - The store process
  • channel - The channel to update
  • ack_ref - The acknowledgment reference
  • caller - The process that will receive the acknowledgment

all(store \\ __MODULE__)

Returns all channels in the store.

Parameters

  • store - The store process

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

find_all_by_topic(store \\ __MODULE__, topic)

Finds all channels with a matching topic.

Parameters

  • store - The store process
  • topic - The topic to match

find_by_join_ref(store \\ __MODULE__, join_ref)

Finds a channel by its join reference.

Parameters

  • store - The store process
  • join_ref - The join reference

find_by_ref(store \\ __MODULE__, ref)

Finds a channel by its reference.

Parameters

  • store - The store process
  • ref - The channel reference

find_by_topic(store \\ __MODULE__, topic)

Finds a channel by its topic.

Parameters

  • store - The store process
  • topic - The channel topic

handle_ack_received(store \\ __MODULE__, ack_ref)

Handles when an acknowledgment is received from the server.

Parameters

  • store - The store process
  • ack_ref - The acknowledgment reference

handle_ack_timeout(store \\ __MODULE__, ack_ref)

Handles when an acknowledgment times out.

Parameters

  • store - The store process
  • ack_ref - The acknowledgment reference

insert(store \\ __MODULE__, channel)

Inserts a new channel into the store.

Parameters

  • store - The store process
  • channel - The channel to insert

remove(store \\ __MODULE__, channel)

Removes a channel from the store.

Parameters

  • store - The store process
  • channel - The channel to remove

remove_binding(store \\ __MODULE__, channel, type, filter)

Removes a binding from a channel.

Parameters

  • store - The store process
  • channel - The channel to update
  • type - The binding type
  • filter - The binding filter

start_link(opts \\ [])

Starts the channel store.

Options

  • :name - Optional registration name

update(store \\ __MODULE__, channel)

Updates an existing channel in the store.

Parameters

  • store - The store process
  • channel - The updated channel data

update_join_ref(store \\ __MODULE__, channel, join_ref)

Updates the join reference of a channel.

Parameters

  • store - The store process
  • channel - The channel to update
  • join_ref - The new join reference

update_state(store \\ __MODULE__, channel, state)

Updates the state of a channel.

Parameters

  • store - The store process
  • channel - The channel to update
  • state - The new channel state