callbackqueue
v9.24.1
github.com/redis/go-redis/v9/internal/callbackqueue
Documentation
pkg.go.dev ↗Functions
RunSafely
func RunSafely(fn func())
RunSafely keeps a panicking callback from crashing the process (callbacks run on a library-owned goroutine) and, when called from drain, from wedging the queue in the draining state. Exported so callers that fan a single dispatched item out to multiple independent callbacks (e.g. a StateChangeCallback loop) can isolate each one without duplicating this recovery logic.
Types
CallbackQueue
type CallbackQueue struct {
// contains filtered or unexported fields
}
CallbackQueue runs queued callbacks on a single goroutine, in FIFO order. The drain goroutine is spawned on demand and exits when the queue empties, so an idle queue holds no goroutine.
Convention: name fields of this type `cbq` in every struct that holds one.
CallbackQueue.Dispatch
func (q *CallbackQueue) Dispatch(fn func())