embedded-service/event: Break up existing Sender trait#863
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the workspace’s event API by separating non-blocking sends from blocking sends, and updates multiple services/controllers to use the new non-blocking try_send style. It also introduces an “immediate event” wrapper type to allow receivers to detect lag for immediate pubsub subscribers.
Changes:
- Split
embedded_services::event::Senderinto non-blockingSender::try_sendand newBlockingSender::send. - Introduce
ImmediateEvent<E>and implementReceiver<ImmediateEvent<E>>forDynSubscriberto surface lagged-message counts. - Update Type-C, power-policy, and thermal services/controllers to replace
.send(...).awaitwithtry_send(...)and log on failure.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/src/service/ucsi.rs | Adjust UCSI codepaths to call the now-sync broadcast without awaiting. |
| type-c-service/src/service/mod.rs | Make service broadcast non-blocking via try_send and log on failure. |
| type-c-service/src/controller/power.rs | Convert power-policy event emission to try_send and log on failure. |
| type-c-service/src/controller/pd.rs | Convert Type-C event emission for VDM/DP/Alert to try_send and log on failure. |
| type-c-service/src/controller/mod.rs | Convert port status/power-policy/loopback notifications to try_send. |
| type-c-service/src/controller/event_receiver.rs | Convert interrupt splitting forwarding to try_send and log on failure. |
| thermal-service/src/sensor.rs | Convert sensor event broadcast to non-blocking try_send. |
| thermal-service/src/fan.rs | Convert fan event broadcast to non-blocking try_send. |
| power-policy-service/src/service/provider.rs | Make post-connect/disconnect broadcast path sync/non-blocking. |
| power-policy-service/src/service/mod.rs | Make service broadcast non-blocking via try_send and log on failure. |
| power-policy-service/src/service/consumer.rs | Update consumer flows to call sync/non-blocking broadcast. |
| embedded-service/src/event.rs | Add BlockingSender, add ImmediateEvent, and adjust sender/receiver impls accordingly. |
4c0c0b0 to
82d51c4
Compare
|
@kurtjd Let me know if this change should apply to the thermal service or if that should use the |
tullom
left a comment
There was a problem hiding this comment.
Code changes look good, Kurtis should sign off on this for the thermal service changes
71fb002 to
82d51c4
Compare
41d7858 to
5de1555
Compare
|
Was part of the motivation for this to make the NonBlockingSender dyn compatible? At least, this does have the nice side effect now of making it easier to pass a heterogeneous sender list to a service without needing enum dispatch. |
Break-out blocking send function into `BlockingSender` trait. Introduce `Immediate` wrapper to distinguish receivers that can implement some sort of recovery flow if events are dropped.
5de1555 to
3dd793f
Compare
3dd793f to
85833b3
Compare
|
Fixed minor merge conflicts from rebasing. |
Not really, the primary goal was to encode more information into the traits, particularly around behavior when a channel fills up. |
Break-out non-blocking send function into
NonBlockingSendertrait. IntroduceImmediatewrapper to distinguish receivers that can implement some sort of recovery flow if events are dropped.