docs: added advanced workflows documentation (#7252)

This commit is contained in:
Shahed Nasser
2024-05-07 10:32:36 +03:00
committed by GitHub
parent 39c3f6d92a
commit 14d15df866
14 changed files with 678 additions and 22 deletions
@@ -6,6 +6,6 @@ export const metadata = {
# {metadata.title}
This section includes documentation for official Medusa architectural plugins.
This section includes documentation for official Medusa architectural modules.
<ChildDocs />
@@ -0,0 +1,39 @@
import { Table } from "docs-ui"
export const metadata = {
title: `In-Memory Workflow Engine Module`,
}
# {metadata.title}
The In-Memory Workflow Engine Module uses a plain JavaScript Map object to store the workflow executions.
This module is helpful for development or when youre testing out Medusa, but its not recommended to be used in production.
For production, its recommended to use modules like [Redis Workflow Engine Module](../redis/page.mdx).
---
## Install the In-Memory Workflow Engine Module
To install the In-Memory Workflow Engine Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/workflow-engine-inmemory
```
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/modules-sdk")
// ...
module.exports = {
// ...
modules: {
// ...
[Modules.WORKFLOW_ENGINE]: true,
},
}
```
@@ -0,0 +1,182 @@
import { Table } from "docs-ui"
export const metadata = {
title: `Redis Workflow Engine Module`,
}
# {metadata.title}
The Redis Workflow Engine Module uses Redis to track workflow executions and handle their subscribers. In production, it's recommended to use this module.
---
## Install the Redis Workflow Engine Module
<Note type="check">
- [Redis installed and Redis server running](https://redis.io/docs/getting-started/installation/).
</Note>
To install Redis Workflow Engine Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/workflow-engine-redis
```
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
export const highlights = [
["8", "redisUrl", "The Redis connection URL."]
]
```js title="medusa-config.js" highlights={highlights}
const { Modules } = require("@medusajs/modules-sdk")
// ...
module.exports = {
// ...
modules: {
// ...
[Modules.WORKFLOW_ENGINE]: {
resolve: "@medusajs/workflow-engine-redis",
options: {
redis: {
url: process.emv.WE_REDIS_URL,
},
},
},
},
}
```
### Redis Workflow Engine Module Options
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Option</Table.HeaderCell>
<Table.HeaderCell>Description</Table.HeaderCell>
<Table.HeaderCell>Required</Table.HeaderCell>
<Table.HeaderCell>Default</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`url`
</Table.Cell>
<Table.Cell>
A string indicating the Redis connection URL.
</Table.Cell>
<Table.Cell>
No. If not provided, you must provide the `pubsub` option.
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`options`
</Table.Cell>
<Table.Cell>
An object of Redis options. Refer to the [Redis API Reference](https://redis.github.io/ioredis/index.html#RedisOptions) for details on accepted properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`queueName`
</Table.Cell>
<Table.Cell>
The name of the queue used to keep track of retries and timeouts.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
<Table.Cell>
`medusa-workflows`
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`pubsub`
</Table.Cell>
<Table.Cell>
A connection object having the following properties:
- `url`: A required string indicating the Redis connection URL.
- `options`: An optional object of Redis options. Refer to the [Redis API Reference](https://redis.github.io/ioredis/index.html#RedisOptions) for details on accepted properties.
</Table.Cell>
<Table.Cell>
No. If not provided, you must provide the `url` option.
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
### Environment Variables
Make sure to add the following environment variables:
```bash
WE_REDIS_URL=<YOUR_REDIS_URL>
```
---
## Test the Module
To test the module, start the Medusa application:
```bash npm2yarn
npm run dev
```
You'll see the following message in the terminal's logs:
```bash noCopy noReport
Connection to Redis in module 'workflow-engine-redis' established
```
+6 -6
View File
@@ -1,8 +1,4 @@
export const filesMap = [
{
"filePath": "/www/apps/resources/app/.DS_Store",
"pathname": "/"
},
{
"filePath": "/www/apps/resources/app/admin-widget-injection-zones/page.mdx",
"pathname": "/admin-widget-injection-zones"
@@ -28,8 +24,12 @@ export const filesMap = [
"pathname": "/architectural-modules"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/.DS_Store",
"pathname": "/commerce-modules"
"filePath": "/www/apps/resources/app/architectural-modules/workflow-engine/in-memory/page.mdx",
"pathname": "/architectural-modules/workflow-engine/in-memory"
},
{
"filePath": "/www/apps/resources/app/architectural-modules/workflow-engine/redis/page.mdx",
"pathname": "/architectural-modules/workflow-engine/redis"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/api-key/examples/page.mdx",
+22
View File
@@ -6844,6 +6844,28 @@ export const generatedSidebar = [
"children": []
}
]
},
{
"loaded": true,
"isPathHref": true,
"title": "Workflow Engine Modules",
"hasTitleStyling": true,
"children": [
{
"loaded": true,
"isPathHref": true,
"path": "/architectural-modules/workflow-engine/in-memory",
"title": "In-Memory",
"children": []
},
{
"loaded": true,
"isPathHref": true,
"path": "/architectural-modules/workflow-engine/redis",
"title": "Redis",
"children": []
}
]
}
]
},
+14
View File
@@ -1619,6 +1619,20 @@ export const sidebar = sidebarAttachHrefCommonOptions([
},
],
},
{
title: "Workflow Engine Modules",
hasTitleStyling: true,
children: [
{
path: "/architectural-modules/workflow-engine/in-memory",
title: "In-Memory",
},
{
path: "/architectural-modules/workflow-engine/redis",
title: "Redis",
},
],
},
],
},
{