-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add doc for the redisSub and redisPub (#2280)
Signed-off-by: XinTong Zhou <[email protected]>
- Loading branch information
Showing
13 changed files
with
230 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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压缩。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters