Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Notifier ¶
type Notifier interface {
// Listen subscribes to notifications on the specified topic.
// It begins listening for notifications on the given topic.
// Returns an error if the subscription fails.
Listen(ctx context.Context, topic string) error
// UnListen unsubscribes from notifications on the specified topic.
// It stops listening for notifications on the given topic.
// Returns an error if the unsubscription fails.
UnListen(ctx context.Context, topic string) error
// Blocking blocks until a notification is received or the context is canceled.
// Notifications are sent to the notifierChannel, and the method returns
// an error if one occurs or the context is canceled.
Blocking(ctx context.Context) error
// NonBlocking starts a goroutine that listens for notifications in a non-blocking manner.
// It uses the Blocking method internally and sends any encountered errors to the errorChannel.
// The method returns immediately after starting the goroutine.
NonBlocking(ctx context.Context)
// Wait waits for a single notification.
// It blocks until a notification is received or an error occurs.
// Returns the notification or an error if one occurs.
Wait(ctx context.Context) (*pgconn.Notification, error)
// NotificationChannel returns a channel for receiving notifications.
// Notifications are sent to this channel by the Blocking or NonBlocking methods.
NotificationChannel() chan *pgconn.Notification
// ErrorChannel returns a channel for receiving errors.
// Errors encountered during notification handling are sent to this channel.
ErrorChannel() chan error
// StopBlocking stops the blocking operation initiated by the Blocking method.
// It signals cancellation to stop the blocking operation.
StopBlocking()
// Close closes the notifier, unsubscribing from all topics and releasing resources.
// It signals cancellation to stop any running blocking operations, closes channels,
// and releases the connection back to the pool.
// Returns an error if any issues occur during the closure process.
Close(ctx context.Context, topic string) error
}
Notifier defines the interface for handling PostgreSQL notifications.
Click to show internal directories.
Click to hide internal directories.