Documentation
¶
Index ¶
- Constants
- func FromContext(ctx context.Context) *waiter
- func InformOnWaiting(log logr.Logger, period time.Duration, message string, keysAndValues ...any) *waiter
- func IsValidValue(value string) bool
- func LogFromContext(ctx context.Context) logr.Logger
- type BasicFlowContext
- func (c *BasicFlowContext) AddTask(g *flow.Graph, name string, fn flow.TaskFn, options ...TaskOption) flow.TaskIDer
- func (c *BasicFlowContext) PersistState(ctx context.Context) error
- func (c *BasicFlowContext) WithLogger(log logr.Logger) *BasicFlowContext
- func (c *BasicFlowContext) WithPersist(task flow.TaskFn) *BasicFlowContext
- func (c *BasicFlowContext) WithSpan() *BasicFlowContext
- type FlatMap
- type TaskOption
- type Timestamper
- type TimestamperFn
- type Whiteboard
Constants ¶
const (
// Separator is used to on translating keys to/from flat maps
Separator = "/"
)
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext retrieves a waiter from the current context or returns nil if there is none.
func InformOnWaiting ¶
func InformOnWaiting(log logr.Logger, period time.Duration, message string, keysAndValues ...any) *waiter
InformOnWaiting periodically prints a message until stopped.
func IsValidValue ¶
IsValidValue returns true if an exported value is valid, i.e. not empty and not special value for deleted.
Types ¶
type BasicFlowContext ¶
type BasicFlowContext struct {
PersistInterval time.Duration
// contains filtered or unexported fields
}
BasicFlowContext provides logic for persisting the state and add tasks to the flow graph.
func NewBasicFlowContext ¶
func NewBasicFlowContext() *BasicFlowContext
NewBasicFlowContext creates a new `BasicFlowContext`.
func (*BasicFlowContext) AddTask ¶
func (c *BasicFlowContext) AddTask(g *flow.Graph, name string, fn flow.TaskFn, options ...TaskOption) flow.TaskIDer
AddTask adds a wrapped task for the given task function and options.
func (*BasicFlowContext) PersistState ¶
func (c *BasicFlowContext) PersistState(ctx context.Context) error
PersistState persists the internal state to the provider status.
func (*BasicFlowContext) WithLogger ¶
func (c *BasicFlowContext) WithLogger(log logr.Logger) *BasicFlowContext
WithLogger injects the given logger into the context.
func (*BasicFlowContext) WithPersist ¶
func (c *BasicFlowContext) WithPersist(task flow.TaskFn) *BasicFlowContext
WithPersist is the Task that will be called after each successful node directly after the node execution.
func (*BasicFlowContext) WithSpan ¶
func (c *BasicFlowContext) WithSpan() *BasicFlowContext
WithSpan when enabled will log the total execution time for the task on Info level.
type TaskOption ¶
TaskOption contains options for created flow tasks
func Dependencies ¶
func Dependencies(dependencies ...flow.TaskIDer) TaskOption
Dependencies creates a TaskOption for dependencies
func Timeout ¶
func Timeout(timeout time.Duration) TaskOption
Timeout creates a TaskOption for Timeout
type Timestamper ¶
Timestamper is an interface around time package.
var DefaultTimer Timestamper = TimestamperFn(time.Now)
DefaultTimer is the default implementation for Timestamper used in the package.
type TimestamperFn ¶
TimestamperFn is an implementation of the Timestamper interface using a function.
func (TimestamperFn) Now ¶
func (t TimestamperFn) Now() time.Time
Now returns the value of time.Now().
type Whiteboard ¶
type Whiteboard interface {
IsEmpty() bool
// GetChild returns a sub-whiteboard for the given key. If no child exists with this name, it is created automatically.
// Each child has its own lock.
GetChild(key string) Whiteboard
// HasChild returns true if there is a non-empty child for that key
HasChild(key string) bool
// GetChildrenKeys returns all children keys
GetChildrenKeys() []string
// Get returns a valid value or nil (never "" or special deleted value)
Get(key string) *string
Set(key, id string)
Delete(key string)
SetPtr(key string, id *string)
IsAlreadyDeleted(key string) bool
SetAsDeleted(key string)
// Keys returns all stored keys, even for deleted ones
Keys() []string
// AsMap returns a map with all valid key/values
AsMap() map[string]string
GetObject(key string) any
SetObject(key string, obj any)
DeleteObject(key string)
HasObject(key string) bool
ObjectKeys() []string
// ImportFromFlatMap reconstructs the hierarchical structure from a flat map containing path-like keys
ImportFromFlatMap(data FlatMap)
// ExportAsFlatMap exports the hierarchical structure to a flat map with path-like keys. Objects are ignored.
ExportAsFlatMap() FlatMap
// CurrentGeneration returns current generation, which increments with any change
CurrentGeneration() int64
}
Whiteboard is a hierarchical key/value store for the internal state. It is safe to be used concurrently. Additionally, it can cache objects for use in subsequent flow task.