Documentation ¶
Index ¶
- func Create[T comparable](ctx context.Context, name string) (*cacher[T], error)
- func CreateInDirectory[T comparable](ctx context.Context, name string, cacheDir string) (*cacher[T], error)
- func CreateListener[T comparable](source <-chan T) *listeners[T]
- func CreateStaticListener[T comparable](value T) staticListeners[T]
- func WaitForCurrent[T comparable](ctx context.Context, v Version[T]) error
- func WaitForValue[T comparable](ctx context.Context, v Version[T], value T) error
- type CacheableFunction
- type Cacher
- type Reactive
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateInDirectory ¶
func CreateListener ¶
func CreateListener[T comparable](source <-chan T) *listeners[T]
func CreateStaticListener ¶
func CreateStaticListener[T comparable](value T) staticListeners[T]
func WaitForCurrent ¶
func WaitForCurrent[T comparable](ctx context.Context, v Version[T]) error
func WaitForValue ¶
func WaitForValue[T comparable](ctx context.Context, v Version[T], value T) error
Types ¶
type CacheableFunction ¶
type CacheableFunction func(ctx context.Context, stdout io.Writer, stderr io.Writer) (result []byte, err error)
A CacheableFunction is provided with writers for any stdout/stderr they produce, along with a context which may be cancelled.
type Reactive ¶
type Reactive[T comparable] func() T
func (Reactive[_]) CancelNotifyOnChange ¶
func (Reactive[_]) HasCurrent ¶
func (Reactive[T]) NotifyOnChange ¶
type Version ¶
type Version[T comparable] interface { HasCurrent() bool Current() T // only valid if HasCurrent() NotifyOnChange(onChanged chan<- T) int // CancelNotifyOnChange deregisters the NotifyOnChange registration. CancelNotifyOnChange(i int) }
Version is used to track the current value of something, receiving a push to nominated channel(s) whenever the value changes. The channel will also be pushed the current value, if there is one at the time of registration.
func CreateNullVersion ¶
CreateNullVersion is used as a no-op, when no version should ever be returned
Click to show internal directories.
Click to hide internal directories.