worker

package
v2.11.4 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Report

func Report(reporters []metrics.Reporter, period time.Duration)

Report sends periodic of worker reports

Types

type RPCJob

type RPCJob interface {
	// ServerDiscovery returns a serverID based on the route
	// and any metadata that is necessary to decide
	ServerDiscovery(
		route string,
		rpcMetadata map[string]interface{},
	) (serverID string, err error)

	// RPC executes the RPC
	// It is expected that if serverID is "" the RPC
	// happens to any destiny server
	RPC(
		ctx context.Context,
		serverID, routeStr string,
		reply, arg proto.Message,
	) error

	// GetArgReply returns the arg and reply of the
	// method
	GetArgReply(route string) (arg, reply proto.Message, err error)
}

RPCJob has infos to execute a rpc on worker

type Worker

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

Worker executes RPCs with retry and backoff time

func NewWorker

func NewWorker(config config.WorkerConfig, opts config.EnqueueOpts) (*Worker, error)

NewWorker configures and returns a *Worker

func (*Worker) EnqueueRPC

func (w *Worker) EnqueueRPC(
	routeStr string,
	metadata map[string]interface{},
	reply, arg proto.Message,
) (jid string, err error)

EnqueueRPC enqueues rpc job to worker

func (*Worker) EnqueueRPCWithOptions

func (w *Worker) EnqueueRPCWithOptions(
	routeStr string,
	metadata map[string]interface{},
	reply, arg proto.Message,
	opts *config.EnqueueOpts,
) (jid string, err error)

EnqueueRPCWithOptions enqueues rpc job to worker

func (*Worker) RegisterRPCJob

func (w *Worker) RegisterRPCJob(rpcJob RPCJob) error

RegisterRPCJob registers a RPC job

func (*Worker) SetLogger

func (w *Worker) SetLogger(logger interfaces.Logger)

SetLogger overwrites worker logger

func (*Worker) Start

func (w *Worker) Start()

Start starts worker in another gorotine

func (*Worker) Started

func (w *Worker) Started() bool

Started returns true if worker was started

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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