Skip to content

Commit

Permalink
docs: add doc for the redisSub and redisPub (#2280)
Browse files Browse the repository at this point in the history
Signed-off-by: XinTong Zhou <[email protected]>
  • Loading branch information
retoool authored Oct 8, 2023
1 parent c022fc0 commit ba33328
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 6 deletions.
16 changes: 16 additions & 0 deletions docs/directory.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@
{
"title": "Redis 数据源",
"path": "guide/sources/builtin/redis"
},
{
"title": "RedisSub 数据源",
"path": "guide/sources/builtin/redisSub"
}
]
},
Expand Down Expand Up @@ -259,6 +263,10 @@
"title": "Redis Sink",
"path": "guide/sinks/builtin/redis"
},
{
"title": "RedisPub Sink",
"path": "guide/sinks/builtin/redisPub"
},
{
"title": "File Sink",
"path": "guide/sinks/builtin/file"
Expand Down Expand Up @@ -883,6 +891,10 @@
{
"title": "Redis Source",
"path": "guide/sources/builtin/redis"
},
{
"title": "RedisSub Source",
"path": "guide/sources/builtin/redisSub"
}
]
},
Expand Down Expand Up @@ -940,6 +952,10 @@
"title": "Redis Sink",
"path": "guide/sinks/builtin/redis"
},
{
"title": "RedisPub Sink",
"path": "guide/sinks/builtin/redisPub"
},
{
"title": "File Sink",
"path": "guide/sinks/builtin/file"
Expand Down
35 changes: 35 additions & 0 deletions docs/en_US/guide/sinks/builtin/redisPub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# RedisPub action

The action is used for publishing output message into redis channel.

## Properties

| Property name | Optional | Description |
|----------------|----------|-------------------------------------------------------|
| address | false | The address of Redis, e.g., 127.0.0.1:6379 |
| username | true | Redis login username (fill in if authentication is required) |
| password | true | Redis login password (fill in if authentication is required) |
| db | false | The Redis database, e.g., 0 |
| channel | false | Specifies the Redis channels to subscribe to. |
| compression | true | Compresses the Payload using the specified compression method. Currently supports zlib, gzip, flate, zstd algorithms.|

Other common sink properties are supported. Please refer to the [sink common properties](../overview.md#common-properties) for more information.

## Sample usage

The following is an example of publishing compressed data to a local Redis server.

```json
{
"redis":{
"address": "127.0.0.1:6379",
"username": "default",
"password": "123456",
"db": 0,
"channel": "exampleChannel",
"compression": "zlib"
}
}
```

This example configuration is used to publish data to the "exampleChannel" channel in Redis and applies zlib compression.
1 change: 1 addition & 0 deletions docs/en_US/guide/sinks/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Users can directly use the built-in sinks in the standard eKuiper instance. The
- [EdgeX sink](./builtin/edgex.md): sink to EdgeX Foundry. This sink only exists when enabling the edgex build tag.
- [Rest sink](./builtin/rest.md): sink to external HTTP server.
- [Redis sink](./builtin/redis.md): sink to Redis.
- [RedisSub sink](./builtin/redisPub.md): sink to redis channel.
- [File sink](./builtin/file.md): sink to a file.
- [Memory sink](./builtin/memory.md): sink to eKuiper memory topic to form rule pipelines.
- [Log sink](./builtin/log.md): sink to log, usually for debugging only.
Expand Down
3 changes: 2 additions & 1 deletion docs/en_US/guide/sources/builtin/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ eKuiper provides built-in support for looking up data in Redis. The Redis Source

::: tip

Currently, the Redis source can only be used as a [lookup table](../../tables/lookup.md).
Currently, the Redis source can only be used as a [lookup table](../../tables/lookup.md),
while the [RedisSub source](./redisSub.md) can be used as both a streaming and scanning table data source,

:::

Expand Down
64 changes: 64 additions & 0 deletions docs/en_US/guide/sources/builtin/redisSub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## RedisSub Source Connector

<span style="background:green;color:white;">stream source</span>
<span style="background:green;color:white">scan table source</span>

eKuiper has built-in support for Redis data sources, allowing data querying and channel subscription within Redis.Please note that the RedisSub source can be used as both a streaming and scanning table data source,while the [Redis source](./redis.md) can be used as a [lookup table](../../tables/lookup.md).

## Configurations

Before using the RedisSub Source Connector, it's essential to configure the connection settings and other relevant parameters. Here are the available configuration options:

The configuration file for the RedisSub source is located at */etc/sources/redisSub.yaml*.

```yaml
default:
address: 127.0.0.1:6379
username: default
db: 0
```
**Configuration Items**
- **`address`**:Specifies the address of the Redis server in the format hostname:port or IP_address:port.
- **`username`**:Sets the username for accessing the Redis server. This is only required when the server has authentication enabled.
- **`password`**:Sets the password for accessing the Redis server. This is only required when the server has authentication enabled.
- **`db`**:Selects the Redis database to connect to. The default is 0.
- **`channels`**:Used to specify a list of Redis channels to subscribe to.
- **`decompression`**:Specifies the compression method for decompressing Redis Payload. Supported compression methods include "zlib," "gzip," "flate," and "zstd."

## Create a Stream Source

To utilize the RedisSub source Connector in eKuiper streams, define a stream specifying the RedisSub source, its configuration, and the data format.

You can define the RedisSub source as the data source either by REST API or CLI tool.

### Use REST API

The REST API offers a programmatic way to interact with eKuiper, perfect for users looking to automate tasks or integrate eKuiper operations into other systems.

**Example**

```sql
CREATE STREAM redisSub_stream () WITH (FORMAT="json", TYPE="redisSub");
```

More details can be found at [Streams Management with REST API](../../../api/restapi/streams.md).

### Use CLI

For users who prefer a hands-on approach, the Command Line Interface (CLI) provides direct access to eKuiper's operations.

1. Navigate to the eKuiper binary directory:

```bash
cd path_to_eKuiper_directory/bin
```

2. Use the `create` command to define a stream for the RedisSub source connector:

```bash
./kuiper create stream redisSub_stream ' WITH (FORMAT="json", TYPE="redisSub")'
```

More details can be found at [Streams Management with CLI](../../../api/cli/streams.md).
1 change: 1 addition & 0 deletions docs/en_US/guide/sources/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Users can directly use the built-in sources in the standard eKuiper instance. Th
- [HTTP pull source](./builtin/http_pull.md): source to pull data from HTTP servers.
- [Http push source](./builtin/http_push.md): push data to eKuiper through http.
- [Redis source](./builtin/redis.md): source to lookup from Redis as a lookup table.
- [RedisSub source](./builtin/redisSub.md): subscribe data from Redis channels.
- [File source](./builtin/file.md): source to read from file, usually used as tables.
- [Memory source](./builtin/memory.md): source to read from eKuiper memory topic to form rule pipelines.

Expand Down
35 changes: 35 additions & 0 deletions docs/zh_CN/guide/sinks/builtin/redisPub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# RedisPub 目标(Sink)

该操作用于将输出消息发布到redis消息通道。

## 属性

| 属性名称 | 是否必填 | 说明 |
|--------------|------|-------------------------------------------------------|
| address || Redis 的地址, 例如: 127.0.0.1:6379 |
| username || Redis 登录用户名(如果需要身份验证则填写) |
| password || Redis 登录密码(如果需要身份验证则填写) |
| db || Redis 的数据库,例如0 |
| channel || 用于指定要订阅的 Redis 频道列表。 |
| compression || 使用指定的压缩方法压缩 Payload。当前支持 zlib, gzip, flate, zstd 算法。 |

其他通用的 sink 属性也支持,请参阅[公共属性](../overview.md#公共属性)

## 示例用法

下面是一个发布压缩数据到本地Redis服务器的示例:

```json
{
"redis":{
"address": "127.0.0.1:6379",
"username": "default",
"password": "123456",
"db": 0,
"channel": "exampleChannel",
"compression": "zlib"
}
}
```

这个示例配置用于将数据发布到Redis的"exampleChannel"频道,并应用了zlib压缩。
2 changes: 2 additions & 0 deletions docs/zh_CN/guide/sinks/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [EdgeX sink](./builtin/edgex.md):输出到 EdgeX Foundry。此动作仅在启用 edgex 编译标签时存在。
- [Rest sink](./builtin/rest.md):输出到外部 http 服务器。
- [Redis sink](./builtin/redis.md): 写入 Redis 。
- [RedisPub sink](./builtin/redisPub.md): 输出到 Redis 消息频道。
- [File sink](./builtin/file.md): 写入文件。
- [Memory sink](./builtin/memory.md):输出到 eKuiper 内存主题以形成规则管道。
- [Log sink](./builtin/log.md):写入日志,通常只用于调试。
Expand Down Expand Up @@ -224,6 +225,7 @@ Sink 缓存的配置有两个层次。`etc/kuiper.yaml` 中的全局配置,定
- MQTT sink: 该属性表示重传的主题。若未设置,则仍传到原主题。
- REST sink: 该属性表示重传的 URL 。若未设置,则仍传到原 URL。
- Memory sink: 该属性表示重传的主题。若未设置,则仍传到原主题。
- RedisPub sink: 该属性表示重传的频道。若未设置,则仍传到原频道。

对于自定义的 sink,可以实现 `CollectResend`
函数来自定义重传策略。请参考[自定义重传策略](../../extension/native/develop/sink.md#自定义重传策略)
3 changes: 2 additions & 1 deletion docs/zh_CN/guide/sources/builtin/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<span style="background:green;color:white">lookup table source</span>

eKuiper 内置支持 Redis 数据源,支持在 Redis 中进行数据查询。注意,现在 Redis 源只能作为一个[查询表](../../tables/lookup.md),不支持作为流和扫描表类数据源。
eKuiper 内置支持 Redis 数据源,支持在 Redis 中进行数据查询。
注意,现在 Redis 源只能作为一个[查询表](../../tables/lookup.md),而[RedisSub 数据源](./redisSub.md)可作为流和扫描表类数据源。

## 配置

Expand Down
67 changes: 67 additions & 0 deletions docs/zh_CN/guide/sources/builtin/redisSub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
## RedisSub 数据源

<span style="background:green;color:white;">stream source</span>
<span style="background:green;color:white">scan table source</span>

eKuiper 内置支持 Redis 数据源,支持在 Redis 中进行数据查询,订阅频道。
注意,RedisSub 数据源可作为流和扫描表类数据源,而[Redis 源](./redis.md)可作为一个[查询表](../../tables/lookup.md)

## 配置

在使用连接器连接 RedisSub 数据源之前,应先完成连接和其他相关参数配置。

RedisSub 源的配置文件位于 */etc/sources/redisSub.yaml*,您可以在其中指定 Redis 的连接信息等属性。

```yaml
default:
address: 127.0.0.1:6379
username: default
db: 0
```
按照以上配置,eKuiper 将引用的 Redis 实例地址是127.0.0.1:6379。值的类型是 "string"。
**配置项**
- **`address`**:指定 Redis 服务器的地址,格式为 `hostname:port` 或 `IP_address:port` 的字符串。
- **`username`**:设置用于访问 Redis 服务器的用户名,只有在服务器启用身份验证时需要配置。
- **`password`**:设置用于访问 Redis 服务器的密码,只有在服务器启用身份验证时需要配置。
- **`db`**:选择要连接的 Redis 数据库。默认是 0。
- **`channels`**:用于指定要订阅的 Redis 频道列表。
- **`decompression`**:指定用于解压缩 Redis Payload 的压缩方法,支持的压缩方法有"zlib","gzip","flate",zstd"。

## 创建流数据源

完成连接器的配置后,后续可通过创建流将其与 eKuiper 规则集成。RedisSub 源连接器可以作为[流式](../../streams/overview.md)或[扫描表数据源](../../tables/scan.md)使用,本节将以流类型源为例进行说明。

您可通过 REST API 或 CLI 工具在 eKuiper 中创建 RedisSub 数据源。

### 通过 REST API 创建

REST API 为 eKuiper 提供了一种可编程的交互方式,适用于自动化或需要将 eKuiper 集成到其他系统中的场景。

**示例**

```sql
CREATE STREAM redis_stream () WITH (FORMAT="json", TYPE="redisSub");
```

详细操作步骤及命令解释,可参考 [通过 REST API 进行流管理](../../../api/restapi/streams.md)。

### 通过 CLI 创建

用户也可以通过命令行界面(CLI)直接访问 eKuiper。

1. 进入 eKuiper `bin` 目录:

```bash
cd path_to_eKuiper_directory/bin
```

2. 使用 `create` 命令创建规则,指定 Redis Sub 数据源,如:

```bash
./kuiper create stream neuron_stream ' WITH (FORMAT="json", TYPE="redisSub")'
```

详细操作步骤及命令解释,可参考 [通过 CLI 进行流管理](../../../api/cli/streams.md)。
1 change: 1 addition & 0 deletions docs/zh_CN/guide/sources/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [Http pull source](./builtin/http_pull.md):从 http 服务器中拉取数据。
- [Http push source](./builtin/http_push.md):通过 http 推送数据到 eKuiper。
- [Redis source](./builtin/redis.md): 从 Redis 中查询数据,用作查询表。
- [RedisSub source](./builtin/redisSub.md): 从 Redis 频道中订阅数据。
- [File source](./builtin/file.md):从文件中读取数据,通常用作表格。
- [Memory source](./builtin/memory.md):从 eKuiper 内存主题读取数据以形成规则管道。

Expand Down
4 changes: 2 additions & 2 deletions etc/sinks/redisPub.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"control": "text",
"type": "int",
"hint": {
"en_US": "Database number (0 to 16).",
"zh_CN": "数据库号(0到16)。"
"en_US": "Database number (0 to 15).",
"zh_CN": "数据库号(0到15)。"
},
"label": {
"en_US": "Database Number",
Expand Down
4 changes: 2 additions & 2 deletions etc/sources/redisSub.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"control": "text",
"type": "int",
"hint": {
"en_US": "Database number (0 to 16).",
"zh_CN": "数据库号(0到16)。"
"en_US": "Database number (0 to 15).",
"zh_CN": "数据库号(0到15)。"
},
"label": {
"en_US": "Database Number.",
Expand Down

0 comments on commit ba33328

Please sign in to comment.