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 ¶
- type PostgresPubSub
- type PostgresWorker
- func (w *PostgresWorker) Close()
- func (w *PostgresWorker) OnError(fn func(channel string, err error))
- func (w *PostgresWorker) OnMessage(fn func(channel string, message string))
- func (w *PostgresWorker) Subscribe(ctx context.Context, channels ...string) error
- func (w *PostgresWorker) Unsubscribe(ctx context.Context, channels ...string) error
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
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