Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool interface { Refreshable CurrentBool() bool }
func NewBool ¶
func NewBool(in Refreshable) Bool
type DefaultRefreshable ¶
type DefaultRefreshable struct { sync.Mutex // protects subscribers // contains filtered or unexported fields }
func NewDefaultRefreshable ¶
func NewDefaultRefreshable(val interface{}) *DefaultRefreshable
func (*DefaultRefreshable) Current ¶
func (d *DefaultRefreshable) Current() interface{}
func (*DefaultRefreshable) Map ¶
func (d *DefaultRefreshable) Map(mapFn func(interface{}) interface{}) Refreshable
func (*DefaultRefreshable) Subscribe ¶
func (d *DefaultRefreshable) Subscribe(consumer func(interface{})) (unsubscribe func())
func (*DefaultRefreshable) Update ¶
func (d *DefaultRefreshable) Update(val interface{}) error
type Duration ¶ added in v1.6.5
type Duration interface { Refreshable CurrentDuration() time.Duration }
Duration is a Refreshable that can return the current time.Duration.
func NewDuration ¶ added in v1.6.5
func NewDuration(in Refreshable) Duration
type Int ¶
type Int interface { Refreshable CurrentInt() int }
func NewInt ¶
func NewInt(in Refreshable) Int
type Refreshable ¶
type Refreshable interface { // Current returns the most recent value of this Refreshable. Current() interface{} // Subscribe subscribes to changes of this Refreshable. The provided function is called with the value of Current() // whenever the value changes. Subscribe(consumer func(interface{})) (unsubscribe func()) // Map returns a new Refreshable based on the current one that handles updates based on the current Refreshable. Map(func(interface{}) interface{}) Refreshable }
func NewFileRefreshable ¶
func NewFileRefreshable(ctx context.Context, filePath string) (Refreshable, error)
NewFileRefreshable is identical to NewFileRefreshableWithDuration except it defaults to use defaultRefreshableSyncPeriod for how often the file is checked
func NewFileRefreshableWithDuration ¶ added in v1.17.1
func NewFileRefreshableWithDuration(ctx context.Context, filePath string, duration time.Duration) (Refreshable, error)
NewFileRefreshableWithDuration returns a new Refreshable whose current value is the bytes of the file at the provided path. The file is checked every duration time.Duration as an argument. Calling this function also starts a goroutine which updates the value of the refreshable whenever the specified file is changed. The goroutine will terminate when the provided context is done or when the returned cancel function is called.
type String ¶
type String interface { Refreshable CurrentString() string }
func NewString ¶
func NewString(in Refreshable) String
type ValidatingRefreshable ¶ added in v1.12.0
type ValidatingRefreshable struct { Refreshable // contains filtered or unexported fields }
func NewValidatingRefreshable ¶ added in v1.12.0
func NewValidatingRefreshable(origRefreshable Refreshable, validatingFn func(interface{}) error) (*ValidatingRefreshable, error)
NewValidatingRefreshable returns a new Refreshable whose current value is the latest value that passes the provided validatingFn successfully. This returns an error if the current value of the passed in Refreshable does not pass the validatingFn or if the validatingFn or Refreshable are nil.
func (*ValidatingRefreshable) Current ¶ added in v1.12.0
func (v *ValidatingRefreshable) Current() interface{}
func (*ValidatingRefreshable) LastValidateErr ¶ added in v1.12.0
func (v *ValidatingRefreshable) LastValidateErr() error
func (*ValidatingRefreshable) Map ¶ added in v1.12.0
func (v *ValidatingRefreshable) Map(mapFn func(interface{}) interface{}) Refreshable
func (*ValidatingRefreshable) Subscribe ¶ added in v1.12.0
func (v *ValidatingRefreshable) Subscribe(consumer func(interface{})) (unsubscribe func())