supabase

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger hclog.Logger

Functions

This section is empty.

Types

type Dialer

type Dialer interface {
	Dial(url string) (WebSocketConn, error)
}

Dialer abstracts WebSocket dialing for testability.

type ListenHandler

type ListenHandler struct {
	Name        string
	Topic       string
	ChannelType RealtimeChannelType
	Table       string
	Schema      string
	EventFilter string
	ConsumeFn   func(ctx context.Context, event string, payload json.RawMessage) error
}

ListenHandler describes a subscription for the provider.

type PhoenixMessage

type PhoenixMessage struct {
	Topic   string          `json:"topic"`
	Event   string          `json:"event"`
	Payload json.RawMessage `json:"payload"`
	Ref     string          `json:"ref,omitempty"`
	JoinRef string          `json:"join_ref,omitempty"`
}

PhoenixMessage is the Phoenix Channels v1 protocol message format.

type Provider

type Provider struct {
	Config *ProviderConfig
	Dialer Dialer
	// contains filtered or unexported fields
}

Provider implements the Supabase Realtime PubSub provider.

func (*Provider) CreateSubscription

func (p *Provider) CreateSubscription(name, topic string) error

CreateSubscription is a no-op for Supabase Realtime (channels are joined on StartListen).

func (*Provider) Publish

func (p *Provider) Publish(ctx context.Context, topic string, message []byte) error

Publish sends a broadcast message to the specified topic.

func (*Provider) StartListen

func (p *Provider) StartListen(handlers []ListenHandler) error

StartListen connects to Supabase Realtime, joins channels, and dispatches messages.

func (*Provider) StopListen

func (p *Provider) StopListen() error

StopListen closes the WebSocket connection and stops all listeners.

type ProviderConfig

type ProviderConfig struct {
	SupabasePublicUrl string
	SupabaseApiUrl    string
	AnonKey           string
	ServiceKey        string
	ProjectId         string
}

ProviderConfig holds Supabase connection settings (no raiden imports).

type RealtimeChannelType

type RealtimeChannelType string

RealtimeChannelType mirrors raiden.RealtimeChannelType without importing root.

const (
	ChannelBroadcast       RealtimeChannelType = "broadcast"
	ChannelPresence        RealtimeChannelType = "presence"
	ChannelPostgresChanges RealtimeChannelType = "postgres_changes"
)

type WebSocketConn

type WebSocketConn interface {
	WriteJSON(v any) error
	ReadJSON(v any) error
	Close() error
}

WebSocketConn abstracts the WebSocket connection for testability.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL