Documentation ¶
Index ¶
- func Available() []string
- func RegisterWorker(constructor WorkerConstructor)
- type Executor
- func (exec *Executor) AddFormatter(category string, fmt formatter.Formatter) *Executor
- func (exec *Executor) HostCount() int
- func (exec *Executor) Run() (failed int, err error)
- func (exec *Executor) SetHostInfoList(list hostlist.HostInfoList) *Executor
- func (exec *Executor) SetHostlist(list []string) *Executor
- func (exec *Executor) SetTransfer(src, dst string) *Executor
- func (exec *Executor) SetTransferHook(before, after string) *Executor
- type Parameter
- type TransferFile
- type Worker
- type WorkerConstructor
- type WorkerWithRecommendedConcurrency
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterWorker ¶
func RegisterWorker(constructor WorkerConstructor)
RegisterWorker used for plugins to register new Worker
Types ¶
type Executor ¶
type Executor struct { Parameter *Parameter // contains filtered or unexported fields }
Executor is a singleton class. Holds meta info for worker.
func NewExecutor ¶
NewExecutor returns an empty Executor
func (*Executor) AddFormatter ¶
AddFormatter adds formatter into a hash. Formatters are devided into categories, and each category can hold only one Formatter. Obviously, the key for hash is `category`.
func (*Executor) SetHostInfoList ¶
func (exec *Executor) SetHostInfoList(list hostlist.HostInfoList) *Executor
SetHostInfoList is extended version of SetHostlist. Executor will adjust it at the beginning of Run, which would set correct User & Cmd.
func (*Executor) SetHostlist ¶
SetHostlist sets hostlist for execution, without check or modification. DEPRECATED
func (*Executor) SetTransfer ¶
SetTransfer sets source(local) and destination(remote) for file copy.
func (*Executor) SetTransferHook ¶
SetTransferHook sets a hook, which would be executed before and after, for the file copying.
type Parameter ¶
type Parameter struct { Cmd string User string Passwd string Script string Account string Method string Retry int Concurrency int64 Hostlist []string HostInfoList hostlist.HostInfoList Timeout int64 Transfer *TransferFile }
Parameter holds data for worker
func (*Parameter) NeedTransferFile ¶
NeedTransferFile returns whether Worker should handle file copying.
func (*Parameter) WrapCmdWithHook ¶
WrapCmdWithHook returns wrapped cmd, e.g. add `-a` and `-b` args
type TransferFile ¶
type TransferFile struct { Data []byte Perm string Basename string Destination string // Destination DIRECTORY Src string // Final Destination, Destination/Basename Dst string // contains filtered or unexported fields }
TransferFile describes file information that should be transferred.
type Worker ¶
type Worker interface { Init(*Parameter) error Name() string Execute(done <-chan struct{}) (<-chan *formatter.Output, <-chan error) }
Worker should able to 1. execute cmd string 2. copy file (from *Executor.transferFile)
type WorkerConstructor ¶
type WorkerConstructor func() Worker
WorkerConstructor is function that receives no parameter and returns Worker
type WorkerWithRecommendedConcurrency ¶
type WorkerWithRecommendedConcurrency interface { // @Return // == 0: Recommended Concurrency // < 0: Hostlist Length RecommendedConcurrency() int64 Worker }
WorkerWithRecommendedConcurrency could give its recommended concurrency