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 setting of Redis connection parameters #35
Conversation
…edis clients. Made kue.app a lazy-loading property so Redis connection strings can be set
looks good, thanks for sticking with the style of the project! The one thing I was thinking, since it's always kinda lame when you have to expose ad hoc apis just to tweak settings of some dependency. So I would almost prefer to just use say |
I've used several of your projects and like your coding style, so much so that I've adopted it for my projects, so keeping with the style of the project was second nature :) I thought about adding doing exactly what you suggested or even adding the |
ah :D awesome. Yeah, I don't mind how it is right now. I just find myself always adding APIs to tweak the dep's settings, when it really should just expose the deps in a way that is tweak-able, if that kinda makes sense |
like the express app, ideally I wouldn't provide any setting like
|
I really like your suggested approach and wanted to try it out, so I've forked both Connect and Express and added the ability to prepend to the middleware stack. The
If an explicit If you want to play around with this, check out my forks of Express and Connect. I've also applied this change to the Connect master, which updates |
I think explicit via |
I think |
Would love to have that. At the same time would be nice to add client.auth() from the redis library. All the while, I'll be trying to implement it myself within the latest code base. |
If you use my fork, you can add the Redis var createClient = kue.redis.createClient;
kue.redis.createClient = function() {
var client = createClient();
client.auth('YOUR_PASSWORD');
return client;
} |
@davidwood: Thanks a bunch! Seems to be working, but I'm running into issues. Not sure if it's me or if it's your library hehe. I pulled from the redis-connection-settings branch. So I'm going to try and get it working locally first with the latest kue... Still hoping for this pull request to go through as soon as it's ready! :) |
@jeromegn What sort of issues? I'm successfully using this approach, so maybe I can help narrow down the cause. |
something about me really hates adding code to expose options for a dependency, it just seems super hacky, but we definitely need something for now, so i'll merge in a bit |
The alternative to providing a way to set dependency parameters for construction, is to just expose a function that constructs the dependency which can be overridden. This works just as easily and in my example code to @jeromegn yesterday, you'll notice I use that approach to set the auth for the Redis client. Check out my If there are going to be a bunch of deps in a project, I wonder if it doesn't make more sense to create a generic deps factory ( |
yeah that's typically what I would do, it just gets to the point sometime where it's a lot of duplicated effort just to expose something that exists already |
And generally, a developer who needs to tweak the default settings is capable enough to override a function :) Especially if all that function is doing is constructing and returning an object |
haha yup! I'd hope so, and less documentation for us |
I updated the readme in my |
yeah i almost think we should just have the createClient which can be overridden |
@davidwood: Your branch seems to work well, implemented it in production after a while of testing. Does the UI work for you? Doesn't seem to. (as long as it does its job and the API works, it's ok though) Thanks for the hard work, both of you! |
@jeromegn The UI works for me, but you need to make sure that you set the Redis client parameters prior to accessing |
* Expose the RedisClient factory. | ||
*/ | ||
|
||
exports.redis = redis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dup :D
I've removed |
awesome thanks man, merging |
damn, it looks like it should apply cleanly but it's not, might have to rebase |
My changes were pretty trivial, let me pull from upstream and merge |
there we go, git is weird sometimes... complains about merge conflicts and does not leave them for merging haha |
Allow setting of Redis connection parameters [davidwood]
I think this is broken currently. See #54 |
See response to issue #54 |
Kue uses the default Redis connection settings and did not provide a mechanism for setting them. I've added the ability to set the parameters that Kue passes to
redis.createClient
.lib/redis.js
exposes two functions:set
which is a chainable function that allows for setting of params andcreateClient
which simply callsredis.createClient
, passing any user defined parameters. This new file is namedredis.js
to minimize integration changes to a therequire
path.Both
lib/http/routes/index.js
andlib/http/routes/json.js
create new instances ofQueue
when required, so I've updatedlib/kue.js
to require the http module on first access ofkue.app
, allowing for Redis connection settings to be set first.