Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidHash = xerror.BadInputError{Err: fmt.Errorf("invalid hash")}
ErrInvalidHash indicates an invalid hash was provided.
Functions ¶
func Middleware ¶
Middleware returns a new killswitch middleware. It checks wether the state is on. If not it writes a 503 response.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
type Service ¶
type Service interface { // TurnOff tries to set the the state to off. // Returns an error if the hash is invalid. TurnOff(ctx context.Context, hash string) error // TurnOn tries to set the the state to on. // Returns an error if the hash is invalid. TurnOn(ctx context.Context, hash string) error // On returns wether the current state is set to on. On(ctx context.Context) (bool, error) }
Service defines an interface for interacting with a killswitch service.
-go:generate go run github.com/petergtz/pegomock/pegomock generate eintopf.info/service/killswitch Service --output=../../internal/mock/killswitch_service.go --package=mock --mock-name=KillswitchService
func NewService ¶
NewService returns a new killswitch service. It takes a list of hashes, that can be used to turn the state on or off.
type Storer ¶
type Storer interface { // SetState sets the state of the killswitch. SetState(ctx context.Context, on bool) error // GetState retrieves the state of the killswitch. GetState(ctx context.Context) (bool, error) }
Storer provides methods to store or retrive the killswitch state. The state can either be on or off.
Click to show internal directories.
Click to hide internal directories.