-
Notifications
You must be signed in to change notification settings - Fork 11
Worker & executor
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 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 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 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.