worker

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 18 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options func(p *Process)

func WithLog

func WithLog(z *zap.Logger) Options

type Process

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

Process - supervised process with api over goridge.Relay.

func InitBaseWorker

func InitBaseWorker(cmd *exec.Cmd, options ...Options) (*Process, error)

InitBaseWorker creates new Process over given exec.cmd.

func (*Process) AttachRelay

func (w *Process) AttachRelay(rl relay.Relay)

AttachRelay attaches relay to the worker

func (*Process) Created

func (w *Process) Created() time.Time

Created returns time, worker was created at.

func (*Process) Exec

func (w *Process) Exec(p *payload.Payload) (*payload.Payload, error)

Exec payload without TTL timeout.

func (*Process) ExecWithTTL

func (w *Process) ExecWithTTL(ctx context.Context, p *payload.Payload) (*payload.Payload, error)

ExecWithTTL executes payload without TTL timeout.

func (*Process) Kill

func (w *Process) Kill() error

Kill kills underlying process, make sure to call Wait() func to gather error log from the stderr. Does not wait for process completion!

func (*Process) Pid

func (w *Process) Pid() int64

Pid returns worker pid.

func (*Process) Relay

func (w *Process) Relay() relay.Relay

Relay returns relay attached to the worker

func (*Process) Start

func (w *Process) Start() error

func (*Process) State

func (w *Process) State() *fsm.Fsm

State return receive-only Process state object, state can be used to safely access Process status, time when status changed and number of Process executions.

func (*Process) Stop

func (w *Process) Stop() error

Stop sends soft termination command to the Process and waits for process completion.

func (*Process) String

func (w *Process) String() string

String returns Process description. fmt.Stringer interface

func (*Process) Wait

func (w *Process) Wait() error

Wait must be called once for each Process, call will be released once Process is complete and will return process error (if any), if stderr is presented it is value will be wrapped as WorkerError. Method will return error code if php process fails to find or Start the script.

func (*Process) Write

func (w *Process) Write(p []byte) (int, error)

Worker stderr

Jump to

Keyboard shortcuts

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