Documentation ¶
Index ¶
- Variables
- func GetWorkerTeam(v interface{}) string
- func InitOverseers() error
- func NewWorkerNotFounderError(id string) error
- func OnStart(f func())
- func OnStop(f func())
- func Reset()
- func ResetTranning()
- func Start()
- func Stop()
- func TrainWorkers() error
- type Config
- type Dummy
- type Outsourced
- type Overseer
- type OverseerTranning
- type PlainOverseer
- func (o *PlainOverseer) Command(worker *Worker, cmd []byte) (interface{}, error)
- func (o *PlainOverseer) Evaluate(worker *Worker) (interface{}, error)
- func (o *PlainOverseer) EvaluationReport(worker *Worker) (string, error)
- func (o *PlainOverseer) ID() string
- func (o *PlainOverseer) Init(tranning *OverseerTranning) error
- func (o *PlainOverseer) Introduction() string
- func (o *PlainOverseer) Muted() bool
- func (o *PlainOverseer) Outsource(outsourced *Outsourced) error
- func (o *PlainOverseer) Team() string
- func (o *PlainOverseer) Train(workers []*Worker) error
- func (o *PlainOverseer) WithCommandFunc(f func(worker *Worker, cmd []byte) (interface{}, error)) *PlainOverseer
- func (o *PlainOverseer) WithEvaluateFunc(f func(worker *Worker) (interface{}, error)) *PlainOverseer
- func (o *PlainOverseer) WithEvaluationReportFunc(f func(worker *Worker) (string, error)) *PlainOverseer
- func (o *PlainOverseer) WithInitFunc(f func(*OverseerTranning) error) *PlainOverseer
- func (o *PlainOverseer) WithIntroduction(intro string) *PlainOverseer
- func (o *PlainOverseer) WithMuted(muted bool) *PlainOverseer
- func (o *PlainOverseer) WithOutsourceFunc(f func(outsourced *Outsourced) error) *PlainOverseer
- func (o *PlainOverseer) WithTrainFunc(f func([]*Worker) error) *PlainOverseer
- type Tranning
- type Worker
Constants ¶
This section is empty.
Variables ¶
var Debug bool
Debug debug mode
var DummyTeam = GetWorkerTeam(NewDummyWorker())
DummyTeam dummy team
var ErrUnknownCommand = errors.New("worker:unknow command")
ErrUnknownCommand error raised if given command is unknown.
var ErrWorkerNotFound = errors.New("worker not found")
var OutsourcedPrefix = "outsourced-"
Functions ¶
func GetWorkerTeam ¶
func GetWorkerTeam(v interface{}) string
GetWorkerTeam get team of given worker
func ResetTranning ¶
func ResetTranning()
ResetTranning reset worker trannings and overseer trannings
Types ¶
type Config ¶
type Config struct { Overseers []*OverseerTranning Workers []*Tranning Outsourced []*Outsourced }
Config config struct
type Outsourced ¶
type Overseer ¶
type Overseer interface { //Team overseer team Team() string //Introduction overseer introduction. Introduction() string //Train init given workers Train(workers []*Worker) error //Muted is overseer muted. Muted() bool //Evaluate evaluate given worker. //Return data and any error if raised Evaluate(*Worker) (interface{}, error) //EvaluationReport create evaluation report by given worker . //Return plain report and any error if raised EvaluationReport(*Worker) (string, error) //Command exec command on given workder. //Return data and any error if raised. Command(*Worker, []byte) (interface{}, error) //Outsource create worker by outsourced config. Outsource(*Outsourced) error //ID overseer id. ID() string //Init init overseer Init(*OverseerTranning) error }
Overseer overseet interface
type OverseerTranning ¶
type OverseerTranning struct { ID string TranningPlan func(v interface{}) error `config:", lazyload"` }
OverseerTranning overseer config struct
type PlainOverseer ¶
type PlainOverseer struct {
// contains filtered or unexported fields
}
PlainOverseer plain oversser struct
func NewOrverseer ¶
func NewOrverseer(id string, v interface{}) *PlainOverseer
NewOrverseer create new overseer with given id and team
func (*PlainOverseer) Command ¶
func (o *PlainOverseer) Command(worker *Worker, cmd []byte) (interface{}, error)
Command exec command on given workder. Return data and any error if raised.
func (*PlainOverseer) Evaluate ¶
func (o *PlainOverseer) Evaluate(worker *Worker) (interface{}, error)
Evaluate evaluate given worker. Return data and any error if raised
func (*PlainOverseer) EvaluationReport ¶
func (o *PlainOverseer) EvaluationReport(worker *Worker) (string, error)
EvaluationReport create evaluation report by given worker. Return plain report and any error if raised
func (*PlainOverseer) Init ¶
func (o *PlainOverseer) Init(tranning *OverseerTranning) error
Init init overseer
func (*PlainOverseer) Introduction ¶
func (o *PlainOverseer) Introduction() string
Introduction overseer introduction.
func (*PlainOverseer) Outsource ¶
func (o *PlainOverseer) Outsource(outsourced *Outsourced) error
Outsource create worker by outsourced config.
func (*PlainOverseer) Train ¶
func (o *PlainOverseer) Train(workers []*Worker) error
Train init given workers
func (*PlainOverseer) WithCommandFunc ¶
func (o *PlainOverseer) WithCommandFunc(f func(worker *Worker, cmd []byte) (interface{}, error)) *PlainOverseer
WithCommandFunc set overseer command function. Return overseer self
func (*PlainOverseer) WithEvaluateFunc ¶
func (o *PlainOverseer) WithEvaluateFunc(f func(worker *Worker) (interface{}, error)) *PlainOverseer
WithEvaluateFunc set overseer evalutate function. Reutrn overseer self.
func (*PlainOverseer) WithEvaluationReportFunc ¶
func (o *PlainOverseer) WithEvaluationReportFunc(f func(worker *Worker) (string, error)) *PlainOverseer
WithEvaluationReportFunc set overseer evalution report function. Return overseer self.
func (*PlainOverseer) WithInitFunc ¶
func (o *PlainOverseer) WithInitFunc(f func(*OverseerTranning) error) *PlainOverseer
WithInitFunc set overseer init func. return overseer self.
func (*PlainOverseer) WithIntroduction ¶
func (o *PlainOverseer) WithIntroduction(intro string) *PlainOverseer
WithIntroduction set overseer introduction. Reutrn overseer itself.
func (*PlainOverseer) WithMuted ¶
func (o *PlainOverseer) WithMuted(muted bool) *PlainOverseer
WithMuted set over muted Return overseer itself.
func (*PlainOverseer) WithOutsourceFunc ¶
func (o *PlainOverseer) WithOutsourceFunc(f func(outsourced *Outsourced) error) *PlainOverseer
WithOutsourceFunc set overseer outsource function. Return overseer self
func (*PlainOverseer) WithTrainFunc ¶
func (o *PlainOverseer) WithTrainFunc(f func([]*Worker) error) *PlainOverseer
WithTrainFunc set overseer train func. return overseer self.
type Tranning ¶
Tranning worker config struct
func GetTranning ¶
GetTranning get worker tranning by given worker id.
type Worker ¶
type Worker struct { Name string Team string Interface interface{} // contains filtered or unexported fields }
Worker worker strut
func FindWorker ¶
func FindWorkerInTeam ¶
FindWorkerInTeam find worker by given type and name.
func (*Worker) Introduction ¶
Introduction return workder introduction
func (*Worker) WithIntroduction ¶
WithIntroduction set workder introduction. Return workder self.