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

Document createClient option #1791

Merged
merged 6 commits into from
Jul 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The optional `url` argument, allows to specify a redis connection string such as

```typescript
interface QueueOptions {
createClient?(type: 'client' | 'subscriber' | 'bclient', config?: Redis.RedisOptions): Redis.Redis | Redis.Cluster;
limiter?: RateLimiter;
redis?: RedisOpts;
prefix?: string = 'bull'; // prefix for all queue keys.
Expand Down Expand Up @@ -105,6 +106,19 @@ interface AdvancedSettings {
}
```

**Custom or Shared IORedis Connections**

`createClient` is passed a `type` to specify the type of connection that Bull is trying to create, and some options that `bull` would like to set for that connection.

You can merge the provided options with some of your own and create an `ioredis` connection.

When type is `client` or `subscriber` you can return the same connection for multiple queues, which can reduce the number of connections you open to the redis server. Bull
does not close or disconnect these connections when queues are closed, so if you need to have your app do a graceful shutdown, you will need to keep references to these
Redis connections somewhere and disconnect them after you shut down all the queues.

The `bclient` connection however is a "blocking client" and is used to wait for new jobs on a single queue at a time. For this reason it cannot be shared and a
new connection should be returned each time.

**Advanced Settings**

**Warning:** Do not override these advanced settings unless you understand the internals of the queue.
Expand Down