job

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MsgLevel

func MsgLevel(lvl string) fwk.Level

MsgLevel returns the fwk.Level according to the given lvl string value. MsgLevel panics if no fwk.Level value corresponds to the lvl string value. Valid values are: "DEBUG", "INFO", "WARNING"|"WARN" and "ERROR"|"ERR".

func NewJSONDecoder

func NewJSONDecoder(r io.Reader) *json.Decoder

NewJSONDecoder returns a new decoder that reads from r.

func NewJSONEncoder

func NewJSONEncoder(w io.Writer) *json.Encoder

NewJSONEncoder returns a new encoder that writes to w

func Save

func Save(stmts []Stmt, enc Encoder) error

Save saves a job's configuration description using the Encoder enc.

Types

type C

type C struct {
	Name  string // name of the fwk.Component to create (eg "my-propagator")
	Type  string // type of the fwk.Component to create (eg "go-hep.org/x/hep/fads.Propagator")
	Props P      // properties of the fwk.Component to create
}

C describes the configuration data of a fwk.Component

type Decoder

type Decoder interface {
	Decode(ptr interface{}) error
}

Decoder decodes data from the unerlying io.Reader

type Encoder

type Encoder interface {
	Encode(data interface{}) error
}

Encoder encodes data into the underlying io.Writer

type GoEncoder

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

A GoEncoder writes a go representation to an output stream

func NewGoEncoder

func NewGoEncoder(w io.Writer) *GoEncoder

NewGoEncoder returns a new encoder that writes to w

func (*GoEncoder) Encode

func (enc *GoEncoder) Encode(data interface{}) error

Encode encodes data into the underlying io.Writer

type Job

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

Job is the go-based scripting interface to create, configure and run a fwk.App.

func New

func New(props P) *Job

New create a new Job with the default fwk.App implementation and configures it with the given properties P.

func NewJob

func NewJob(app fwk.App, props P) *Job

NewJob create a new Job from the given fwk.App value and configures it with the given properties P.

func (*Job) App

func (job *Job) App() fwk.App

App returns the underlying fwk.App value of this Job.

func (*Job) Create

func (job *Job) Create(cfg C) fwk.Component

Create creates a fwk.Component according to the configuration data held by cfg. Create panics if no such component was registered with fwk.

func (*Job) Debugf

func (job *Job) Debugf(format string, a ...interface{}) (int, error)

Debugf displays a (formated) DBG message

func (*Job) Errorf

func (job *Job) Errorf(format string, a ...interface{}) (int, error)

Errorf displays a (formated) ERR message

func (*Job) Infof

func (job *Job) Infof(format string, a ...interface{}) (int, error)

Infof displays a (formated) INFO message

func (*Job) Run

func (job *Job) Run()

Run runs the underlying fwk.App. Run panics if an error occurred during any of the execution stages of the application.

func (*Job) SetProp

func (job *Job) SetProp(c fwk.Component, name string, value interface{})

SetProp sets the property name of the component c with the value v. SetProp panics if the component does not have such property or if the types do not match.

func (*Job) Stmts

func (job *Job) Stmts() []Stmt

Stmts returns the list of statements this Job has seen so far.

func (*Job) UI

func (job *Job) UI() UI

UI returns a fwk Scripter

func (*Job) Warnf

func (job *Job) Warnf(format string, a ...interface{}) (int, error)

Warnf displays a (formated) WARN message

type P

type P map[string]interface{}

P holds the configuration data (the properties) of a fwk.Component a map of key-value pairs.

type Stmt

type Stmt struct {
	Type StmtType // type of the statement
	Data C        // the configuration data associated with that statement
}

Stmt represents a job options statement.

func Load

func Load(dec Decoder) ([]Stmt, error)

Load loads a job's configuration description using the Decoder dec.

type StmtType

type StmtType int

StmtType represents the type of a job-options statement.

const (
	StmtNewApp StmtType = iota
	StmtCreate
	StmtSetProp
)

func (StmtType) String

func (stmt StmtType) String() string

String returns the string representation of a StmtType

type UI

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

UI wraps a fwk.Scripter and panics when an error occurs

func (UI) Configure

func (ui UI) Configure()

Configure configures the underlying fwk.App. Configure panics if an error occurs.

func (UI) Run

func (ui UI) Run(evtmax int64)

Run runs the event-loop of the underlying fwk.App. Run panics if an error different than io.EOF occurs.

func (UI) Shutdown

func (ui UI) Shutdown()

Shutdown shuts the underlying fwk.App down. Shutdown panics if an error occurs.

func (UI) Start

func (ui UI) Start()

Start starts the underlying fwk.App. Start panics if an error occurs.

func (UI) Stop

func (ui UI) Stop()

Stop stops the underlying fwk.App. Stopt panics if an error occurs.

Jump to

Keyboard shortcuts

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