Documentation
¶
Index ¶
Constants ¶
const ( DefaultRetryAfter = time.Second * 10 DefaultTimeoutAfter = time.Second * 15 )
default values populating options objects
Variables ¶
var ( DefaultNotify = func(error) {} DefaultFailedHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.Error(w, "permanent error creating handler", http.StatusServiceUnavailable) }) )
default values populating options objects
Functions ¶
func NewHandler ¶
func NewHandler(ctx context.Context, create func() (http.Handler, error), configs ...Config) http.Handler
NewHandler returns a new http.Handler that will try to queue requests until handler creation succeeded. On a failed creation attempt the notify function will be called with the error returned by `create` if it is configured. In case the passed context is cancelled before a handler could be created, retrying will be terminated and the handler will permanently return 503 or use the behavior of a passed `FailedHandler` Config.
Types ¶
type Config ¶
type Config func(options) options
Config is a function that returns an updated options object when being passed another
func WithExponentialBackoff ¶
WithExponentialBackoff returns a Config that will ensure the given duration is used for retrying handler creation with exponential delay
func WithFailedHandler ¶
WithFailedHandler returns a Config that will ensure the given handler will be used when the creation has permanently failed
func WithNotify ¶
WithNotify returns a Config that will ensure the given Notify func is called when handler creation fails
func WithRetryAfter ¶
WithRetryAfter returns a Config that will ensure the given duration is used as the interval for retrying handler creation
func WithTimeoutAfter ¶
WithTimeoutAfter returns a Config that will ensure the pending handler will timeout after the given duration