pg

package
v1.0.1139 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DBReconnectMaxDuration         = time.Minute * 5
	DBReconnectBackoffBaseDuration = time.Second
)

Functions

func Listen

func Listen(ctx context.Context, channel string, listener chan<- string) error

Listen listens to PostgreSQL notifications on the specified channel. It acquires a dedicated connection.

The function blocks until the context is cancelled or an error occurs. On connection failure, it will automatically reconnect with exponential backoff.

func ListenMany added in v1.0.1081

func ListenMany(ctx context.Context, listeners ...ChannelListener) error

ListenMany listens to PostgreSQL notifications on the specified channels. It acquires a dedicated connection.

Multiple channels can be listened to and multiple listeners can be registered for the same channel - notifications will be sent to all receivers for that channel.

The function blocks until the context is cancelled or an error occurs.

func NewNotifyRouter

func NewNotifyRouter() *notifyRouter

Types

type ChannelListener added in v1.0.1081

type ChannelListener struct {
	Channel  string
	Receiver chan<- string
}

ChannelListener represents a listener for a PostgreSQL notification channel.

Jump to

Keyboard shortcuts

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