File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
src/env/artifact/environment Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023. Smart Operating Block
3
+ *
4
+ * Use of this source code is governed by an MIT-style
5
+ * license that can be found in the LICENSE file or at
6
+ * https://opensource.org/licenses/MIT.
7
+ */
8
+
9
+ package artifact .environment ;
10
+
11
+ import application .controller .manager .EventManager ;
12
+ import cartago .Artifact ;
13
+ import cartago .INTERNAL_OPERATION ;
14
+ import cartago .OPERATION ;
15
+ import infrastructure .events .KafkaClient ;
16
+
17
+ /**
18
+ * CArtAgO artifact that is responsible to observe the operating block and expose its data.
19
+ */
20
+ public class OperatingBlockObserverArtifact extends Artifact {
21
+ private boolean working ;
22
+ private EventManager eventManager ;
23
+ /**
24
+ * Initialize the operating block observer artifact.
25
+ */
26
+ void init () {
27
+ this .working = false ;
28
+ this .eventManager = KafkaClient .getInstance ();
29
+ }
30
+
31
+ /**
32
+ * Start the Operating Block Observer.
33
+ */
34
+ @ OPERATION
35
+ void start () {
36
+ if (!working ) {
37
+ working = true ;
38
+ execInternalOp ("poll" );
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Internal artifact's operation used to polling for new events with the event manager.
44
+ */
45
+ @ INTERNAL_OPERATION
46
+ void poll () {
47
+ this .eventManager .poll (event -> {
48
+ signal ("event" , event .getKey ()); // tobe deleted
49
+ });
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments