forked from aporeto-inc/trireme-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.go
70 lines (52 loc) · 2.31 KB
/
interfaces.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
package processor
import (
"github.com/aporeto-inc/trireme-lib/collector"
"github.com/aporeto-inc/trireme-lib/policy"
"github.com/aporeto-inc/trireme-lib/rpc/events"
)
// Config holds configuration for all monitors
type Config struct {
Collector collector.EventCollector
PUHandler ProcessingUnitsHandler
SyncHandler SynchronizationHandler
MergeTags []string
}
// A ProcessingUnitsHandler must be implemnted by the monitor instantiators or components thereof.
type ProcessingUnitsHandler interface {
// CreatePURuntime is called when a monitor detects creation of a new ProcessingUnit.
CreatePURuntime(contextID string, runtimeInfo *policy.PURuntime) error
// HandlePUEvent is called by all monitors when a PU event is generated. The implementer
// is responsible to update all components by explicitly adding a new PU.
HandlePUEvent(contextID string, event events.Event) error
}
// A SynchronizationType represents the type of synchronization job.
type SynchronizationType int
const (
// SynchronizationTypeInitial indicates the initial synchronization job.
SynchronizationTypeInitial SynchronizationType = iota + 1
// SynchronizationTypePeriodic indicates subsequent synchronization jobs.
SynchronizationTypePeriodic
)
// A SynchronizationHandler must be implemnted by the monitor instantiators or components thereof.
type SynchronizationHandler interface {
// HandleSynchronization handles a synchronization routine.
HandleSynchronization(contextID string, state events.State, RuntimeReader policy.RuntimeReader, syncType SynchronizationType) error
// HandleSynchronizationComplete is called when a synchronization job is complete.
HandleSynchronizationComplete(syncType SynchronizationType)
}
// Processor is a generic interface that processes monitor events using
// a normalized event structure.
type Processor interface {
// Start processes PU start events
Start(eventInfo *events.EventInfo) error
// Event processes PU stop events
Stop(eventInfo *events.EventInfo) error
// Create process a PU create event
Create(eventInfo *events.EventInfo) error
// Event process a PU destroy event
Destroy(eventInfo *events.EventInfo) error
// Event processes a pause event
Pause(eventInfo *events.EventInfo) error
// ReSync resyncs all PUs handled by this processor
ReSync(EventInfo *events.EventInfo) error
}