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 InvalidateAfter(ctx context.Context, d time.Duration)
- func InvalidateAt(ctx context.Context, t time.Time)
- func WithDependencyCallback(ctx context.Context, f DependencyCallbackFunc) 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 WithDependencyCallback ¶ added in v0.5.0
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 ¶ added in v0.5.0
type Dependency interface{}
func Dependencies ¶ added in v0.5.0
func Dependencies(ctx context.Context) []Dependency
type DependencyCallbackFunc ¶ added in v0.5.0
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 ¶
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