conveyor

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: MIT Imports: 16 Imported by: 0

README

Conveyor

The support of the multi-concurrent design patterns.

Common Conveyor schema:

alt text

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(lengthChannel int, chanType faces.ChanType, name string) faces.IConveyor

Types

type Conveyor

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

func (*Conveyor) AddErrorHandler

func (c *Conveyor) AddErrorHandler(manageName faces.Name, minCount, maxCount int, handler faces.GiveBirth) error

AddErrorHandler adds custom error handler for processing the errors which were returned with work handler. Multiple custom error handlers are allowed. If custom error handler returned error the conveyor logs the error but doesn't process.

func (*Conveyor) AddFinalHandler

func (c *Conveyor) AddFinalHandler(name faces.Name, minCount, maxCount int, handler faces.GiveBirth) error

AddFinalHandler adds customer final handler as the latest handler from all. Only single customer final handler is allow. If custom final handler returned error the conveyor doesn't process and log it.

func (*Conveyor) AddHandler

func (c *Conveyor) AddHandler(name faces.Name, minCount, maxCount int, handler faces.GiveBirth) error

addSystemFinalHandler adds customer handler. Parameter name should be unique. minCount should be less or equal the maxCount.

The order of adding handlers are important. The handlers are called in the same order as they were added.

func (*Conveyor) GetDefaultPriority

func (c *Conveyor) GetDefaultPriority() int

GetDefaultPriority returns the default priority of items. It makes sense if priority queue is used.

func (*Conveyor) GetName

func (c *Conveyor) GetName() string

GetName is a simple getter for name property

func (*Conveyor) MetricPeriod

func (c *Conveyor) MetricPeriod(duration time.Duration) faces.IConveyor

MetricPeriod sets up the period between metric evaluations. By default 10 second

func (*Conveyor) Run

func (c *Conveyor) Run(data interface{})

Run creates the new item over interface and sends to conveyor. If priority queue is used the default priority will be set up.

func (*Conveyor) RunCtx

func (c *Conveyor) RunCtx(ctx context.Context, data interface{})

RunCtx is a variety of Run with context If priority queue is used the default priority will be set up.

func (*Conveyor) RunPriority

func (c *Conveyor) RunPriority(data interface{}, priority int)

RunPriority is a variety of Run with priority

func (*Conveyor) RunPriorityCtx

func (c *Conveyor) RunPriorityCtx(ctx context.Context, data interface{}, priority int)

RunPriorityCtx is a variety of RunPriority with context

func (*Conveyor) RunPriorityTrace

func (c *Conveyor) RunPriorityTrace(ctx context.Context, tr faces.ITrace, data interface{}, priority int)

RunPriorityTrace is a variety of RunPriorityCtx with tracer

func (*Conveyor) RunRes

func (c *Conveyor) RunRes(data interface{}, priority int) (interface{}, error)

RunRes creates the new item over interface and sends to conveyor and returns result.

func (*Conveyor) RunResCtx

func (c *Conveyor) RunResCtx(ctx context.Context, data interface{}, priority int) (interface{}, error)

RunResCtx is a variety of RunRes with context

func (*Conveyor) RunResTrace

func (c *Conveyor) RunResTrace(ctx context.Context, tr faces.ITrace, data interface{}, priority int) (interface{}, error)

RunResTrace is a variety of RunPriorityCtx with tracer

func (*Conveyor) RunTrace

func (c *Conveyor) RunTrace(ctx context.Context, tr faces.ITrace, data interface{})

RunTrace is a variety of RunCtx with tracer If priority queue is used the default priority will be set up.

func (*Conveyor) SetDefaultPriority

func (c *Conveyor) SetDefaultPriority(defaultPriority int)

SetDefaultPriority sets the priority of items.

It makes sense if priority queue is used. If priority is not set up it equals the 0 (defaultPriority constant)

func (*Conveyor) SetMasterNode

func (c *Conveyor) SetMasterNode(addr string, masterNodePeriod time.Duration)

SetMasterNode sets the internet address master node. Master node allow to get information online about current conveyor see more information github.com/iostrovok/conveyormaster

func (*Conveyor) SetName

func (c *Conveyor) SetName(name string) faces.IConveyor

SetName is a simple setter for name property

func (*Conveyor) SetTracer

func (c *Conveyor) SetTracer(tr faces.ITrace) faces.IConveyor

SetTracer sets up the tracer with ITrace interface

func (*Conveyor) SetWorkersCounter

func (c *Conveyor) SetWorkersCounter(wc faces.IWorkersCounter) faces.IConveyor

SetWorkersCounter sets up the tracer with IWorkersCounter interface WorkersCounter rules the number of current worked handlers.

func (*Conveyor) Start

func (c *Conveyor) Start(ctx context.Context) error

Start starts the conveyor

func (*Conveyor) Statistic

func (c *Conveyor) Statistic() *nodes.SlaveNodeInfoRequest

Statistic returns the information about current stage of conveyor.

func (*Conveyor) Stop

func (c *Conveyor) Stop()

Stop stops the conveyor. Processing of items will be interrupted.

func (*Conveyor) WaitAndStop

func (c *Conveyor) WaitAndStop()

WaitAndStop waits while all handler are finished and exits. Processing of items will not be interrupted.

Directories

Path Synopsis
Just for fun - simple script which grabs documentation from "godoc" local server
Just for fun - simple script which grabs documentation from "godoc" local server
example
mmock
Package mmock is a generated GoMock package.
Package mmock is a generated GoMock package.
Internal package.
Internal package.
Package realizes the IItem interface.
Package realizes the IItem interface.
protobuf
Package supports the IChan interface and provides 3 simples realization of them.
Package supports the IChan interface and provides 3 simples realization of them.
priorityqueue
The package support the priority queue for using them in conveyor.
The package support the priority queue for using them in conveyor.
stack
The package support the stack queue LIFO (or FILO) for using them in conveyor.
The package support the stack queue LIFO (or FILO) for using them in conveyor.
std
The package support queue with standard GO-channels for using them in conveyor.
The package support queue with standard GO-channels for using them in conveyor.
The package support the slave mode and sends statistic to master node.
The package support the slave mode and sends statistic to master node.
Package supports the simple realization of ITrace.
Package supports the simple realization of ITrace.
Internal package.
Internal package.
WorkersCounter rules the number of current worked handlers.
WorkersCounter rules the number of current worked handlers.

Jump to

Keyboard shortcuts

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