Skip to content

Worker & executor

Zheng Luo edited this page May 30, 2018 · 1 revision

Worker interface

Worker is an interface for workers using different ways of synchronising. Each worker corresponds to one repository. It exposes four functions. GetStatus and GetConfig returns the status and config of this worker. RunSync start a loop and waiting for start signal from channel. TriggerSync can called by manager and send a signal into channel.

NewWorker

NewWorker is a worker factory. It first checkes the type of the worker to be created according the config. Then it calles the corresponding new function and creates the corresponding worker.

Status

Status defines the struct of status of worker.

Result represents whether the sync job succeeds or not.

Idle represents whether the worker is idle.

LastFinished is the time of last successful sync

executor

executor is an abstract interface for one-shot tasks. If every sync command can be abstracted into executing one command, then you can implement a class satisfying executor interface, then use invokeExecutorWorker to wrap it into a worker.

Clone this wiki locally