Skip to content

embedded-service/event: Break up existing Sender trait#863

Open
RobertZ2011 wants to merge 2 commits into
OpenDevicePartnership:mainfrom
RobertZ2011:update-sender-trait
Open

embedded-service/event: Break up existing Sender trait#863
RobertZ2011 wants to merge 2 commits into
OpenDevicePartnership:mainfrom
RobertZ2011:update-sender-trait

Conversation

@RobertZ2011
Copy link
Copy Markdown
Contributor

@RobertZ2011 RobertZ2011 commented May 26, 2026

Break-out non-blocking send function into NonBlockingSender trait. Introduce Immediate wrapper to distinguish receivers that can implement some sort of recovery flow if events are dropped.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::Sender into non-blocking Sender::try_send and new BlockingSender::send.
  • Introduce ImmediateEvent<E> and implement Receiver<ImmediateEvent<E>> for DynSubscriber to surface lagged-message counts.
  • Update Type-C, power-policy, and thermal services/controllers to replace .send(...).await with try_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.

Comment thread type-c-service/src/controller/mod.rs
Comment thread type-c-service/src/controller/mod.rs
Comment thread type-c-service/src/controller/mod.rs
Comment thread type-c-service/src/controller/mod.rs Outdated
Comment thread type-c-service/src/controller/power.rs
Comment thread type-c-service/src/controller/power.rs
Comment thread type-c-service/src/controller/pd.rs
Comment thread type-c-service/src/service/mod.rs
Comment thread power-policy-service/src/service/mod.rs
Comment thread embedded-service/src/event.rs
@RobertZ2011 RobertZ2011 force-pushed the update-sender-trait branch from 4c0c0b0 to 82d51c4 Compare May 26, 2026 18:16
@RobertZ2011 RobertZ2011 linked an issue May 26, 2026 that may be closed by this pull request
3 tasks
@RobertZ2011 RobertZ2011 marked this pull request as ready for review May 26, 2026 18:23
@RobertZ2011 RobertZ2011 requested review from a team as code owners May 26, 2026 18:23
@RobertZ2011
Copy link
Copy Markdown
Contributor Author

@kurtjd Let me know if this change should apply to the thermal service or if that should use the BlockingSender trait.

tullom
tullom previously approved these changes May 26, 2026
Copy link
Copy Markdown
Contributor

@tullom tullom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look good, Kurtis should sign off on this for the thermal service changes

kurtjd
kurtjd previously approved these changes May 26, 2026
Comment thread embedded-service/src/event.rs Outdated
kurtjd
kurtjd previously approved these changes May 26, 2026
@kurtjd
Copy link
Copy Markdown
Member

kurtjd commented May 26, 2026

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.
@RobertZ2011 RobertZ2011 force-pushed the update-sender-trait branch from 3dd793f to 85833b3 Compare May 26, 2026 21:22
@RobertZ2011
Copy link
Copy Markdown
Contributor Author

Fixed minor merge conflicts from rebasing.

@RobertZ2011 RobertZ2011 enabled auto-merge (squash) May 26, 2026 21:23
@RobertZ2011 RobertZ2011 requested a review from kurtjd May 26, 2026 21:23
@RobertZ2011
Copy link
Copy Markdown
Contributor Author

Was part of the motivation for this to make the NonBlockingSender dyn compatible?

Not really, the primary goal was to encode more information into the traits, particularly around behavior when a channel fills up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clean-up pass: Sender/Receiver

4 participants