...

Package functionchain

import "golang.conradwood.net/go-easyops/utils/functionchain"
Overview
Index

Overview ▾

type Function

type Function interface {
    SetTo(ctx context.Context, activate bool) error
}

type FunctionChain

a "function chain" is a chain of idempotent functions that enable or disable something. The chain will attempt to keep ALL functions enabled or disabled. In other words, it attempts to keep all functions either disabled or enabled.

type FunctionChain struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewFunctionChain

func NewFunctionChain() *FunctionChain

func (*FunctionChain) Add

func (fc *FunctionChain) Add(f Function) *function_ref

func (*FunctionChain) AddFuncs

func (fc *FunctionChain) AddFuncs(enable, disable func(context.Context) error) *function_ref

shortcut: add a pair of enable/disable functions

func (*FunctionChain) AddSetter

func (fc *FunctionChain) AddSetter(setter func(context.Context, bool) error) *function_ref

shortcut: add a pair of enable/disable functions

func (*FunctionChain) Disable

func (fc *FunctionChain) Disable(ctx context.Context) error

func (*FunctionChain) Enable

func (fc *FunctionChain) Enable(ctx context.Context) error

func (*FunctionChain) SetTo

func (fc *FunctionChain) SetTo(ctx context.Context, b bool) error