-
Notifications
You must be signed in to change notification settings - Fork 268
Conversation
- Wrap signal senders in Option rather than initializing with broken channels - Add Signal struct with Internal variant - Emit Signal::Internal for most Actions (all but InitApplication) - Test for said emitting - Adds utility for replacing history.len() checks with a signal receiver
98fd131
to
45027bf
Compare
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.
Nice work! This is great stuff. Approved but I would like to see the printlns removed...
container/src/main.rs
Outdated
@@ -72,7 +72,11 @@ fn bootstrap_from_config(path: &str) -> Result<Container, HolochainError> { | |||
config | |||
.check_consistency() | |||
.map_err(|string| HolochainError::ConfigError(string))?; | |||
Container::try_from(&config) | |||
let mut container = Container::from_config(config).with_signal_handler(|sig| { | |||
println!("WE GET SIGNAL:\n{:?}", sig); |
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.
not sure I like the println here. I think this should be moved into a bonafide test.
container_api/src/container.rs
Outdated
}); | ||
self.signal_thread = Some(signal_thread); | ||
} else { | ||
println!("Warning: no signal handler was set!"); |
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.
println also, perhaps this function should return a Result?
container_api/src/container.rs
Outdated
// @NB: if the Instance constructor ever changes such that it can accept a SyncSender rather than | ||
// spitting out a Receiver, we can just clone that Sender instead of gathering the receivers | ||
let signal_rx = combine_receivers(signal_rxs); | ||
self.spawn_signal_thread(signal_rx); |
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.
if spawn_signal_thread returns a Result then this could just have a ?
// @NB: these three getters smell bad because previously Instance and Context had SyncSenders | ||
// rather than Option<SyncSenders>, but these would be initialized by default to broken channels | ||
// which would panic if `send` was called upon them. These `expect`s just bring more visibility to | ||
// that potential failure mode. |
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.
nice!
I realized that specifying a signal handler in the container is a bit overkill. It's far simpler to set up a channel outside the I would appreciate a look at the new changes @zippy and @lucksus. |
Codecov Report
@@ Coverage Diff @@
## develop #732 +/- ##
===========================================
+ Coverage 72.37% 72.67% +0.31%
===========================================
Files 146 147 +1
Lines 4947 5005 +58
===========================================
+ Hits 3580 3637 +57
- Misses 1367 1368 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #732 +/- ##
==========================================
+ Coverage 72.64% 72.94% +0.3%
==========================================
Files 145 146 +1
Lines 4922 4980 +58
==========================================
+ Hits 3575 3632 +57
- Misses 1347 1348 +1
Continue to review full report at Codecov.
|
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 good :)
I started refactoring Context
and adding a builder. I should base my stuff off of this. Either we merge this soon or I will just merge this into my branch...
I'm mildly in favor of just merging this before we figure out the windows problem and adding it to the list. However I did notice something weird. Look at line 848 of https://travis-ci.com/holochain/holochain-rust/jobs/165253486 why are there those compiler warnings? I don't see them when I run holochain-cmd tests locally. |
Instance
andContext
signal senders inOption
rather than initializing with broken channelsSignal::Internal
for most Actions (all but InitApplication)