diff options
author | Valery Piashchynski <[email protected]> | 2021-06-15 22:12:32 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-06-15 22:12:32 +0300 |
commit | d4c92e48bada7593b6fbec612a742c599de6e736 (patch) | |
tree | 53b6fb81987953b71a77ae094e579a0a7daa407c /plugins/jobs/broker.go | |
parent | 9dc98d43b0c0de3e1e1bd8fdc97c122c7c7c594f (diff) |
- Jobs plugin initial commit
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/jobs/broker.go')
-rw-r--r-- | plugins/jobs/broker.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/jobs/broker.go b/plugins/jobs/broker.go new file mode 100644 index 00000000..0066a4f1 --- /dev/null +++ b/plugins/jobs/broker.go @@ -0,0 +1,47 @@ +package jobs + +// Broker manages set of pipelines and provides ability to push jobs into them. +type Broker interface { + // Register broker pipeline. + Register(pipe *Pipeline) error + + // Consume configures pipeline to be consumed. With execPool to nil to disable pipelines. Method can be called before + // the service is started! + Consume(pipe *Pipeline, execPool chan Handler, errHandler ErrorHandler) error + + // Push job into the worker. + Push(pipe *Pipeline, j *Job) (string, error) + + // Stat must fetch statistics about given pipeline or return error. + Stat(pipe *Pipeline) (stat *Stat, err error) +} + +// EventProvider defines the ability to throw events for the broker. +type EventProvider interface { + // Listen attaches the even listener. + Listen(lsn func(event int, ctx interface{})) +} + +// Stat contains information about pipeline. +type Stat struct { + // Pipeline name. + Pipeline string + + // Broken is name of associated broker. + Broker string + + // InternalName defines internal broker specific pipeline name. + InternalName string + + // Consuming indicates that pipeline is pipelines jobs. + Consuming bool + + // testQueue defines number of pending jobs. + Queue int64 + + // Active defines number of jobs which are currently being processed. + Active int64 + + // Delayed defines number of jobs which are being processed. + Delayed int64 +} |