supabase_realtime

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ACCESS_TOKEN_EVENT = "access_token"
View Source
const BROADCAST_EVENT = "broadcast"

Broadcast Events

View Source
const HEARTBEAT_EVENT = "heartbeat"
View Source
const JOIN_EVENT = "phx_join"

Channel Events

View Source
const POSTGRES_CHANGE_EVENT = "postgres_changes"

DB Subscription Events

View Source
const PRESENCE_DIFF_EVENT = "presence_diff"
View Source
const PRESENCE_STATE_EVENT = "presence_state"

Presence Events

View Source
const REPLY_EVENT = "phx_reply"
View Source
const SYS_EVENT = "system"

Other Events

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Url     string // WebSocket URL
	RestUrl string // REST API URL
	ApiKey  string
	// contains filtered or unexported fields
}

Client is the Supabase Realtime WebSocket client

func CreateRealtimeClient

func CreateRealtimeClient(apiKey string, logger *zap.Logger, opts ...string) *Client

CreateRealtimeClient initializes a new Client Supports either projectRef or separate host/port/database/user/password params

func (*Client) Connect

func (client *Client) Connect() error

Connect establishes a WebSocket connection

func (*Client) Disconnect

func (client *Client) Disconnect() error

Disconnect gracefully closes the WebSocket connection

func (*Client) IsClientAlive

func (client *Client) IsClientAlive() bool

isClientAlive checks if client is connected and healthy

func (*Client) IsConnected

func (client *Client) IsConnected() bool

IsConnected checks if the client is connected

func (*Client) ListenToPostgresChanges

func (client *Client) ListenToPostgresChanges(opts PostgresChangesOptions, handler func(map[string]any)) error

ListenToPostgresChanges subscribes to changes on a table

func (*Client) QueryTable

func (c *Client) QueryTable(table string, dest any, filters map[string]any) (int, error)

QueryTable performs a filtered REST query

type ConnectionMsg

type ConnectionMsg struct {
	TemplateMsg

	Payload struct {
		Data struct {
			Schema     string            `json:"schema"`
			Table      string            `json:"table"`
			CommitTime string            `json:"commit_timestamp"`
			EventType  string            `json:"eventType"`
			New        map[string]string `json:"new"`
			Old        map[string]string `json:"old"`
			Errors     string            `json:"errors"`
		} `json:"data"`
	} `json:"payload"`
}

type HearbeatMsg

type HearbeatMsg struct {
	TemplateMsg

	Payload struct {
	} `json:"payload"`
}

type PostgresChangesOptions

type PostgresChangesOptions struct {
	Schema string
	Table  string
	Filter string
}

Postgres subscription support

type TemplateMsg

type TemplateMsg struct {
	Event string `json:"event"`
	Topic string `json:"topic"`
	Ref   string `json:"ref"`
}

Jump to

Keyboard shortcuts

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