control

package
v0.2.4-0...-f8342f3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const LogKeyActor = "actor"
View Source
const LogKeyCallID = "call_id"

Variables

This section is empty.

Functions

func MaybeRuntimeErr

func MaybeRuntimeErr(err error) error

Types

type Call

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

func (*Call) RegisterStop

func (c *Call) RegisterStop(onStop base.OnStop)

func (*Call) RequestStep

func (c *Call) RequestStep(ctx context.Context) (noStep bool, finish bool, err error)

RequestStep wait for the next step, and waits for the step to complete, or for the call to finish.

func (*Call) RequestStop

func (c *Call) RequestStop(ctx context.Context) error

func (*Call) Step

func (c *Call) Step(step base.Step) error

Blocks until the step is consumed by the caller

type CallErr

type CallErr struct {
	Exit CallExitReason
	Err  error
}

func (*CallErr) Error

func (ce *CallErr) Error() string

func (*CallErr) String

func (ce *CallErr) String() string

func (*CallErr) Unwrap

func (ce *CallErr) Unwrap() error

type CallExitReason

type CallExitReason uint8
const (
	SuccessDone CallExitReason = iota
	RuntimeError
	ParseError
)

func (CallExitReason) ExitErr

func (code CallExitReason) ExitErr() error

func (CallExitReason) WithErr

func (code CallExitReason) WithErr(err error) *CallErr

type CallID

type CallID string

type CallSummary

type CallSummary struct {
	ActorName actor.ActorID `json:"actor"`
	Args      []string      `json:"args"`
}

type EnvGlobal

type EnvGlobal interface {
	GetCall(id CallID) *Call
	// Runs the call in sync
	MakeCall(callCtx context.Context, out io.Writer, actorID actor.ActorID, callID CallID, args []string) (*Call, error)
	NewSubSession(log logrus.FieldLogger, ctx context.Context, parentEnv expand.Environ) *Session
	IsClosing() bool
	KillActor(id actor.ActorID)
	GetCalls(id actor.ActorID) map[CallID]CallSummary
	GetLogData(key string) (value interface{}, ok bool)
	ClearLogData()
}

type LinesReader

type LinesReader struct {
	Fn NextMultiLineFn
	// contains filtered or unexported fields
}

LinesReader is used to convert a stream of lines back into a reader

func (*LinesReader) Read

func (lr *LinesReader) Read(p []byte) (n int, err error)

type LogSplitFn

type LogSplitFn func(entry *logrus.Entry) error

func (LogSplitFn) Format

func (fn LogSplitFn) Format(entry *logrus.Entry) ([]byte, error)

type NextMultiLineFn

type NextMultiLineFn func() (string, error)

Reads one or more lines at a time. The multi-line string may not end with a linebreak character, but should never end in the middle of an actual line.

type NextSingleLineFn

type NextSingleLineFn func() (string, error)

type ReadWithCallback

type ReadWithCallback struct {
	io.Reader
	Callback func() error
}

func (*ReadWithCallback) Read

func (rc *ReadWithCallback) Read(p []byte) (n int, err error)

type Report

type Report struct {
	Actors map[actor.ActorID]ReportActor `json:"actors"`
	Calls  map[CallID]ReportCall         `json:"calls"`
}

type ReportActor

type ReportActor struct {
	// May be empty if no host is active
	PeerID      string   `json:"peer_id,omitempty"`
	ListenAddrs []string `json:"listen_addrs,omitempty"`
	Peers       []string `json:"peers,omitempty"`
	ENR         string   `json:"enr,omitempty"`
}

type ReportCall

type ReportCall struct {
	Actor       actor.ActorID `json:"actor,omitempty"`
	Args        []string      `json:"args,omitempty"`
	StartTimeMS int64         `json:"start_time,omitempty"`
}

type Session

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

func (*Session) Close

func (sess *Session) Close() error

func (*Session) Done

func (sess *Session) Done() <-chan struct{}

func (*Session) Each

func (sess *Session) Each(fn func(name string, vr expand.Variable) bool)

func (*Session) Exited

func (sess *Session) Exited() bool

func (*Session) Get

func (sess *Session) Get(name string) expand.Variable

func (*Session) GetLastCall

func (sess *Session) GetLastCall() *Call

func (*Session) HasInterest

func (sess *Session) HasInterest(id CallID) (lvl logrus.Level, ok bool)

func (*Session) ListInterests

func (sess *Session) ListInterests() (out []CallID)

func (*Session) NewCallID

func (sess *Session) NewCallID() CallID

func (*Session) Run

func (sess *Session) Run(ctx context.Context, node syntax.Node) error

Run interprets a node inside a Rumor session, using the mvdan shell package.

From the shell docs: A node can be a *File, *Stmt, or Command. If a non-nil error is returned, it will typically contain commands exit status, which can be retrieved with IsExitStatus.

Run can be called multiple times synchronously to interpret programs incrementally. To reuse a Runner without keeping the internal shell state, call Reset.

func (*Session) RunCmd

func (sess *Session) RunCmd(ctx context.Context, args []string) error

RunCmd implements interp.ExecHandlerFunc

func (*Session) RunInclude

func (sess *Session) RunInclude(ctx context.Context, includePath string) error

RunInclude runs an included file as a sub-session. The ctx must be an interp.HandlerCtx. The session environment, except the dynamic parts, is inherited. As well as the current default actor.

func (*Session) RunNonRumorCmd

func (sess *Session) RunNonRumorCmd(ctx context.Context, args []string) error

func (*Session) SetInterest

func (sess *Session) SetInterest(id CallID, lvl logrus.Level)

func (*Session) UnsetInterest

func (sess *Session) UnsetInterest(id CallID)

type SessionID

type SessionID string

type SessionProcessor

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

func NewSessionProcessor

func NewSessionProcessor(adminLog logrus.FieldLogger) *SessionProcessor

func (*SessionProcessor) ClearLogData

func (sp *SessionProcessor) ClearLogData()

func (*SessionProcessor) Close

func (sp *SessionProcessor) Close()

func (*SessionProcessor) GetActor

func (sp *SessionProcessor) GetActor(name actor.ActorID) *actor.Actor

func (*SessionProcessor) GetCall

func (sp *SessionProcessor) GetCall(id CallID) *Call

func (*SessionProcessor) GetCalls

func (sp *SessionProcessor) GetCalls(id actor.ActorID) map[CallID]CallSummary

func (*SessionProcessor) GetLogData

func (sp *SessionProcessor) GetLogData(key string) (value interface{}, ok bool)

func (*SessionProcessor) IsClosing

func (sp *SessionProcessor) IsClosing() bool

func (*SessionProcessor) KillActor

func (sp *SessionProcessor) KillActor(id actor.ActorID)

func (*SessionProcessor) MakeCall

func (sp *SessionProcessor) MakeCall(callCtx context.Context, out io.Writer,
	actorName actor.ActorID, callID CallID, cmdArgs []string) (*Call, error)

func (*SessionProcessor) NewSession

func (sp *SessionProcessor) NewSession(log logrus.FieldLogger) *Session

func (*SessionProcessor) NewSubSession

func (sp *SessionProcessor) NewSubSession(log logrus.FieldLogger, ctx context.Context, parentEnv expand.Environ) *Session

func (*SessionProcessor) RemoveInterests

func (sp *SessionProcessor) RemoveInterests(id CallID)

func (*SessionProcessor) Report

func (sp *SessionProcessor) Report() *Report

type ShellLogFmt

type ShellLogFmt struct {
	FieldMap FieldMap
}

ShellLogFmt formats logs into text

func (*ShellLogFmt) Format

func (f *ShellLogFmt) Format(entry *Entry) ([]byte, error)

Format renders a single log entry

type VoidWriter

type VoidWriter struct{}

func (VoidWriter) Write

func (v VoidWriter) Write(p []byte) (n int, err error)

type WriteableFn

type WriteableFn func(msg string)

func (WriteableFn) Write

func (fn WriteableFn) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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