File tree Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Package supervisor manages running modules and takes care
2
+ // of the inter-modules communication, if required.
3
+ package supervisor
4
+
5
+ import "oracle-watchdog/internal/logger"
6
+
7
+ // Supervisor defines the interface for a process managing
8
+ // set of oracle modules with specific functionality.
9
+ type Supervisor interface {
10
+ // AddModule adds new module to the supervisor.
11
+ AddOracle (Oracle )
12
+
13
+ // Run starts the supervisor functions.
14
+ Run ()
15
+
16
+ // Terminate signals supervisor to stop all running modules
17
+ // and finish the job.
18
+ Terminate ()
19
+
20
+ // Log returns an instance of a logger to be used for log messages
21
+ // by the oracles.
22
+ Log () logger.Logger
23
+ }
24
+
25
+ // Oracle defines the interface for an oracle module supervised
26
+ // by the supervisor.
27
+ type Oracle interface {
28
+ }
Original file line number Diff line number Diff line change
1
+ // Package supervisor manages running modules and takes care
2
+ // of the inter-modules communication, if required.
3
+ package supervisor
4
+
5
+ import (
6
+ "oracle-watchdog/internal/logger"
7
+ )
8
+
9
+ // WatchdogSupervisor implements the
10
+ type WatchdogSupervisor struct {
11
+ log logger.Logger
12
+ oracles []Oracle
13
+ }
14
+
15
+ // New creates new instance of the Supervisor.
16
+ func New (log logger.Logger ) Supervisor {
17
+ // make the watchdog
18
+ ws := WatchdogSupervisor {
19
+ log : log ,
20
+ oracles : make ([]Oracle , 0 ),
21
+ }
22
+
23
+ return & ws
24
+ }
25
+
26
+ // AddModule adds new module to the supervisor.
27
+ func (ws * WatchdogSupervisor ) AddOracle (ora Oracle ) {
28
+ // supervisor must not be running already
29
+ // adding can be done in the init phase only
30
+
31
+ // add the module
32
+ ws .oracles = append (ws .oracles , ora )
33
+ }
34
+
35
+ // Run inits the supervisor modules and starts them to do their job.
36
+ func (ws * WatchdogSupervisor ) Log () logger.Logger {
37
+ return ws .log
38
+ }
39
+
40
+ // Run inits the supervisor modules and starts them to do their job.
41
+ func (ws * WatchdogSupervisor ) Run () {
42
+
43
+ }
44
+
45
+ // Terminate signals watchdog supervisor to stop all running modules
46
+ // and finish their job.
47
+ func (ws * WatchdogSupervisor ) Terminate () {
48
+
49
+ }
You can’t perform that action at this time.
0 commit comments