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

Please provide an easy way to delegate Executor #3739

Open
joshtriplett opened this issue Feb 13, 2025 · 0 comments
Open

Please provide an easy way to delegate Executor #3739

joshtriplett opened this issue Feb 13, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@joshtriplett
Copy link
Contributor

I have found these related issues/pull requests

(none)

Description

I've found it useful to have a wrapper around a Pool, to distinguish between specific kinds of database connections (e.g. a user DB vs a global DB). I'd find my wrappers even more convenient to use if they implemented Executor. However, delegating Executor correctly requires implementing many methods with complex signatures (including a hidden method).

Prefered solution

I'd love to have some convenient way to delegate Executor to a field. I can see two straightforward ways to do this:

  • A derive(Executor) macro, which has an #[executor] attribute identifying the field to delegate to.
  • Something like an IntoExecutor trait, to be accepted by methods like execute instead of Executor, which has a single method that returns the trait. This would be simpler in some ways, but requires changing the signature of those methods. That should be a compatible change and shouldn't break any existing code.

Is this a breaking change? Why or why not?

The derive(Executor) approach is not breaking.

The IntoExecutor approach requires an API change but that API change should be compatible with existing code, and is unlikely to be breaking.

@joshtriplett joshtriplett added the enhancement New feature or request label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant