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 channel for cancelling listening
Canceller <-chan struct{}
}
Options for calling Listen()
Click to show internal directories.
Click to hide internal directories.