-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A0-2884: Refactor alerter #315
Conversation
Please make sure the following happened
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to construct the Handler
and use that for the simulation rather than Service
. Plus some other comments about the general architecture of this kind of split, mostly that logging should happen in the Service
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Suggestion: consider implementing a more direct approach instead of simulation
. I don't know how exactly your interactions with Handler
will look like but in general a safer approach would be a more direct interaction with it, e.g. add a new constructor to Handler
that initializes its internal state properly based on persisted state. This way it should be more safe if somebody decides to change Handler
's internals. With the simulation approach, you risk ending in some undefined
state (since it's not a full
simulation - imagine someone add some more steps to protocol, or it buffers something internally, etc.). Using directly a new constructor assures you (kind of) that the Handler is in correct state after initialization.
I think it is possible. Our goal is to obtain a handler which witnessed some events in a particular order, and a Service with some of its IO channels partially filled, also depending on the sequence of events. We can have That would be nicer indeed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exiting
thing feels wrong, I suspect it should rather be an error propagated outwards, but I really don't want to make you rewrite this again so I guess it can stay.
Refactor alerter to make it possible for synchronous simulation.
alerts
module into synchronous handler and service with a single async method (Alerter
is nowHandler
andService
contains therun
logic)Service
andHandler
before running the serviceA delicate change: changed signature of
rmc
andio
to not takekeychain
by reference but by value. This was needed becausekeychain
is now passed toService::new
where it is passed further toHandler
(oldAlerter
) andIO
. It can't be passed by reference to them because of the lifetime issues. Instead we pass clonedkeychain
to both of them by value.If we really want
keychain
to remain passed by reference we can probably implement it by usingRc
.