-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathframework_interface.go
57 lines (45 loc) · 1.87 KB
/
framework_interface.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
package meritop
import "log"
// This interface is used by application during taskgraph configuration phase.
type Bootstrap interface {
// These allow application developer to set the task configuration so framework
// implementation knows which task to invoke at each node.
SetTaskBuilder(taskBuilder TaskBuilder)
// This allow the application to specify how tasks are connection at each epoch
SetTopology(topology Topology)
// After all the configure is done, driver need to call start so that all
// nodes will get into the event loop to run the application.
Start()
}
// Note that framework can decide how update can be done, and how to serve the updatelog.
type BackedUpFramework interface {
// Ask framework to do update on this update on this task, which consists
// of one primary and some backup copies.
Update(taskID uint64, log UpdateLog)
}
// Framework hides distributed system complexity and provides users convenience of
// high level features.
type Framework interface {
// This allow the task implementation query its neighbors.
GetTopology() Topology
// Some task can inform all participating tasks to shutdown.
// If successful, all tasks will be gracefully shutdown.
// TODO: @param status
ShutdownJob()
GetLogger() *log.Logger
// This is used to figure out taskid for current node
GetTaskID() uint64
}
// Context is used in task callbacks. It provides APIs for tasks to ask framework
// to do work in certain context.
type Context interface {
// These two are useful for task to inform the framework their status change.
// metaData has to be really small, since it might be stored in etcd.
// Set meta flag to notify parent/child of the change.
FlagMetaToParent(meta string)
FlagMetaToChild(meta string)
// Some task can inform all participating tasks to new epoch
IncEpoch()
// Request data from parent or children.
DataRequest(toID uint64, meta string)
}