forked from rexray/rexray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_services.go
88 lines (68 loc) · 2.14 KB
/
types_services.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package types
// Service is the base type for services.
type Service interface {
Driver
}
// Services is a service's container.
type Services interface {
// Storage gets the storage service.
Storage() StorageService
// Tasks gets the task service.
Tasks() TaskTrackingService
}
// TaskRunFunc is a function responsible for a task's execution.
type TaskRunFunc func(ctx Context) (interface{}, error)
// StorageTaskRunFunc is a function responsible for a storage-service task's
// execution.
type StorageTaskRunFunc func(
ctx Context,
service StorageService) (interface{}, error)
// StorageService is a service that provides the interaction with
// StorageDrivers.
type StorageService interface {
Service
// Driver returns the service's StorageDriver.
Driver() StorageDriver
// TaskEnqueue enqueues a task for execution.
TaskEnqueue(
ctx Context,
run StorageTaskRunFunc,
schema []byte) *Task
// AuthConfig returns the storage service's authentication configuration.
AuthConfig() *AuthConfig
}
// TaskTrackingService a service for tracking tasks.
type TaskTrackingService interface {
Service
// Tasks returns a channel on which all tasks tracked via TrackTasks are
// received.
Tasks() <-chan *Task
// TaskTrack creates a new, trackable task.
TaskTrack(ctx Context) *Task
// TaskEnqueue enqueues a task for execution.
TaskEnqueue(
ctx Context,
run TaskRunFunc,
schema []byte) *Task
// TaskInspect returns the task with the specified ID.
TaskInspect(taskID int) *Task
// TaskWait blocks until the specified task completes.
TaskWait(taskID int) <-chan int
// TaskWaitAll blocks until all the specified tasks complete.
TaskWaitAll(taskIDs ...int) <-chan int
// TaskWaitC returns a channel that is closed when the specified task
// completes.
TaskWaitC(taskID int) <-chan int
// TaskWaitAll returns a channel that is closed when the specified task
// completes.
TaskWaitAllC(taskIDs ...int) <-chan int
}
// TaskExecutionService is a service for executing tasks.
type TaskExecutionService interface {
Service
// TaskEnqueue enqueues a task for execution.
TaskEnqueue(
ctx Context,
run TaskRunFunc,
schema []byte) *Task
}