Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InTransaction ¶
InTransaction runs a function inside a transaction and handles commiting and rollback on error.
func Listen ¶
func Listen(opts ListenOpts) (err error)
Listen assigns a function to listen to Postgres notifications on a channel
Types ¶
type ListenOpts ¶
type ListenOpts struct {
// Prevent identical messages from triggering the handler for up to
// DebounceInterval. If 0, all messages trigger the handler.
DebounceInterval time.Duration
// URL to connect on to the database. Required.
ConnectionURL string
// Channel to listen on. Required.
Channel string
// Message handler. Required.
OnMsg func(msg string) error
// Optional error handler
OnError func(err error)
// Optional handler for database connection loss. The connection will be
// automatically reestablished regardless, but this can be used to hook
// extra logic on the library user's side of the application.
OnConnectionLoss func()
// Optional handler for reconnection after database connection loss
OnReconnect func()
// Optional context for cancelling listening
Context context.Context
}
Options for calling Listen()
Click to show internal directories.
Click to hide internal directories.