Skip to content

Commit

Permalink
docs: Translations for documents under the handbook module and the we…
Browse files Browse the repository at this point in the history
…lcome module. (#267)
  • Loading branch information
Albert-mah authored Jan 2, 2025
1 parent b5ea77d commit 7961b66
Show file tree
Hide file tree
Showing 10 changed files with 403 additions and 414 deletions.
70 changes: 35 additions & 35 deletions docs/en-US/handbook/workflow-subflow/index.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
# 子流程
# Subflow

<PluginInfo name="workflow-subflow" link="/handbook/workflow-subflow" commercial="true"></PluginInfo>

用于在一个工作流中调用其他的流程,可以使用当前流程的变量作为子流程的输入,并使用子流程的输出作为当前流程的变量在后续节点中使用。
Used to call other processes within a workflow, allowing the current process variables to serve as inputs for the subflow, and using the outputs of the subflow as variables in subsequent nodes of the current process.

调用子流程的处理过程如下图所示:
The process of calling a subflow is illustrated in the diagram below:

![20241230134634](https://static-docs.nocobase.com/20241230134634.png)

通过子流程可以复用一些通用的流程逻辑,例如发送邮件、短信等,或者将一个复杂的流程拆分为多个子流程,便于管理和维护。
Subflows can be used to reuse some common process logic, such as sending emails or SMS, or to break a complex process into multiple subflows for easier management and maintenance.

## 使用手册
## User Manual

本质上工作流不区分一个流程是否是子流程,任意一个工作流都可以作为子流程被其他流程调用,也可以调用其他流程。所有工作流都是平等的,只存在调用和被调用的关系。
Essentially, workflows do not distinguish whether a process is a subflow or not; any workflow can be called by other processes and can call other processes. All workflows are equal, existing only in a caller and callee relationship.

同样的,子流程的使用分处于两个位置:
Similarly, the use of subflows occurs in two locations:

1. 主流程中:作为调用方,通过“调用工作流”节点,调用其他的工作流。
2. 子流程中:作为被调用方,通过“流程输出”节点,保存当前流程中需要输出的变量,可在调用当前流程的工作流中被后续节点使用。
1. In the main process: as the caller, invoking other workflows through the "Call Workflow" node.
2. In the subflow: as the callee, saving the variables that need to be output in the current process through the "Process Output" node, which can then be utilized by subsequent nodes in the workflow that calls the current process.

### 调用工作流节点
### Call Workflow Node

#### 创建节点
#### Create Node

在工作流配置界面中,点击流程中的加号(“+”)按钮,添加“调用工作流”节点:
In the workflow configuration interface, click the plus ("+") button within the process to add a "Call Workflow" node:

![添加调用工作流节点](https://static-docs.nocobase.com/20241230001323.png)
![Add Call Workflow Node](https://static-docs.nocobase.com/20241230001323.png)

#### 配置节点
#### Configure Node

##### 选择工作流
##### Select Workflow

选择要调用的工作流,可以通过搜索框快速查找:
Select the workflow to be called, which can be quickly found using the search box:

![选择工作流](https://static-docs.nocobase.com/20241230001534.png)
![Select Workflow](https://static-docs.nocobase.com/20241230001534.png)

:::info{title=提示}
* 未启用的工作流也可以作为子流程被调用。
* 当前工作流为同步模式时,也只能调用同步模式的子流程。
:::info{title=Tip}
* Workflows that are not enabled can still be called as subflows.
* When the current workflow is in synchronous mode, only synchronous subflows can be called.
:::

##### 配置工作流的触发器变量
##### Configure Trigger Variables for the Workflow

选定工作流后,还需要配置触发器的变量,作为触发子流程的输入数据。可以直接选择静态的数据,也可以选择当前流程中的变量:
After selecting the workflow, you also need to configure the trigger variables as input data for the subflow. You can choose static data directly or select variables from the current process:

![配置触发器变量](https://static-docs.nocobase.com/20241230162722.png)
![Configure Trigger Variables](https://static-docs.nocobase.com/20241230162722.png)

不同类型的触发器所需的变量不同,可以根据需要在表单上完成配置。
Different types of triggers require different variables, which can be configured on the form as needed.

### 流程输出节点
### Process Output Node

#### 创建节点
#### Create Node

在被调用的工作流中,添加“流程输出”节点:
In the called workflow, add a "Process Output" node:

![20241231002033](https://static-docs.nocobase.com/20241231002033.png)

#### 配置节点
#### Configure Node

##### 输出值
##### Output Value

输入或选择变量作为输出值,输出值可以是任意类型,可以是常量,如字符串、数字、逻辑值、日期或自定义 JSON 等,也可以是流程中的其他变量。
Input or select variables as output values. Output values can be of any type, including constants such as strings, numbers, boolean values, dates, or custom JSON. They can also be other variables within the process.

![20241231003059](https://static-docs.nocobase.com/20241231003059.png)

:::info{title=提示}
如果在被调用的工作流中添加了多个“流程输出”节点,那么在调用该工作流时,会按最后一个执行的“流程输出”节点的值输出。
:::info{title=Tip}
If multiple "Process Output" nodes are added in the called workflow, the value will be output according to the last executed "Process Output" node when calling that workflow.
:::

### 使用流程输出
### Using Process Output

回到主流程中,在调用工作流下方的其他节点,要使用子流程的输出值时,可以选择调用工作流节点的结果。如果子流程输出的是一个简单值,如字符串、数字、逻辑值、日期(日期为 UTC 格式的字符串)等,可以直接使用;如果是一个复杂对象(如数据表中的对象),需要先通过 JSON 解析节点进行映射后,才能使用其中的属性,否则只能按整个对象使用。
Returning to the main process, to use the subflow's output values in other nodes below the call workflow, the result of the call workflow node can be selected. If the subflow outputs a simple value, such as a string, number, boolean value, or date (date in UTC string format), it can be used directly. If it is a complex object (such as an object in a Collection), it must first be mapped through a JSON parsing node before its properties can be used; otherwise, it can only be used as the entire object.

如果子流程没有配置流程输出节点,或者没有输出值,那么在主流程中使用调用工作流节点的结果时,只能获得一个空值(`null`)。
If the subflow does not configure a process output node or does not output any value, then when using the result of the call workflow node in the main process, only a null value (`null`) will be obtained.
2 changes: 1 addition & 1 deletion docs/en-US/handbook/workflow/nodes/output.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Output

参考 [子流程插件:流程输出](../../workflow-subflow/index.md#流程输出节点)
Refer to [Subprocess Plugin: Process Output](../../workflow-subflow/index.md#process-output-node).
2 changes: 1 addition & 1 deletion docs/en-US/handbook/workflow/nodes/subflow.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Call Workflow

参考 [子流程插件:调用工作流](../../workflow-subflow/index.md#调用工作流节点)
Refer to [Subprocess Plugin: Call Workflow](../../workflow-subflow/index.md#call-workflow-node).
149 changes: 74 additions & 75 deletions docs/en-US/welcome/getting-started/deployment/cluster-mode.md
Original file line number Diff line number Diff line change
@@ -1,131 +1,130 @@
# 集群模式
# Cluster Mode

NocoBase 自 v1.6.0 版本开始支持以集群模式运行应用。应用以集群模式运行时,可以通过多个实例和使用多核模式来提高应用的对并发访问处理的性能。
Starting from version v1.6.0, NocoBase supports running applications in cluster mode. When an application runs in cluster mode, its performance in handling concurrent accesses can be improved through multiple instances and using a multi-core mode.

## 系统架构
## System Architecture

![20241231010814](https://static-docs.nocobase.com/20241231010814.png)

### 架构组件
### Architectural Components

目前的集群模式仅针对应用实例,分布式架构中的其他系统组件根据不同团队的运维需求,在符合当前约束的条件下,由团队的运维人员自行选用。
The current cluster mode is focused solely on application instances. Other system components in the distributed architecture can be selected by the operations personnel of different teams according to their operational requirements, as long as they comply with the current constraints.

#### 应用集群
#### Application Cluster

应用集群是 NocoBase 应用的实例集合,每个实例可以是一个独立的节点,或是在单机上以多核模式运行的多个应用进程,也可以两者混合使用。
The application cluster is a collection of instances of NocoBase applications, where each instance can be an independent node or multiple application processes running on a single machine in multi-core mode, or a combination of both.

#### 数据库
#### Database

由于目前的集群模式只针对应用实例,数据库暂时只支持单节点,如有主从等数据库架构,需要自行通过中间件实现,并保证对 NocoBase 应用透明。
Since the current cluster mode only targets application instances, the database currently only supports a single node. For setups such as master-slave databases, it must be implemented through middleware independently, ensuring transparency to the NocoBase application.

#### 缓存、同步消息和分布式锁
#### Caching, Synchronization Messages, and Distributed Locks

NocoBase 集群模式需要依赖缓存、同步消息和分布式锁等中间件来实现集群间的通信和协调,目前初步支持使用 Redis 作为相应功能的中间件。
The NocoBase cluster mode relies on middleware such as caching, synchronization messages, and distributed locks to achieve communication and coordination between clusters. Currently, Redis is preliminarily supported as middleware for these functionalities.

#### 负载均衡
#### Load Balancing

NocoBase 集群模式需要通过负载均衡器来实现请求的分发,以及应用实例的健康检查和故障转移。该部分根据团队运维需求自行选择和配置。
The NocoBase cluster mode requires a load balancer to distribute requests and perform health checks and failover for application instances. This part should be selected and configured according to the operations needs of the team.

## 部署步骤
## Deployment Steps

### 基础设施准备
### Infrastructure Preparation

#### 负载均衡
#### Load Balancer

以自建 Nginx 为例,在配置文件中增加以下内容:
Taking a self-built Nginx as an example, add the following content to the configuration file:

```
upstream myapp {
# ip_hash; # 可用于会话保持,开启后来自同一客户端的请求总是发送到同一个后端服务器。
server 172.31.0.1:13000; # 内网节点1
server 172.31.0.2:13000; # 内网节点2
server 172.31.0.3:13000; # 内网节点3
# ip_hash; # Can be used for session persistence, once enabled, requests from the same client will always be sent to the same backend server.
server 172.31.0.1:13000; # Internal node 1
server 172.31.0.2:13000; # Internal node 2
server 172.31.0.3:13000; # Internal node 3
}
server {
listen 80;
location / {
# 使用定义的 upstream 进行负载均衡
# Use the defined upstream for load balancing
proxy_pass http://myapp;
# ... 其他配置
# ... other configurations
}
}
```

意为将请求反代分发到不同的服务器节点进行处理。
其他云服务商提供的负载均衡中间件可参考具体服务商提供的配置文档。
This means that requests are reverse proxied and distributed to different server nodes for processing. The configurations for load balancing middleware provided by other cloud service providers can be referenced in the specific configuration documentation provided by them.

#### Redis 服务
#### Redis Service

在集群内网(或 k8s)中,启动一个 Redis 服务。或根据不同功能(缓存、同步消息和分布式锁)各自启用一个 Redis 服务。
Start a Redis service within the cluster's internal network (or k8s). Alternatively, enable separate Redis services based on different functionalities (caching, synchronization messages, and distributed locks).

#### 本地存储(按需)
#### Local Storage (Optional)

如使用了本地存储,在多节点模式下应通过挂载云盘作为本地存储目录,以支持多节点共享访问。否则本地存储不会自动同步,将无法正常使用。
If local storage is used, in a multi-node mode, it should be mounted as a local storage directory to support shared access across multiple nodes. Otherwise, local storage will not automatically synchronize and cannot be used properly.

如不使用本地存储,在应用启动后,需要将基于云服务的文件存储空间设置为默认文件存储空间,并将应用的 Logo(或其他文件)迁移到云存储空间。
If not using local storage, after the application starts, the cloud service-based file storage space must be set as the default file storage space, and the application’s logo (or other files) should be migrated to the cloud storage space.

### 相关插件准备
### Related Plugin Preparation

| 功能 | 插件 |
| Function | Plugin |
| --- | --- |
| 缓存 | 内置 |
| 同步消息 | @nocobase/plugin-pubsub-adapter-redis |
| 分布式锁 | @nocobase/plugin-lock-adapter-redis |
| Caching | Built-in |
| Synchronization Messages | @nocobase/plugin-pubsub-adapter-redis |
| Distributed Lock | @nocobase/plugin-lock-adapter-redis |

:::info{title=提示}
与单节点模式的应用一样,只要配置了商业插件服务平台相关的环境变量,应用启动后会自动下载相应的插件。
:::info{title=Tip}
Just like applications in single-node mode, as long as the respective environment variables for the commercial plugin service platform are configured, the application will automatically download the corresponding plugins after startup.
:::

### 环境变量配置
### Environment Variable Configuration

除基本的环境变量外,以下环境变量所有节点均需配置,且需要保持一致。
In addition to the basic environment variables, the following environment variables must be configured consistently across all nodes.

#### 应用密钥
#### Application Key

用于用户登录时创建 JWT Token 的密钥,建议使用随机字符串。
The key used for creating JWT Tokens during user login; it is recommended to use a random string.

```ini
APP_KEY=
```

#### 多核模式
#### Multi-core Mode

```ini
# 开启 PM2 多核模式
# CLUSTER_MODE=max # 默认不开启,需要手动配置
# Enable PM2 multi-core mode
# CLUSTER_MODE=max # Default is disabled and needs to be manually configured
```

#### 缓存
#### Caching

```ini
# 缓存适配器,集群模式下需要填写为 redis(默认不填为内存)
# Cache adapter; must be set to redis in cluster mode (default is memory if not set)
CACHE_DEFAULT_STORE=redis

# Redis 缓存适配器连接地址,需要主动填写
# Redis cache adapter connection address; must be actively set
CACHE_REDIS_URL=
```

#### 同步消息
#### Synchronization Messages

```ini
# Redis 同步适配器连接地址,默认不填为 redis://localhost:6379/0
# Redis synchronization adapter connection address; default is redis://localhost:6379/0 if not set
PUBSUB_ADAPTER_REDIS_URL=
```

#### 分布式锁
#### Distributed Lock

```ini
# 锁适配器,集群模式下需要填写为 redis(默认不填为内存本地锁)
# Lock adapter; must be set to redis in cluster mode (default is memory local lock if not set)
LOCK_ADAPTER_DEFAULT=redis

# Redis 锁适配器连接地址,默认不填为 redis://localhost:6379/0
# Redis lock adapter connection address; default is redis://localhost:6379/0 if not set
LOCK_ADAPTER_REDIS_URL=
```

:::info{title=提示}
通常情况,相关的适配器可以都使用同一个 Redis 实例,但最好区分使用不同的数据库,以避免可能存在的键冲突问题,例如:
:::info{title=Tip}
Generally, the related adapters can all use the same Redis instance, but it’s best to distinguish by using different databases to avoid potential key conflict issues.

```ini
CACHE_REDIS_URL=redis://localhost:6379/0
Expand All @@ -134,43 +133,43 @@ LOCK_ADAPTER_REDIS_URL=redis://localhost:6379/2
```
:::

#### 内置插件启用
#### Enable Built-in Plugins

```ini
# 内置要开启的插件
# Built-in plugins to be enabled
APPEND_PRESET_BUILT_IN_PLUGINS=lock-adapter-redis,pubsub-adapter-redis
```

### 启动应用
### Start the Application

首次启动应用时,应先启动其中一个节点,等待插件安装完毕并启用后,再启动其他节点。
When starting the application for the first time, you should first start one of the nodes and wait for the plugins to be installed and enabled before starting the other nodes.

## 升级或维护
## Upgrade or Maintenance

当需要升级 NocoBase 版本或启用/禁用插件时,参考此流程处理。
When it is necessary to upgrade the NocoBase version or enable/disable plugins, refer to this process.

:::warning{title=注意}
在集群生产环境需要谨慎或禁止使用插件管理和版本升级等功能。
:::warning{title=Note}
In a cluster production environment, caution or prohibition is advised when using features such as plugin management and version upgrades.

NocoBase 暂时未实现集群版本的在线升级,为确保数据一致性,在升级过程中需要暂停服务。
NocoBase has not yet implemented online upgrades for the cluster version. To ensure data consistency, services need to be paused during the upgrade process.
:::

### 停止当前服务
### Stop Current Services

停止所有 NocoBase 应用实例,Redis 等中间件,并将负载均衡的流量转发至 503 状态页面。
Stop all NocoBase application instances, middleware such as Redis, and redirect load-balanced traffic to a 503 status page.

### 备份数据
### Backup Data

在升级前,强烈建议备份数据库数据,以防止升级过程中出现异常。
Before upgrading, it is strongly recommended to back up database data to prevent issues during the upgrade process.

### 更新版本
### Update Version

参考 [Docker 升级](../upgrading/docker-compose.md) 更新 NocoBase 应用镜像的版本。
Refer to [Docker Upgrade](../upgrading/docker-compose.md) to update the version of the NocoBase application image.

### 启动服务
### Start Services

1. 重新依赖的中间件(Redis
2. 启动集群中的一个节点,等待更新完毕并启动成功
3. 验证功能正确,如有异常且排查无法解决,可回滚至上一个版本
4. 启动其他节点
5. 转移负载均衡的流量至应用集群
1. Restart the dependent middleware (Redis)
2. Start one node in the cluster and wait for the update to complete and start successfully
3. Verify functionality; if there are exceptions that cannot be resolved, you may roll back to the previous version
4. Start the other nodes
5. Redirect load-balanced traffic to the application cluster
Loading

0 comments on commit 7961b66

Please sign in to comment.