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

Custom Redis connection; documentation #81

Merged
merged 1 commit into from
Jan 5, 2018
Merged

Custom Redis connection; documentation #81

merged 1 commit into from
Jan 5, 2018

Conversation

vhf
Copy link
Contributor

@vhf vhf commented Jan 4, 2018

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-usage

I also enhanced the documentation a bit.

Copy link
Contributor

@wearhere wearhere left a 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
}
Copy link
Contributor

@wearhere wearhere Jan 5, 2018

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:

Copy link
Contributor Author

@vhf vhf Jan 5, 2018

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!

Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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`.
Copy link
Contributor

@wearhere wearhere Jan 5, 2018

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.

Copy link
Contributor Author

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",
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Object.assign(options, {
const options = {
prefix,
redis: url || redis || { port, host, db, password },
Copy link
Contributor

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.

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 catch, yep!

Copy link
Contributor

@wearhere wearhere left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@wearhere wearhere merged commit ba871ce into bee-queue:master Jan 5, 2018
@wearhere
Copy link
Contributor

wearhere commented Jan 5, 2018

Published as 2.4.0.

@vhf vhf deleted the redis-opts branch January 6, 2018 00:42
@vhf
Copy link
Contributor Author

vhf commented Jan 6, 2018

Thanks a lot!

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.

Need to pass skipVersionCheck redis option to bull.
2 participants