tasks

package
v0.0.88 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionCreated = "fn.action.created"
	ActionWaiting = "fn.action.waiting"
	ActionRunning = "fn.action.running"
	ActionDone    = "fn.action.done"
	ActionInstant = "fn.action.instant"
)
View Source
const ErrTypeIsCancelled errType = "CANCELLED"
View Source
const ErrTypeIsDependencyFailed errType = "DEPENDENCY FAILED"
View Source
const ErrTypeIsRegular errType = ""
View Source
const (
	WkAction = "action"
)

Variables

View Source
var ActionStorer func(*RunningAction)
View Source
var (
	BaseDefaultConfig = computeDefaultConfig()
)
View Source
var File_std_tasks_configuration_proto protoreflect.FileDescriptor
View Source
var OutputFullTraceCallsToDebug bool = false
View Source
var (
	TaskOutputTextLog = Output("text.log", "text/plain")
)

Functions

func ContextWithThrottler

func ContextWithThrottler(ctx context.Context, debugLog io.Writer, confs *ThrottleConfigurations) context.Context

func ErrorType

func ErrorType(err error) errType

func MakeStoreProto

func MakeStoreProto(data *EventData, at *EventAttachments) *storage.StoredTask

func NameOf

func NameOf(ev *ActionEvent) (string, string)

func Retain

func Retain(af *RunningAction) *storage.Command

func Return

func Return[V any](ctx context.Context, ev *ActionEvent, f func(context.Context) (V, error)) (V, error)

func SetupFlags

func SetupFlags(flags *pflag.FlagSet)

func TraceCaller

func TraceCaller(ctx context.Context, makeLogger func(context.Context) io.Writer, name string)

func TryProtoAsJson

func TryProtoAsJson(pr ProtoResolver, msg proto.Message, multiline bool) ([]byte, error)

func WithSink

func WithSink(ctx context.Context, sink ActionSink) context.Context

Types

type ActionArgument

type ActionArgument struct {
	Name string
	Msg  interface{}
}

type ActionEvent

type ActionEvent struct {
	// contains filtered or unexported fields
}

func Action

func Action(name string) *ActionEvent

func (*ActionEvent) Anchor

func (ev *ActionEvent) Anchor(id ActionID) *ActionEvent

func (*ActionEvent) Arg

func (ev *ActionEvent) Arg(name string, msg interface{}) *ActionEvent

func (*ActionEvent) Category

func (ev *ActionEvent) Category(category string) *ActionEvent

func (*ActionEvent) Clone

func (ev *ActionEvent) Clone(makeName func(string) string) *ActionEvent

func (*ActionEvent) HumanReadablef

func (ev *ActionEvent) HumanReadablef(label string, args ...interface{}) *ActionEvent

func (*ActionEvent) ID

func (ev *ActionEvent) ID(id ActionID) *ActionEvent

func (*ActionEvent) IncludesPrivateData

func (ev *ActionEvent) IncludesPrivateData() *ActionEvent

func (*ActionEvent) Indefinite

func (ev *ActionEvent) Indefinite() *ActionEvent

func (*ActionEvent) Log

func (ev *ActionEvent) Log(ctx context.Context)

func (*ActionEvent) LogLevel

func (ev *ActionEvent) LogLevel(level int) *ActionEvent

Sets the level for this action (by default it's zero). The lower the level, the higher the importance.

func (*ActionEvent) OnDone

func (ev *ActionEvent) OnDone(f OnDoneFunc) *ActionEvent

func (*ActionEvent) Parent

func (ev *ActionEvent) Parent(tid ActionID) *ActionEvent

func (*ActionEvent) Progress

func (ev *ActionEvent) Progress(p ActionProgress) *ActionEvent

func (*ActionEvent) Run

func (ev *ActionEvent) Run(ctx context.Context, f func(context.Context) error) error

func (*ActionEvent) RunWithOpts

func (ev *ActionEvent) RunWithOpts(ctx context.Context, opts RunOpts) error

func (*ActionEvent) Scope

func (ev *ActionEvent) Scope(pkgs ...schema.PackageName) *ActionEvent

func (*ActionEvent) Start

func (ev *ActionEvent) Start(ctx context.Context) *RunningAction

func (*ActionEvent) StartTimestamp

func (ev *ActionEvent) StartTimestamp(ts time.Time) *ActionEvent

func (*ActionEvent) Str

func (ev *ActionEvent) Str(name string, msg fmt.Stringer) *ActionEvent

type ActionID

type ActionID string

func NewActionID

func NewActionID() ActionID

func (ActionID) String

func (a ActionID) String() string

type ActionProgress

type ActionProgress interface {
	FormatProgress() string
}

type ActionSink

type ActionSink interface {
	Waiting(*RunningAction)
	Started(*RunningAction)
	Done(*RunningAction)
	Instant(*EventData)
	AttachmentsUpdated(ActionID, *ResultData)
	Output(name, contentType string, outputType common.CatOutputType) io.Writer
}

func NullSink

func NullSink() ActionSink

func SinkFrom

func SinkFrom(ctx context.Context) ActionSink

type ActionState

type ActionState string

func (ActionState) IsDone

func (a ActionState) IsDone() bool

func (ActionState) IsRunning

func (a ActionState) IsRunning() bool

type EventAttachments

type EventAttachments struct {
	ResultData
	// contains filtered or unexported fields
}

func Attachments

func Attachments(ctx context.Context) *EventAttachments

func (*EventAttachments) ActionID

func (ev *EventAttachments) ActionID() ActionID

func (*EventAttachments) AddResult

func (ev *EventAttachments) AddResult(key string, msg interface{}) *EventAttachments

func (*EventAttachments) Attach

func (ev *EventAttachments) Attach(name OutputName, body []byte)

func (*EventAttachments) AttachSerializable

func (ev *EventAttachments) AttachSerializable(name, modifier string, body interface{}) error

func (*EventAttachments) IsRecording

func (ev *EventAttachments) IsRecording() bool

func (*EventAttachments) Output

func (ev *EventAttachments) Output(name OutputName, cat common.CatOutputType) io.Writer

func (*EventAttachments) ReaderByName

func (ev *EventAttachments) ReaderByName(name string) io.ReadCloser

func (*EventAttachments) ReaderByOutputName

func (ev *EventAttachments) ReaderByOutputName(outputName OutputName) io.ReadCloser

func (*EventAttachments) SetProgress

func (ev *EventAttachments) SetProgress(p ActionProgress) *EventAttachments

type EventData

type EventData struct {
	ActionID       ActionID
	ParentID       ActionID
	AnchorID       ActionID // This action represents "waiting" on the action represented by `anchorID`.
	SpanID         string
	State          ActionState
	Name           string
	HumanReadable  string // If not set, name is used.
	Category       string
	Created        time.Time
	Started        time.Time
	Completed      time.Time
	Arguments      []ActionArgument
	Scope          schema.PackageList
	Level          int
	HasPrivateData bool
	Indefinite     bool
	Err            error
}

func EventDataFromProto

func EventDataFromProto(cat string, in *protocol.Task) EventData

func (*EventData) Proto

func (ev *EventData) Proto() *protocol.Task

type Observer

type Observer interface {
	OnStart(*RunningAction)
	OnUpdate(*RunningAction)
	OnDone(*RunningAction)
}

type OnDoneFunc

type OnDoneFunc func(*protocol.Task)

type OutputName

type OutputName struct {
	// contains filtered or unexported fields
}

func Output

func Output(name string, contentType string) OutputName

type ResultData

type ResultData struct {
	Items    []*ActionArgument
	Progress ActionProgress
}

type RunOpts

type RunOpts struct {
	// If Wait returns true, then the action is considered to be cached, and Run is skipped.
	Wait func(context.Context) (bool, error)
	Run  func(context.Context) error
}

type RunningAction

type RunningAction struct {
	Data     EventData
	Progress ActionProgress
	// contains filtered or unexported fields
}

func ActionFromProto

func ActionFromProto(ctx context.Context, cat string, in *protocol.Task) *RunningAction

func (*RunningAction) Attachments

func (af *RunningAction) Attachments() *EventAttachments

func (*RunningAction) Call

func (af *RunningAction) Call(ctx context.Context, f func(context.Context) error) error

func (*RunningAction) CustomDone

func (af *RunningAction) CustomDone(t time.Time, err error) bool

func (*RunningAction) Done

func (af *RunningAction) Done(err error) error

func (*RunningAction) ID

func (af *RunningAction) ID() ActionID

func (*RunningAction) Proto

func (af *RunningAction) Proto() *protocol.Task

type StatefulSink

type StatefulSink struct {
	// contains filtered or unexported fields
}

func NewStatefulSink

func NewStatefulSink(parent ActionSink, keepHistory bool) *StatefulSink

func WithStatefulSink

func WithStatefulSink(ctx context.Context) (context.Context, *StatefulSink)

func (*StatefulSink) HistoricReaderByName

func (s *StatefulSink) HistoricReaderByName(id ActionID, name string) io.ReadCloser

func (*StatefulSink) History

func (s *StatefulSink) History(max int, filter func(*protocol.Task) bool) []*protocol.Task

func (*StatefulSink) Observe

func (s *StatefulSink) Observe(obs Observer) func()

func (*StatefulSink) Sink

func (s *StatefulSink) Sink() ActionSink

func (*StatefulSink) Trace

func (s *StatefulSink) Trace(id ActionID) (trace []*protocol.Task)

Recursively returns the action and all of its callers (leaf action first).

type ThrottleConfiguration

type ThrottleConfiguration struct {

	// Capacity configuration applies to requests with these labels.
	Labels map[string]string `` /* 153-byte string literal not displayed */
	// Maximum capacity, i.e. concurrency.
	Capacity int32 `protobuf:"varint,2,opt,name=capacity,proto3" json:"capacity,omitempty"`
	// If specified, maintain a map of capacities, keyed by the value of the specified label.
	CountPerLabel string `protobuf:"bytes,3,opt,name=count_per_label,json=countPerLabel,proto3" json:"count_per_label,omitempty"`
	// contains filtered or unexported fields
}

func (*ThrottleConfiguration) Descriptor deprecated

func (*ThrottleConfiguration) Descriptor() ([]byte, []int)

Deprecated: Use ThrottleConfiguration.ProtoReflect.Descriptor instead.

func (*ThrottleConfiguration) GetCapacity

func (x *ThrottleConfiguration) GetCapacity() int32

func (*ThrottleConfiguration) GetCountPerLabel

func (x *ThrottleConfiguration) GetCountPerLabel() string

func (*ThrottleConfiguration) GetLabels

func (x *ThrottleConfiguration) GetLabels() map[string]string

func (*ThrottleConfiguration) ProtoMessage

func (*ThrottleConfiguration) ProtoMessage()

func (*ThrottleConfiguration) ProtoReflect

func (x *ThrottleConfiguration) ProtoReflect() protoreflect.Message

func (*ThrottleConfiguration) Reset

func (x *ThrottleConfiguration) Reset()

func (*ThrottleConfiguration) String

func (x *ThrottleConfiguration) String() string

type ThrottleConfigurations

type ThrottleConfigurations struct {
	ThrottleConfiguration []*ThrottleConfiguration `protobuf:"bytes,1,rep,name=throttle_configuration,json=throttleConfiguration,proto3" json:"throttle_configuration,omitempty"`
	// contains filtered or unexported fields
}

func LoadThrottlerConfig

func LoadThrottlerConfig(ctx context.Context, debugLog io.Writer) *ThrottleConfigurations

func (*ThrottleConfigurations) Descriptor deprecated

func (*ThrottleConfigurations) Descriptor() ([]byte, []int)

Deprecated: Use ThrottleConfigurations.ProtoReflect.Descriptor instead.

func (*ThrottleConfigurations) GetThrottleConfiguration

func (x *ThrottleConfigurations) GetThrottleConfiguration() []*ThrottleConfiguration

func (*ThrottleConfigurations) ProtoMessage

func (*ThrottleConfigurations) ProtoMessage()

func (*ThrottleConfigurations) ProtoReflect

func (x *ThrottleConfigurations) ProtoReflect() protoreflect.Message

func (*ThrottleConfigurations) Reset

func (x *ThrottleConfigurations) Reset()

func (*ThrottleConfigurations) String

func (x *ThrottleConfigurations) String() string

type WellKnown

type WellKnown string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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