Improve the events design
Opened this issue · 0 comments
This is a wide topic that should spawn several tasks.
Now we have events NewResource
, ResourceClosed
, ResorceDataChanged
and never-emitted ResourceChangePossible
.
This is not enough. But: it's super important to add only really useful events now, not "all events that maybe-one-day-could-have-some-use-and-we-thought-of-them-today".
Changes that seem reasonable to me now:
-
Remove
ResourceChangePossible
. This will be super-complex to implement and doesn't seem very useful either way. Go back to the concept if we ever decide we need it. -
Add events
ShutdownStarted
,ShutdownFinished
- this will make debugging easier (e.g. check if there was a full clean shutdown, check what happened during the shutdown and what happened just before etc). Consider alsoGolemStarted
event, but I'm not sure about this one. -
Add
BatchFinished
event. Or, as an alternative: maybe emitResourceClosed(batch)
? But this might be confusing. -
Consider splitting
NewResource
toResourceCreated
andResourceFound
("we created a new Resource object that corresponds to a Golem entity that was created before", e.g. when we first time interact with anAllocation
created in a previous run). Consider following scenario:- We register an event callback that is supposed to run whenever we create a new activity
- We create an Activity, callback is executed
- We restart the app
- We get a
DebitNote
for this activity and the callback executes again, becauseActivity
object was created (but we didn't create an activity,GolemNode
was told about a previously created activity)
We might consider event nesting here -
ResourceCreated
andResourceFound
inheriting fromNewResource
.