|
1
|
<p align="center"> |
|
2
|
<a href="https://www.medusajs.com"> |
|
3
|
<img alt="Medusa" src="https://user-images.githubusercontent.com/7554214/153162406-bf8fd16f-aa98-4604-b87b-e13ab4baf604.png" width="100" /> |
|
4
|
</a> |
|
5
|
</p> |
|
6
|
<h1 align="center"> |
|
7
|
@medusajs/event-bus-redis |
|
8
|
</h1> |
|
9
|
|
|
10
|
<h4 align="center"> |
|
11
|
<a href="https://docs.medusajs.com">Documentation</a> | |
|
12
|
<a href="https://www.medusajs.com">Website</a> |
|
13
|
</h4> |
|
14
|
|
|
15
|
<p align="center"> |
|
16
|
An open source composable commerce engine built for developers. |
|
17
|
</p> |
|
18
|
<p align="center"> |
|
19
|
<a href="https://github.com/medusajs/medusa/blob/master/LICENSE"> |
|
20
|
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Medusa is released under the MIT license." /> |
|
21
|
</a> |
|
22
|
<a href="https://circleci.com/gh/medusajs/medusa"> |
|
23
|
<img src="https://circleci.com/gh/medusajs/medusa.svg?style=shield" alt="Current CircleCI build status." /> |
|
24
|
</a> |
|
25
|
<a href="https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md"> |
|
26
|
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="PRs welcome!" /> |
|
27
|
</a> |
|
28
|
<a href="https://www.producthunt.com/posts/medusa"><img src="https://img.shields.io/badge/Product%20Hunt-%231%20Product%20of%20the%20Day-%23DA552E" alt="Product Hunt"></a> |
|
29
|
<a href="https://discord.gg/xpCwq3Kfn8"> |
|
30
|
<img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Discord Chat" /> |
|
31
|
</a> |
|
32
|
<a href="https://twitter.com/intent/follow?screen_name=medusajs"> |
|
33
|
<img src="https://img.shields.io/twitter/follow/medusajs.svg?label=Follow%20@medusajs" alt="Follow @medusajs" /> |
|
34
|
</a> |
|
35
|
</p> |
|
36
|
|
|
37
|
## Overview |
|
38
|
|
|
39
|
Redis Event Bus module for Medusa. When installed, the events system of Medusa is powered by BullMQ and `io-redis`. BullMQ is responsible for the message queue and worker. `io-redis` is the underlying Redis client, that BullMQ connects to for events storage. |
|
40
|
|
|
41
|
## Getting started |
|
42
|
|
|
43
|
Install the module: |
|
44
|
|
|
45
|
```bash |
|
46
|
yarn add @medusajs/event-bus-redis |
|
47
|
``` |
|
48
|
|
|
49
|
Add the module to your `medusa-config.js`: |
|
50
|
|
|
51
|
```js |
|
52
|
module.exports = { |
|
53
|
// ... |
|
54
|
modules: [ |
|
55
|
{ |
|
56
|
resolve: "@medusajs/event-bus-redis", |
|
57
|
options: { |
|
58
|
redisUrl: "redis:..", |
|
59
|
}, |
|
60
|
}, |
|
61
|
], |
|
62
|
// ... |
|
63
|
} |
|
64
|
``` |
|
65
|
|
|
66
|
## Configuration |
|
67
|
|
|
68
|
The module can be configured with the following options: |
|
69
|
|
|
70
|
| Option | Type | Description | Default | |
|
71
|
| -------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ | --------------- | |
|
72
|
| `redisUrl` | `string` | URL of the Redis instance to connect to. | `events-worker` | |
|
73
|
| `queueName` | `string?` | Name of the BullMQ queue. | `events-queue` | |
|
74
|
| `queueOptions` | `object?` | Options for the BullMQ queue. See BullMQ's [documentation](https://api.docs.bullmq.io/interfaces/QueueOptions.html). | `{}` | |
|
75
|
| `redisOptions` | `object?` | Options for the Redis instance. See `io-redis`'s [documentation](https://redis.github.io/ioredis/types/RedisOptions.html) | `{}` | |
|
76
|
|
|
77
|
**Info**: See how the options are applied in the [RedisEventBusService](https://github.com/medusajs/medusa/blob/0c1d1d590463fa30b083c4312293348bdf6596be/packages/event-bus-redis/src/services/event-bus-redis.ts#L52) and [loader](https://github.com/medusajs/medusa/blob/0c1d1d590463fa30b083c4312293348bdf6596be/packages/event-bus-redis/src/loaders/index.ts). |
|
78
|
|
|
79
|
If you do not provide a `redisUrl` in the module options, the server will fail to start. |