worker

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalWorker

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

LocalWorker is the local Worker implement

func NewLocalWorker

func NewLocalWorker(config LocalWorkerConfig) (*LocalWorker, error)

NewLocalWorker create LocalWorker.

func (*LocalWorker) AfterRun

func (l *LocalWorker) AfterRun() (err error)

AfterRun call user hook

func (*LocalWorker) BeforeRun

func (l *LocalWorker) BeforeRun() (err error)

BeforeRun call user hook

func (*LocalWorker) CheckoutCollector

func (l *LocalWorker) CheckoutCollector() (collector.Collector, bool, error)

CheckoutCollector checkout collector.

func (*LocalWorker) Do

func (l *LocalWorker) Do() error

Do call the workers to running

func (*LocalWorker) Done

func (l *LocalWorker) Done() chan struct{}

Done close the worker.

func (*LocalWorker) SetContext

func (l *LocalWorker) SetContext(bs []byte) (err error)

SetContext set the context of worker passed from Master

func (*LocalWorker) Statistics

func (l *LocalWorker) Statistics() (int64, int64)

Statistics get the number of sent and missed transactions

func (*LocalWorker) Teardown

func (l *LocalWorker) Teardown()

Teardown close the worker manually.

type LocalWorkerConfig

type LocalWorkerConfig struct {
	Index    int64         // Index the index of localWorker
	Cap      int64         // Cap the number of vm
	Rate     int64         // Rate the number of tx will be sent per second
	Instant  int64         // Instant the number of a batch
	Wait     time.Duration // Wait maximum time to wait before get vm
	Duration time.Duration // Duration time of pressure test
}

LocalWorkerConfig define the local worker need config.

type RemoteWorker

type RemoteWorker struct {
	*client.Client
}

RemoteWorker is the agent of remote worker.

func NewRemoteWorker

func NewRemoteWorker(index int, url string) (*RemoteWorker, error)

NewRemoteWorker create RemoteWorker.

type Worker

type Worker interface {
	// SetContext set the context of worker passed from Master.
	SetContext([]byte) error

	// BeforeRun call user hook
	BeforeRun() error

	// Do call the workers to running.
	Do() error

	// AfterRun call user hook
	AfterRun() error

	// CheckoutCollector checkout collector.
	CheckoutCollector() (collector.Collector, bool, error)

	// Statistic get the number of sent and missed transactions
	Statistics() (int64, int64)

	// Teardown close the worker manually.
	Teardown()
}

Worker is the interface of worker node

func NewWorkers

func NewWorkers() (workers []Worker, err error)

NewWorkers generate workers according to config

Jump to

Keyboard shortcuts

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