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 getting connection pools for an event loop in clients #109

Open
wfltaylor opened this issue May 8, 2022 · 10 comments
Open

Allow getting connection pools for an event loop in clients #109

wfltaylor opened this issue May 8, 2022 · 10 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@wfltaylor
Copy link

Is your feature request related to a problem? Please describe.
It would be useful to be able to get the RedisConnectionPool for an EventLoop. For example, one may want to extend QueueContext with a Redis property, to allow using Redis from Vapor Jobs.

Describe the solution you'd like
The method pool(eventLoop:) in Application.Redis could be made public.

Describe alternatives you've considered
This library could extend each type that could make use of Redis.

@wfltaylor wfltaylor added the enhancement New feature or request label May 8, 2022
@Mordil
Copy link
Member

Mordil commented May 8, 2022

@wfltaylor Do you have a concrete example use case of what you’re trying to do in which the current API doesn’t allow?

Most of the API surface exposes limited access for a reason - either abstraction from a specific database engine, or to limit the chance of having bad state.

@Mordil Mordil added the question Further information is requested label May 8, 2022
@wfltaylor
Copy link
Author

wfltaylor commented May 8, 2022

I am trying to extend QueueContext from Vapor Queues with a redis property that uses the correct event loop, similar to how Request is extended from within this library.

@Mordil
Copy link
Member

Mordil commented May 8, 2022

To do what exactly? To have access to Redis for executing commands as part of the job’s process?

This might be more of a feature request for Queues more specifically

@wfltaylor
Copy link
Author

To have access to Redis for executing commands as part of the job’s process?

Yes exactly - I need to be able to read and write to Redis during the execution of the job.

@Mordil Mordil transferred this issue from vapor/redis May 9, 2022
@jdmcd
Copy link
Member

jdmcd commented May 9, 2022

@wfltaylor you should be able to get to it from context.application.redis. Let me know if that solves it for you

@wfltaylor
Copy link
Author

@wfltaylor you should be able to get to it from context.application.redis. Let me know if that solves it for you

Is this safe, as this instance isn't for the jobs event loop?

@jdmcd
Copy link
Member

jdmcd commented May 9, 2022

@wfltaylor good point, in that case I guess it depends on whether or not you are running the queue in a single event loop. If not then yeah that probably isn't safe.

@wfltaylor
Copy link
Author

@wfltaylor good point, in that case I guess it depends on whether or not you are running the queue in a single event loop. If not then yeah that probably isn't safe.

That's possible, so do you know of any way to get Redis with the correct event loop? This is done by the Redis library for requests, but I haven't been able to figure out a way to do this without using inaccessible methods.

@jdmcd
Copy link
Member

jdmcd commented May 9, 2022

Nope I would agree with you @wfltaylor, the pool method would need to be made public. The same would be true even if the queues library were to implement a property ourselves (although it would have to be on the queues-redis-driver package since queues itself has no knowledge of Redis)

@Mordil
Copy link
Member

Mordil commented May 9, 2022

I moved this here as it makes sense to me that a job should be given the underlying driver client for the provided event loop as part of the context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants