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

Allow futures on Serve and Stub to be Send #448

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ShaneMurphy2
Copy link
Contributor

Not sure if this approach is the right one, so this MR is a draft.

@tikue
Copy link
Collaborator

tikue commented Apr 12, 2024

Sorry for the delay in reviewing! Will try to look in the next week.

@tikue tikue marked this pull request as ready for review April 24, 2024 05:37
Copy link
Collaborator

@tikue tikue left a comment

Choose a reason for hiding this comment

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

This looks like a reasonable change to me. Doesn't Serve need to be made a trait variant, too? Also, could you add some tests demonstrating how it will work for users?

@@ -66,6 +68,27 @@ impl Config {
}
}

/// A [`Stub`] implementation that simply warps a `Serve`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: typo

Suggested change
/// A [`Stub`] implementation that simply warps a `Serve`.
/// A [`Stub`] implementation that simply wraps a `Serve`.

@@ -66,6 +68,27 @@ impl Config {
}
}

/// A [`Stub`] implementation that simply warps a `Serve`.
pub struct ServeStub<S> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe keep this type private for now and return an imp Stub? Can always make it public later if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea

@ShaneMurphy2
Copy link
Contributor Author

This looks like a reasonable change to me.

Perfect, that's what I was looking for by putting up an early draft.

Doesn't Serve need to be made a trait variant, too?

Probably, was just focusing on my use case a little too much 😅

Also, could you add some tests demonstrating how it will work for users?

Will do, as I mentioned this is an early draft to make sure the change makes sense.

@ShaneMurphy2
Copy link
Contributor Author

I'll get back to this in a day or so, thanks for the review!

@ShaneMurphy2
Copy link
Contributor Author

Haven't forgotten, just wrapped up in other stuff. I'll try to get to it soon!

@ShaneMurphy2
Copy link
Contributor Author

Looks like trait_variant::make doesn't support default implementations in trait definitions. I could update the macro in that crate, thoughts?

Also, how do you feel about renaming Serve and Stub to LocalServe and LocalStub so that the "default" type is Send, seems like the more common use case potentially.

@ShaneMurphy2
Copy link
Contributor Author

I've given it some more thought and I'm wondering if the right move is to instead have a feature flag that annotates all traits with async methods in them with async_trait. Thoughts @tikue?

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.

None yet

2 participants