runner

package
v0.0.0-...-8fc2537 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShortID

func ShortID() string

ShortID generates short random ids

Types

type IncludeAction

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

IncludeAction runs shell script

func (*IncludeAction) Eval

func (s *IncludeAction) Eval(ctx force.ExecutionContext) (interface{}, error)

Eval runs shell script and returns output as a string

func (*IncludeAction) MarshalCode

func (s *IncludeAction) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals action into code representation

func (*IncludeAction) String

func (s *IncludeAction) String() string

func (*IncludeAction) Type

func (s *IncludeAction) Type() interface{}

type Input

type Input struct {
	// ID specifies run ID
	ID string
	// Setup is an optional setup script to parse
	// it sets up a group of processes
	Setup Script
	// Script is a script to parse
	Script Script
	// Context is a global context
	Context context.Context
	// Debug turns on global debug mode
	Debug bool
}

Input is an input to parser

func (*Input) CheckAndSetDefaults

func (i *Input) CheckAndSetDefaults() error

CheckAndSetDefaults checks and sets default values

type LoadAction

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

LoadAction

func (*LoadAction) Eval

func (s *LoadAction) Eval(ctx force.ExecutionContext) (interface{}, error)

Eval runs shell script and returns output as a string

func (*LoadAction) MarshalCode

func (s *LoadAction) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

MarshalCode marshals action into code representation

func (*LoadAction) String

func (s *LoadAction) String() string

func (*LoadAction) Type

func (s *LoadAction) Type() interface{}

type LocalProcess

type LocalProcess struct {
	force.Spec
	// contains filtered or unexported fields
}

LocalProcess implements a process interface

func NewLocalProcess

func NewLocalProcess(ctx context.Context, logger force.Logger, spec force.Spec) (*LocalProcess, error)

NewLocalProcess starts a new local process in the future we may support remote processes, e.g. K8s process?

func (*LocalProcess) Action

func (l *LocalProcess) Action() force.Action

func (*LocalProcess) Channel

func (l *LocalProcess) Channel() force.Channel

EventSource returns channel

func (*LocalProcess) Done

func (l *LocalProcess) Done() <-chan struct{}

Done returns a channel that signals that process has completed handling channel events and exited

func (*LocalProcess) Eval

func (l *LocalProcess) Eval(ctx force.ExecutionContext) (interface{}, error)

func (*LocalProcess) Events

func (l *LocalProcess) Events() chan<- force.Event

func (*LocalProcess) Group

func (l *LocalProcess) Group() force.Group

Runner returns a process group this process belongs to

func (*LocalProcess) MarshalCode

func (l *LocalProcess) MarshalCode(ctx force.ExecutionContext) ([]byte, error)

func (*LocalProcess) Name

func (l *LocalProcess) Name() string

Name returns a process name

func (*LocalProcess) Start

func (l *LocalProcess) Start(ctx force.ExecutionContext) error

func (*LocalProcess) String

func (l *LocalProcess) String() string

String returns process user friendly string

func (*LocalProcess) Type

func (l *LocalProcess) Type() interface{}

type NewProcess

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

NewProcess is a function that creates a new process

func (*NewProcess) NewInstance

func (n *NewProcess) NewInstance(group force.Group) (force.Group, interface{})

NewInstance returns a new instance of the process

type NewSetupProcess

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

NewSetupProcess creates new setup process

func (*NewSetupProcess) NewInstance

func (n *NewSetupProcess) NewInstance(group force.Group) (force.Group, interface{})

NewInstance returns a new instance of a function that does nothing but grouping methods together

type Runner

type Runner struct {
	sync.RWMutex
	*force.LexScope
	// contains filtered or unexported fields
}

Runner listens for events and launches processes

func Parse

func Parse(i Input) (*Runner, error)

Parse parses golang-like expressions, for example:

Infof("hello")

And calls registered function "Infof" with argument "hello", however, Infof does not immediatelly log the "hello" message, instead it returns LogAction{Message: "hello"}, essentially

translating golang syntax into a tree of actions to interpret, like a high level virtual machine, for example

func(){
   a := "hello"
   Infof(a)
}()

becomes:

LambdaFunctionCall{
   LambdaFunction{
        Statements: {
             DefineAction{Name: "a", Value: "hello"},
             InfofAction{Format: VariableReference{Name: "a"}}
        }
   }
   // called with no args
   Args: {}
 }

func (*Runner) AddChannel

func (r *Runner) AddChannel(e force.Channel)

func (*Runner) AddProcess

func (r *Runner) AddProcess(p force.Process)

func (*Runner) BroadcastEvents

func (r *Runner) BroadcastEvents() chan<- force.Event

BroadcastEvents will broadcast events to every process in a process group

func (*Runner) Close

func (r *Runner) Close() error

func (*Runner) Context

func (r *Runner) Context() context.Context

Context returns a process group context

func (*Runner) Done

func (r *Runner) Done() <-chan struct{}

Done returns channel

func (*Runner) ExitEvent

func (r *Runner) ExitEvent() force.ExitEvent

func (*Runner) GetPlugin

func (r *Runner) GetPlugin(key interface{}) (interface{}, bool)

GetPlugin returns a process group local variable all setters and getters are thread safe

func (*Runner) IsDebug

func (r *Runner) IsDebug() bool

IsDebug returns a global debug override

func (*Runner) Logger

func (r *Runner) Logger() force.Logger

Logger returns a logger associated with this runner if the plugin is set, it will use the plugin to instantiate the logger

func (*Runner) Oneshot

func (r *Runner) Oneshot(name string, actions ...force.Action) (force.Process, error)

Oneshot creates a new oneshot process

func (*Runner) OneshotWithExit

func (r *Runner) OneshotWithExit(actions ...force.Action) (force.Process, error)

OneshotWithExit creates a oneshot process that wraps actions and exits

func (*Runner) Process

func (r *Runner) Process(spec force.Spec) (force.Process, error)

Process creates a local process

func (*Runner) ProcessCount

func (r *Runner) ProcessCount() int

func (*Runner) RemoveRunner

func (r *Runner) RemoveRunner(name string, in *Runner) bool

RemoveRunner removes the runner if it matches the passed runner pointer (to avoid removing new runner)

func (*Runner) SetPlugin

func (r *Runner) SetPlugin(key interface{}, val interface{})

SetPlugin sets process group-local variable all setters and getters are thread safe

func (*Runner) Setup

func (r *Runner) Setup(actions ...force.Action) (force.Process, error)

Setup creates a new setup process

func (*Runner) Start

func (r *Runner) Start()

Start is a non blocking call

func (*Runner) String

func (r *Runner) String() string

func (*Runner) SwapRunner

func (r *Runner) SwapRunner(name string, in *Runner) *Runner

SwapRunner sets the runner by name and returns the previous version of the runner

type Script

type Script struct {
	// Filename is a file name of the script
	Filename string
	// Content is a script content
	Content string
}

Script is a force code script

Jump to

Keyboard shortcuts

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