spaship / operator

SPAship Operator
https://spaship.io/operator/
Apache License 2.0
1 stars 2 forks source link

Internal Operator Events #59

Closed lkrzyzanek closed 3 years ago

lkrzyzanek commented 3 years ago

Let's introduce the internal events. Such events could be consumed and interpreted by other modules like Notification, Logging, Metrics etc.

Implementation could be based on reactive events: https://quarkus.io/guides/reactive-event-bus

Events

Each event needs identify the source of it:

lkrzyzanek commented 3 years ago

calling /api throws this error:

2021-06-07 10:56:54,051 DEBUG [io.spa.ope.eve.EventSourcingEngine] (executor-thread-1) >toggleEnabled after set true
2021-06-07 10:56:54,052 DEBUG [io.spa.ope.eve.EventSourcingEngine] (executor-thread-1) toggleEnabled vale is true
2021-06-07 10:56:54,053 ERROR [io.spa.ope.eve.EventSourcingEngine] (executor-thread-1) failed to parse string into json detected Failed to decode:Unrecognized token 'invoked': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"invoked /api endpoint"; line: 1, column: 8] proceeding with string format
2021-06-07 10:56:54,054 INFO  [io.spa.ope.eve.EventSourcingEngine] (executor-thread-1) sourcing message {"id":"f7fb15cb-1204-4141-b75e-8fb461fb1113","payload":"invoked /api endpoint","time":"2021-06-07T10:56:54.054015"}
arkaprovob commented 3 years ago

okay so what's happening here , you may pass a string message or a json message (as a string) to the event sourcing engine, now it will try to parse your message into json first, if it fails then it will log that along with stack trace and then treat the message as String. example if the passed message was {"type" : "json message","mark":"true"} instead of invoked /api endpoint the final output (event) would look like this {"id":"xxxx-xxx-xxx","payload":{"type" : "json message","mark":"true"} ,"time":"2021-06-07T10:56:54.054015"}. The point here is, treat the message as json if it is json otherwise the type of the attribute payload is string. We could change the ERROR to a WARN if it is confusing.

lkrzyzanek commented 3 years ago

Before closing this ticket please document events mechanism in https://github.com/spaship/operator/tree/main/docs/developer-guide

lkrzyzanek commented 3 years ago

Also please document those variables

event.sourcing.enabled=
event.logging.enabled=

in https://spaship.io/operator/operator-manual/configuration.html

arkaprovob commented 3 years ago

done, created a merge request please check.

lkrzyzanek commented 3 years ago

Great. Closing. Docs: https://spaship.io/operator/developer-guide/events.html