-
Notifications
You must be signed in to change notification settings - Fork 7
/
taskor.go
42 lines (37 loc) · 1.18 KB
/
taskor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package taskor
import (
"github.com/scaleway/taskor/handler"
"github.com/scaleway/taskor/log"
"github.com/scaleway/taskor/runner"
"github.com/scaleway/taskor/serializer"
"github.com/scaleway/taskor/task"
)
// TaskManager Interface to communicate with client
type TaskManager interface {
// Send a new task in queue
Send(task *task.Task) error
// Add a new task definition to be handle by worker
Handle(Definition *task.Definition) error
// Get all task definition that be handle
GetHandled() []*task.Definition
// Start to execute task in queue
RunWorker() error
// Stop worker
StopWorker()
// GetMetrics return current metric
GetMetrics() handler.Metric
// IsRunnerReady checks that the runner connection and channel are set
IsRunnerReady() error
}
// New create a new Taskor instance
func New(runner runner.Runner) (TaskManager, error) {
return NewWithSerializer(runner, serializer.TypeJSON)
}
func NewWithSerializer(runner runner.Runner, serializerType serializer.Type) (TaskManager, error) {
log.Debug("Starting")
return handler.NewWithSerializer(runner, serializerType)
}
// SetLogger - change current logger
func SetLogger(newLogger log.Logger) {
log.SetLogger(newLogger)
}