faces

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanType

type ChanType nodes.ChanType

type EmptyHandler added in v0.0.3

type EmptyHandler struct{}

EmptyHandler realizes the empty handler which do nothing. It is useful for replace empty Start and Stop methods by inherited objects.

Example:

type MySimpleHandler struct {
   EmptyHandler
}

func Handler(_ faces.Name) (faces.IHandler, error) {
	return &MySimpleHandler{}, nil
}

func (m *MySimpleHandler) Run(item faces.IItem) error {s
	// do something here
	return nil
}

func (*EmptyHandler) Run added in v0.0.3

func (m *EmptyHandler) Run(_ IItem) error

Run does nothing

func (*EmptyHandler) Start added in v0.0.3

func (m *EmptyHandler) Start(_ context.Context) error

Start does nothing

func (*EmptyHandler) Stop added in v0.0.3

func (m *EmptyHandler) Stop()

Stop does nothing

type GiveBirth

type GiveBirth func(name Name) (IHandler, error)

GiveBirth return new handler. Type Name is string which was passed with AddHandler(...)

var MakeEmptyHandler GiveBirth = func(name Name) (IHandler, error) {
	return &EmptyHandler{}, nil
}

type IChan

type IChan interface {
	// Return
	ChanIn() MainCh
	ChanOut() MainCh
	Push(IItem)

	Close()
	IsActive() bool
	Count() int
	Len() int
	Info() *nodes.ChanData
}

type IConveyor

type IConveyor interface {
	Start(ctx context.Context) error
	Stop()
	WaitAndStop()

	// simple pushing
	Run(IInput)
	RunRes(IInput) (interface{}, error)

	SetDefaultPriority(defaultPriority int)
	GetDefaultPriority() int

	SetName(name string) IConveyor
	GetName() string

	SetWorkersCounter(wc IWorkersCounter) IConveyor
	AddHandler(manageName Name, minCount, maxCount int, handler GiveBirth) error
	AddErrorHandler(manageName Name, minCount, maxCount int, handler GiveBirth) error
	AddFinalHandler(manageName Name, minCount, maxCount int, handler GiveBirth) error
	Statistic() *nodes.SlaveNodeInfoRequest
	SetTracer(tr ITrace, duration time.Duration) IConveyor

	// The period between metric evaluations.
	// By default 10 second
	MetricPeriod(duration time.Duration) IConveyor

	// Master node is single node for control the conveyor
	SetMasterNode(addr string, masterNodePeriod time.Duration)

	DefaultPriority() int
}

type IHandler

type IHandler interface {
	// Start() function is called one time for each handler right after it's created with GiveBirth().
	Start(ctx context.Context) error

	// Run() function is called for processing single item.
	Run(item IItem) error

	// Stop() function is called before destruction of handler.
	Stop()
}

type IInput added in v0.0.9

type IInput interface {
	Context(ctx context.Context) IInput // by default the context.Background()
	Trace(tr ITrace) IInput             // nil is by default
	Data(data interface{}) IInput       // nil is by default
	Priority(priority int) IInput       // by default is IConveyor.DefaultPriority()
	SkipToName(name Name) IInput        // by default is ""

	// return all data above
	Values() (ctx context.Context, tr ITrace, data interface{}, priority *int, name Name)
}

type IItem

type IItem interface {
	GetID() int64
	SetID(id int64) IItem

	Get() (data interface{})
	Set(data interface{}) IItem

	GetContext() context.Context

	AddError(err error)
	GetError() error
	CleanError()

	SetSkipToName(label Name)
	GetSkipToName() Name
	NeedToSkip(worker IWorker) (bool, error)

	LogTraceFinishTime(format string, a ...interface{})
	LogTrace(format string, a ...interface{})

	Start() IItem
	Cancel()
	Finish()

	// >>>>>>> Priority Queue Supports
	GetPriority() int
	SetPriority(priority int) IItem

	SetHandlerError(handlerNameWithError Name) IItem
	GetHandlerError() Name

	SetLastHandler(handlerName Name) IItem
	GetLastHandler() Name
}

type IManager

type IManager interface {
	SetHandler(handler GiveBirth) IManager

	Start(ctx context.Context) error
	Stop()

	SetWorkersCounter(wc IWorkersCounter) IManager
	SetChanIn(in IChan) IManager
	SetChanOut(out IChan) IManager
	SetChanErr(errCh IChan) IManager

	GetNextManager() IManager
	SetNextManager(next IManager) IManager

	GetPrevManager() IManager
	SetPrevManager(previous IManager) IManager

	SetIsLast(isLast bool) IManager
	IsLast() bool

	SetWaitGroup(wg *sync.WaitGroup) IManager

	MetricPeriod(duration time.Duration) IManager

	Statistic() *nodes.ManagerData
}

type ITrace

type ITrace interface {
	// LazyPrintf evaluates its arguments with fmt.Sprintf each time the
	// /debug/requests page is rendered. Any memory referenced by a will be
	// pinned until the trace is finished and later discarded.
	LazyPrintf(format string, a ...interface{})

	// SetError declares that this trace resulted in an error.
	SetError()

	// Flush will call at the end on cycle
	Flush()

	// Flush will call at the end on cycle
	ForceFlush()
}

type IWorker

type IWorker interface {
	Start(ctx context.Context) error
	Stop()

	SetBorderCond(typ ManagerType, isLast bool)
	GetBorderCond() (Name, ManagerType, bool)

	Name() Name
	ID() string
}

type IWorkersCounter

type IWorkersCounter interface {
	Check(mc *nodes.ManagerData) (*nodes.ManagerAction, error)
}

type MainCh

type MainCh chan IItem

type ManagerType

type ManagerType string
const (
	WorkerManagerType ManagerType = "worker"
	ErrorManagerType  ManagerType = "error"
	FinalManagerType  ManagerType = "final"
)

type Name

type Name string
const EmptySkipName Name = ""
const SkipAll Name = "###SKIP_EVERYTHING_BY_THE_END"

Directories

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

Jump to

Keyboard shortcuts

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