context

package
v0.6.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 17

Documentation

Overview

This package provides a context for Tasks and a registry for their usage in flows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	RootValue cue.Value
	GoContext gocontext.Context

	FlowStack []string

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	Value cue.Value
	Error error

	// debug / internal
	Verbosity int

	Middlewares  []Middleware
	TaskRegistry *sync.Map

	// BOOKKEEPING
	Tasks *sync.Map

	// experimental
	BaseTask *task.BaseTask

	// Middleware
	Pools *sync.Map

	// Global (for this context, tbd shared) lock around CUE evaluator
	CUELock *sync.Mutex

	// map of cue.Values
	ValStore *sync.Map

	// map of chan?
	Mailbox *sync.Map
}

A Context provides context for running a task.

func Copy

func Copy(ctx *Context) *Context

func New

func New() *Context

func (*Context) Lookup

func (C *Context) Lookup(key string) RunnerFunc

Lookup returns the RunnerFunc for a key.

func (*Context) Register

func (C *Context) Register(key string, f RunnerFunc)

Register registers a task for cue commands.

func (*Context) Use

func (C *Context) Use(m Middleware)

type Middleware

type Middleware interface {
	Apply(*Context, RunnerFunc) RunnerFunc
}

Middleware to apply to RunnerFuncs should wrap and call Run of the passed RunnerFunc?

type Runner

type Runner interface {
	// Runner runs given the current value and returns a new value which is to
	// be unified with the original result.
	Run(ctx *Context) (results interface{}, err error)
}

A Runner defines a task type.

type RunnerFunc

type RunnerFunc func(v cue.Value) (Runner, error)

A RunnerFunc creates a Runner.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL