Skip to content
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

feat(exex): subscribe to notifications explicitly #10573

Merged
merged 31 commits into from
Sep 6, 2024

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented Aug 27, 2024

Towards #10571. Implements a new way to subscribe to notifications.

This is not a breaking change, so it will not require any changes to existing ExExes, but the use of ExExNotifications::recv() is discouraged now

#[deprecated(
note = "use `ExExNotifications::poll_next` and its `Stream` implementation instead"
)]
pub async fn recv(&mut self) -> Option<ExExNotification> {

Later, when we add an ability to subscribe with the given head, it will not be a breaking change too and users will just need to do ctx.notifications.with_head(head) instead of using ctx.notifications directly.

The functionality of ExExNotificationsWithHead does not include the backfill logic yet.

@shekhirin shekhirin added C-enhancement New feature or request A-exex Execution Extensions labels Aug 27, 2024
@shekhirin shekhirin force-pushed the alexey/exexcontext-notifications-subscribe branch from c4d7798 to eae2985 Compare August 28, 2024 11:34
@shekhirin shekhirin force-pushed the alexey/exexcontext-notifications-subscribe branch from 379ca8f to 467456b Compare August 28, 2024 13:59
@shekhirin shekhirin force-pushed the alexey/exexcontext-notifications-subscribe branch from 467456b to aff910e Compare August 28, 2024 14:00
@shekhirin shekhirin force-pushed the alexey/exexcontext-notifications-subscribe branch from 6e69df2 to 342b15f Compare August 28, 2024 15:07
@shekhirin shekhirin marked this pull request as ready for review August 29, 2024 09:06
@shekhirin shekhirin marked this pull request as draft September 3, 2024 07:50

/// Subscribe to notifications.
pub fn subscribe(&mut self) -> ExExNotifications<'_> {
ExExNotifications::Left(ExExNotificationsWithoutHead(&mut self.notifications))
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we wrapping this here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mpsc::Receiver doesn't implement Stream by default. https://docs.rs/tokio-stream/0.1.15/tokio_stream/wrappers/struct.ReceiverStream.html exists for this, but I didn't want to import a new dep just for that

Copy link
Collaborator

Choose a reason for hiding this comment

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

using either here is a bit weird, I'd prefer a custom type over this

crates/exex/types/src/head.rs Outdated Show resolved Hide resolved
crates/exex/exex/src/manager.rs Outdated Show resolved Hide resolved
crates/exex/exex/src/context.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

still have some questions about the borrow

for backfill, does the user need to provide the components with the head?

crates/exex/exex/src/manager.rs Outdated Show resolved Hide resolved
crates/exex/types/src/head.rs Show resolved Hide resolved

/// Subscribe to notifications.
pub fn subscribe(&mut self) -> ExExNotifications<'_> {
ExExNotifications::Left(ExExNotificationsWithoutHead(&mut self.notifications))
Copy link
Collaborator

Choose a reason for hiding this comment

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

using either here is a bit weird, I'd prefer a custom type over this

@shekhirin
Copy link
Collaborator Author

shekhirin commented Sep 5, 2024

for backfill, does the user need to provide the components with the head?

no, I don't think so. Components are the same for all ExExes, so we should just pass them to the ExExManager when initializing it

@mattsse
Copy link
Collaborator

mattsse commented Sep 5, 2024

so we should just pass them to the ExExManager when initializing it

why does it need that?

@shekhirin shekhirin force-pushed the alexey/exexcontext-notifications-subscribe branch from 942b1da to 5d0385a Compare September 5, 2024 16:22
@shekhirin shekhirin force-pushed the alexey/exexcontext-notifications-subscribe branch from ed5c1a8 to e6d1d4c Compare September 6, 2024 08:56
@shekhirin shekhirin force-pushed the alexey/exexcontext-notifications-subscribe branch from e6d1d4c to d357e2d Compare September 6, 2024 08:58
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

cool

@mattsse mattsse added S-breaking This PR includes a breaking change M-changelog This change should be included in the changelog and removed S-breaking This PR includes a breaking change labels Sep 6, 2024
@shekhirin shekhirin added the S-blocked This cannot more forward until something else changes label Sep 6, 2024
@shekhirin
Copy link
Collaborator Author

shekhirin commented Sep 6, 2024

@shekhirin shekhirin force-pushed the alexey/exexcontext-notifications-subscribe branch from c25d0dc to 291929c Compare September 6, 2024 11:14
@shekhirin shekhirin added this pull request to the merge queue Sep 6, 2024
Merged via the queue into main with commit a89de21 Sep 6, 2024
35 checks passed
@shekhirin shekhirin deleted the alexey/exexcontext-notifications-subscribe branch September 6, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exex Execution Extensions C-enhancement New feature or request M-changelog This change should be included in the changelog S-blocked This cannot more forward until something else changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants