Documentation ¶
Index ¶
- func Create[valueT any, versionT comparable](ctx context.Context, name string) (*cacher[valueT, versionT], error)
- func CreateInDirectory[valueT any, versionT comparable](ctx context.Context, name string, cacheDir string) (*cacher[valueT, versionT], error)
- func CreateListener[T comparable](source <-chan T) *listeners[T]
- func CreateReactiveListener[T comparable](r Reactive[T], validity time.Duration) *reactiveListeners[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 SilentCacheableFunction
- 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 CreateReactiveListener ¶
func CreateReactiveListener[T comparable](r Reactive[T], validity time.Duration) *reactiveListeners[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[valueT any] func(ctx context.Context, stdout io.Writer, stderr io.Writer) (result valueT, err error)
A CacheableFunction is provided with writers for any stdout/stderr they produce, along with a context which may be cancelled.
type Cacher ¶
type Cacher[valueT any, versionT comparable] interface { Call(ctx context.Context, wrapped SilentCacheableFunction[valueT], version versionT) (valueT, error) Cache(ctx context.Context, hasher hash.Hash, wrapped CacheableFunction[valueT], versioner Version[versionT]) (valueT, error) SetDefaultValidity(d time.Duration) Close() }
type Reactive ¶
type Reactive[T comparable] func() (T, error)
type SilentCacheableFunction ¶
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.