mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Remove reprocess channel (#7437)
Partially https://github.com/sigp/lighthouse/issues/6291 This PR removes the reprocess event channel from being externally exposed. All work events are now sent through the single `BeaconProcessorSend` channel. I've introduced a new `Work::Reprocess` enum variant which we then use to schedule jobs for reprocess. I've also created a new scheduler module which will eventually house the different scheduler impls. This is all needed as an initial step to generalize the beacon processor A "full" implementation for the generalized beacon processor can be found here https://github.com/sigp/lighthouse/pull/6448 I'm going to try to break up the full implementation into smaller PR's so it can actually be reviewed
This commit is contained in:
@@ -30,6 +30,7 @@ impl Priority {
|
||||
}
|
||||
|
||||
/// Spawns tasks on the `BeaconProcessor` or directly on the tokio executor.
|
||||
#[derive(Clone)]
|
||||
pub struct TaskSpawner<E: EthSpec> {
|
||||
/// Used to send tasks to the `BeaconProcessor`. The tokio executor will be
|
||||
/// used if this is `None`.
|
||||
@@ -155,6 +156,32 @@ impl<E: EthSpec> TaskSpawner<E> {
|
||||
.and_then(|x| x)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_send(&self, work_event: WorkEvent<E>) -> Result<(), warp::Rejection> {
|
||||
if let Some(beacon_processor_send) = &self.beacon_processor_send {
|
||||
let error_message = match beacon_processor_send.try_send(work_event) {
|
||||
Ok(()) => None,
|
||||
Err(TrySendError::Full(_)) => {
|
||||
Some("The task was dropped. The server is overloaded.")
|
||||
}
|
||||
Err(TrySendError::Closed(_)) => {
|
||||
Some("The task was dropped. The server is shutting down.")
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(error_message) = error_message {
|
||||
return Err(warp_utils::reject::custom_server_error(
|
||||
error_message.to_string(),
|
||||
));
|
||||
};
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
Err(warp_utils::reject::custom_server_error(
|
||||
"The beacon processor is unavailable".to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Send a task to the beacon processor and await execution.
|
||||
|
||||
Reference in New Issue
Block a user