-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic.go
More file actions
52 lines (41 loc) · 950 Bytes
/
Copy pathbasic.go
File metadata and controls
52 lines (41 loc) · 950 Bytes
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
43
44
45
46
47
48
49
50
51
52
package workmanager
import (
"context"
)
// WorkerName worker name
type WorkerName string
// WorkStep work step
type WorkStep string
// Worker a worker
type Worker interface {
// WithContext set worker context
WithContext(context.Context) Worker
// Work worker do work
Work(targets ...WorkTarget) (results []WorkTarget, err error)
}
// Cacher work target cache
type Cacher interface {
// Allow to continue next steps when return true, abort step runner when return false
Allow(tgt WorkTarget) bool
}
// WorkerConfig worker configure
type WorkerConfig interface {
Args() map[string]any
Active() bool
}
// WorkTarget target/result
type WorkTarget interface {
// Token return target belong to which task
Token() string
// Key return target unique key
Key() string
}
// WorkTask work task
type WorkTask interface {
Cancel() error
Finish() error
IsCanceled() bool
IsFinished() bool
Token() string
Context() context.Context
}