breaker

package module
v0.0.0-...-0e70372 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 2 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

breaker

AFAIRE


Copyright (c) 2022-2023 Archivage Numérique

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Breaker

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

func New

func New(cfg *Config) (*Breaker, error)

func (*Breaker) State

func (b *Breaker) State() State

func (*Breaker) Update

func (b *Breaker) Update(success bool) State

func (*Breaker) Usable

func (b *Breaker) Usable() bool

type Config

type Config struct {
	Name              string        `dm:"name"`
	CloseToOpen       uint          `dm:"close_to_open"`
	HalfOpenToClose   uint          `dm:"half_open_to_close"`
	OpenToHalfOpen    time.Duration `dm:"open_to_half_open"`
	OnStateChangeFunc OnStateChangeFunc
}

type OnStateChangeFunc

type OnStateChangeFunc func(name string, to, from State)

type State

type State string
const (
	StateClosed   State = "closed"
	StateHalfOpen State = "half_open"
	StateOpen     State = "open"
)

Jump to

Keyboard shortcuts

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