postgresql

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

This package provides a Hydro pub/sub backend implementation for PostgreSQL, allowing you to add real-time capabilities to the database using its internal systems. Everything stays fully transactional.

This implementation uses GORM and libpq. If you want to use a different library for transactions, this implementation might not be for you. However, you can look at it for reference.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresPubSub

type PostgresPubSub struct {
	// contains filtered or unexported fields
}

The main backend implementation for PostgreSQL pub/sub.

func NewPostgresPubSub

func NewPostgresPubSub(connStr string) *PostgresPubSub

NewPostgresPubSub creates a new instance of PostgresPubSub with the given connection string (host=<host> port=<port> user=<user> dbname=<dbname> password=<password>).

func (*PostgresPubSub) CreateWorker

func (p *PostgresPubSub) CreateWorker() hydro.ISubWorker

func (*PostgresPubSub) Publish

func (p *PostgresPubSub) Publish(ctx context.Context, db *gorm.DB, channel string, message string) error

type PostgresWorker

type PostgresWorker struct {
	// contains filtered or unexported fields
}

PostgresWorker is the worker implementation for PostgreSQL pub/sub. It listens for notifications on the specified channels and invokes the provided callbacks when messages are received or errors occur.

func (*PostgresWorker) Close

func (w *PostgresWorker) Close()

func (*PostgresWorker) OnError

func (w *PostgresWorker) OnError(fn func(channel string, err error))

func (*PostgresWorker) OnMessage

func (w *PostgresWorker) OnMessage(fn func(channel string, message string))

func (*PostgresWorker) Subscribe

func (w *PostgresWorker) Subscribe(ctx context.Context, channels ...string) error

func (*PostgresWorker) Unsubscribe

func (w *PostgresWorker) Unsubscribe(ctx context.Context, channels ...string) error

Jump to

Keyboard shortcuts

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