Documentation ¶
Index ¶
- Variables
- func AddDependency(ctx context.Context, r *Resource, dep Dependency)
- func Cache(ctx context.Context, key interface{}, f ComputeFunc) (interface{}, error)
- func HasRerunner(ctx context.Context) bool
- func PurgeCache(ctx context.Context)
- func WithDependencyCallback(ctx context.Context, f DependencyCallbackFunc) context.Context
- func WithDependencySetForSelection(ctx context.Context) context.Context
- type ComputeFunc
- type Dependency
- type DependencyCallbackFunc
- type Rerunner
- type Resource
Constants ¶
This section is empty.
Variables ¶
var ( // Sentinel error to tell the rerunner to not dump the current // computation cache and let the error'd function retry. RetrySentinelError = errors.New("retry") // WriteThenReadDelay is how long to wait after hearing a change // was made, before reading that change by rerunning. WriteThenReadDelay = 200 * time.Millisecond )
Functions ¶
func AddDependency ¶
func AddDependency(ctx context.Context, r *Resource, dep Dependency)
func HasRerunner ¶
func PurgeCache ¶
PurgeCache is meant to be use as a transition off of using the reactive cache. It allows slowly removing caching whenever the user wants, ideally between cache execution runs.
func WithDependencyCallback ¶
func WithDependencyCallback(ctx context.Context, f DependencyCallbackFunc) context.Context
WithDependencyCallback registers a callback that is invoked when AddDependency is called with non-nil serializable dependency.
Types ¶
type ComputeFunc ¶
type Dependency ¶
type Dependency interface{}
func Dependencies ¶
func Dependencies(ctx context.Context) []Dependency
func DependenciesForSelection ¶
func DependenciesForSelection(ctx context.Context) []Dependency
type DependencyCallbackFunc ¶
type DependencyCallbackFunc func(context.Context, Dependency)
type Rerunner ¶
type Rerunner struct {
// contains filtered or unexported fields
}
Rerunner automatically reruns a computation whenever its dependencies change.
The computation stops when it returns an error or after calling Stop. There is no way to get the output value from a computation. Instead, the computation should communicate its result before returning.
func NewRerunner ¶
func NewRerunner(ctx context.Context, f ComputeFunc, minRerunInterval time.Duration, alwaysSpawnGoroutine bool) *Rerunner
NewRerunner runs f continuously
func (*Rerunner) RerunImmediately ¶
func (r *Rerunner) RerunImmediately()
RerunImmediately removes the delay from the next recomputation.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource represents a leaf-level dependency in a computation
func (*Resource) Cleanup ¶
func (r *Resource) Cleanup(f func())
Cleanup registers a handler to be called when all computations using r stop
NOTE: For f to be called, at least one computation must AddDependency r!
func (*Resource) Invalidated ¶
func (n *Resource) Invalidated() bool
Invalidated returns if the node has been invalidated