redisfallback

package
v1.22.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package redisfallback runs a store's Redis commands with an in-process fallback. A command waits at most Timeout, whatever the client's own timeouts. While Redis fails, one call tries it again after a backoff that doubles from a second to 30 seconds and the rest use the fallback; the failure and the recovery are logged once each.

Index

Constants

View Source
const (
	// Timeout bounds what one command waits on Redis, so an outage costs a
	// request at most this.
	Timeout = 250 * time.Millisecond
)

Variables

This section is empty.

Functions

func Run

func Run[T any](ctx context.Context, g *Gate, cmd func(context.Context) (T, error)) (_ T, ok bool)

Run runs cmd on Redis. ok is false when the caller must use its fallback: Redis failed, or is down and no retry is due.

Types

type Gate

type Gate struct {
	// contains filtered or unexported fields
}

Gate tracks one store's Redis.

func New

func New(failure, recovery string) *Gate

New is a gate that logs failure and recovery when Redis fails and answers again.

Jump to

Keyboard shortcuts

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