worker

package
v4.7.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 21 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

func WithMaxExecs added in v4.7.0

func WithMaxExecs(maxExecs uint64) 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) AddCallback added in v4.5.0

func (w *Process) AddCallback(cb func())

func (*Process) AttachRelay

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

AttachRelay attaches relay to the worker

func (*Process) Callback added in v4.5.0

func (w *Process) Callback()

func (*Process) Created

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

Created returns time, worker was created at.

func (*Process) Exec

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

Exec executes payload with TTL timeout in the context.

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) MaxExecs added in v4.7.2

func (w *Process) MaxExecs() uint64

func (*Process) MaxExecsReached added in v4.7.0

func (w *Process) MaxExecsReached() bool

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) StreamCancel added in v4.4.0

func (w *Process) StreamCancel(ctx context.Context) error

StreamCancel sends stop bit to the worker

func (*Process) StreamIter added in v4.4.0

func (w *Process) StreamIter() (*payload.Payload, bool, error)

func (*Process) StreamIterWithContext added in v4.5.5

func (w *Process) StreamIterWithContext(ctx context.Context) (*payload.Payload, bool, error)

StreamIter returns true if stream is available and payload

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