-
Notifications
You must be signed in to change notification settings - Fork 232
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
Custom Redis connection; documentation #81
Conversation
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.
Thank you! I especially appreciate you fixing up the documentation, which is hard where there are multiple ways of doing something, as here.
@@ -30,20 +30,64 @@ Configure your queues in the "queues" key of [`index.json`](src/server/config/in | |||
} |
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.
Now that there are several ways of configuring the Redis client, I think we should make it clearer up top here that name
is the only always-required parameter. Perhaps replace "Queues take the following format:" to the end of this section with:
Queues are JSON objects. The only required key is "name", the name of the queue. The other keys describe how to configure the underlying Redis client, and vary. Here is a queue that configures the client to connect to a specific host and port:
{
"name": "my_queue",
"port": 6381,
"host": "127.0.0.1",
"hostId": "AWS Server 2"
}
The ways in which you can configure the client are:
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.
I liked your suggestion but after taking into account your other comments I went another way: I grouped the common config keys in here, numbered the three config ways and avoided repeating what is common to all of them. I think it's better that way, let me know what you think!
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.
Great way to solve it!
README.md
Outdated
|
||
##### port host [db] [password] | ||
|
||
The `name`, `port`, `host`, and `hostId` fields are required. `hostId` can be given any name, so it is recommended to give it a helpful name for reference. | ||
Optionally, you can also pass in `db` and `password` to configure redis credentials, or `prefix` to specify the customized prefix of the queue. |
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.
Can you show all of these keys in the JSON blob, with example values and per-option documentation saying whether the option is required / optional / has a default? Perhaps like https://github.com/rollup/rollup-plugin-node-resolve#usage.
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.
Then you won't need these paragraphs alongside the code sample.
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.
Done.
README.md
Outdated
``` | ||
|
||
##### URL | ||
|
||
You can also provide a `url` field instead of `host`, `port` `db` and `password`. |
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.
It looks like hostId
is also not necessary, in this scenario? I would avoid repeating the keys from previous sections (unless they're required, as name
), but rather make it clear that each section shows a complete queue object.
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.
Done.
README.md
Outdated
```json | ||
{ | ||
"name": "my_queue", | ||
"prefix": "q", |
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.
Doesn't look like this is documented in this section. Is this a key that applies independent of how the Redis client is configured? If so, please document it up top where name
is talked about and maybe don't repeat it in the Redis configuration examples, unless it's a required key.
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.
Moved to the 'common' section.
src/server/queue/index.js
Outdated
Object.assign(options, { | ||
const options = { | ||
prefix, | ||
redis: url || redis || { port, host, db, password }, |
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.
nit: even though we don't expect multiple of the conditions here to be truthy, I think that redis
should be ordered first since that's the most powerful option. If that happened to be an existing client, I especially don't think the developer would want another client to be created.
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.
Good catch, yep!
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.
lgtm, thanks!
Published as 2.4.0. |
Thanks a lot! |
This PR fixes #67.
It also fixes a bug related to Bull configuration. Creating a Bull queue using a URL as configuration is done by passing it as a string 2nd argument, not as
{url}
object 2nd argument: https://github.com/OptimalBits/bull#basic-usageI also enhanced the documentation a bit.