Skip to content

Commit

Permalink
Merge pull request #34 from ljemq/feat/rule-doc
Browse files Browse the repository at this point in the history
feat(rule-doc): add enable test in rule and change plugin page and add simulator source
  • Loading branch information
QQDQ authored Dec 24, 2023
2 parents bc2cdcf + 928737e commit a5a59c3
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 30 deletions.
8 changes: 8 additions & 0 deletions directory.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@
{
"title": "Video",
"path": "streaming-processing/video"
},
{
"title": "Simulator",
"path": "streaming-processing/simulator"
}
]
},
Expand Down Expand Up @@ -1409,6 +1413,10 @@
{
"title": "Video",
"path": "streaming-processing/video"
},
{
"title": "Simulator",
"path": "streaming-processing/simulator"
}
]
},
Expand Down
Binary file added en_US/configuration/_assets/plugin_add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added en_US/configuration/_assets/plugin_update.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions en_US/configuration/ecp_edge_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ Plugin types include the following three modes:

## Add new pluggable module

On the plugin page, click the **Add plugin** button in the upper left corner to upload the local plugin .so file.
On the plugin page, click the **Add plugin** button in the upper left corner to upload the local plugin .so file and .json file.

![plugin-options](./_assets/plugin_add.png)

For specific plug-in development tutorials, please refer to [SKD Tutorial](https://neugates.io/docs/zh/latest/dev-guide/sdk-tutorial/sdk-tutorial.html).

## Replace existing plug-in modules

On the plugin page, click the **Replace** button on each plugin card to upload the local plugin .so file.
On the plugin page, click the **Replace** button on each plugin card to upload the local plugin .so file and .json file.

![plugin-options](./_assets/plugin_update.png)

For specific plugin replacement and updates, please contact the EMQ business team.
74 changes: 63 additions & 11 deletions en_US/streaming-processing/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Rules `sql` define the streams or tables to be processed and how to process them

The simplest rule SQL is `SELECT * FROM neuronStream`. This rule will get all the data from the `neuronStream` data stream. NeuronEX provides a wealth of operators and functions. For more usage, please see the [SQL](./sqls/overview.md) chapter.

Click the **SQL Examples** button to view commonly used SQL examples, where you can get SQL statements, application scenarios, input message examples, and processing results.

## Add action (Sink)

The action (Sink) part defines the output behavior of a rule. Each rule can have multiple actions.
Expand All @@ -59,26 +61,33 @@ In the **Actions** area, click the **Add** button.

After completing the settings, click **Test Connection**. After confirming the settings, click **Submit** to complete the creation of the action.

:::tip Tips
Only the test connection function is provided for MQTT. Click the **Test Connection**. After confirming the settings, click **Submit** to complete the creation of the action.
:::


## Resuorce Examples
You can view the created data sources and usage examples.

## Rule options (optional)

Click the **Options** section to continue configuring the current rules:

| Option name | Type & Default Value | Description |
| ------------------ | -------------------- | ------------------------------------------------------------ |
| debug | bool: false | Specify whether to enable the debug level for this rule. By default, it will inherit the Debug configuration parameters in the global configuration. |
| logFilename | string: "" | Specify the name of a separate log file for this rule, and the log will be saved in the global log folder. By default, the log configuration parameters in the global configuration will be used. |
| isEventTime | boolean: false | Whether to use event time or processing time as the timestamp for an event. If event time is used, the timestamp will be extracted from the payload. |
| lateTolerance | int64:0 | When working with event-time windowing, it can happen that elements arrive late. LateTolerance can specify by how much time(unit is millisecond) elements can be late before they are dropped. By default, the value is 0 which means late elements are dropped. |
| concurrency | int: 1 | A rule is processed by several phases of plans according to the sql statement. This option will specify how many instances will be run for each plan. If the value is bigger than 1, the order of the messages may not be retained. |
| bufferLength | int: 1024 | Specify how many messages can be buffered in memory for each plan. If the buffered messages exceed the limit, the plan will block message receiving until the buffered messages have been sent out so that the buffered size is less than the limit. A bigger value will accommodate more throughput but will also take up more memory footprint. |
| debug | bool: false | Specify whether to enable the debug level for this rule. By default, it will inherit the Debug configuration parameters in the global configuration. |
| sendMetaToSink | bool:false | Specify whether the meta data of an event will be sent to the sink. If true, the sink can get te meta data information. |
| sendError | bool: true | Whether to send the error to sink. If true, any runtime error will be sent through the whole rule into sinks. Otherwise, the error will only be printed out in the log. |
| isEventTime | boolean: false | Whether to use event time or processing time as the timestamp for an event. If event time is used, the timestamp will be extracted from the payload. |
| lateTolerance | int64:0 | When working with event-time windowing, it can happen that elements arrive late. LateTolerance can specify by how much time(unit is millisecond) elements can be late before they are dropped. By default, the value is 0 which means late elements are dropped. |
| qos | int:0 | Specify the qos of the stream. The options are 0: At most once; 1: At least once and 2: Exactly once. If qos is bigger than 0, the checkpoint mechanism will be activated to save states periodically so that the rule can be resumed from errors. |
| checkpointInterval | int:300000 | Specify the time interval in milliseconds to trigger a checkpoint. This is only effective when qos is bigger than 0. |
| restartStrategy | struct | Specify the strategy to automatic restarting rule after failures. This can help to get over recoverable failures without manual operations. Please check [Rule Restart Strategy](#rule-restart-strategy) for detail configuration items. |
| cron | string: "" | Specify the periodic trigger strategy of the rule, which is described by [cron expression](https://en.wikipedia.org/wiki/Cron) |
| duration | string: "" | Specifies the running duration of the rule, only valid when cron is specified. The duration should not exceed the time interval between two cron cycles, otherwise it will cause unexpected behavior. |
| cronDatetimeRange | lists of struct | Specify the effective time period of the Scheduled Rule, which is only valid when `cron` is specified. When this `cronDatetimeRange` is specified, the Scheduled Rule will only take effect within the time range specified. Please see [Scheduled Rule](#Scheduled Rule) for detailed configuration items |
| attempts | int: 0 | Maximum number of retries. If set to 0, the rule will fail immediately without retrying. |
| delay | int: 1000 | Default retry interval in milliseconds. If the multiplier is not set, the retry interval will be fixed to this value. |
| maxDelay | int: 30000 | The maximum interval between retries, in milliseconds. This only takes effect if the multiplier is set so that the delay is increased for each retry. |
| multiplier | float: 2 | Multiplier for the retry interval. |
| jitterFactor | float: 0.1 | Adds or subtracts a random value coefficient to the delay to prevent multiple rules from being restarted at the same time. |


:::tip Tips
Expand All @@ -87,8 +96,51 @@ In most scenarios, the default values for rule options are sufficient.

After completing the settings, click **Submit** to complete the creation of the current rules. The new rule will appear in the rules list. Here you can view rule status, edit rules, stop rules, refresh rules, view rule topology map, copy rules or delete rules.



## Rule test
Enable Test
- Close simulate data source

1. Click **Run Test** to output the results on the right.

2. The data template can be configured to simulate the Data Template in Sink and modify the data format of the output after SQL statement processing.

3. Click **Stop** to stop testing.

- Open simulate data source

1. Select a data source in SQL for simulation. Click the plus sign to add multiple simulation data sources.

2. interval: set the sending interval, and receive test results according to the sending interval.

3. Send Cyclically: Enable cyclic sending to receive test results continuously.

4. Simulation data supports "multiple lines and one json", "single line and one json", and "multiple lines and single line and one json".

- multiple lines in one json
```json
{
"ts" : 1672545661000,
"tag1" : "area1",
"value1" : 123
}
```
- single line in one json
```json
{"ts" : 1672545661000, "tag1" : "area1", "value1" : 1}
```
- multiple lines and single line is one json
```json
{"ts" : 1672545661000, "tag1" : "area1", "value1" : 1}
{"ts" : 1672545662000, "tag1" : "area1", "value1" : 2}
{"ts" : 1672545663000, "tag1" : "area1", "value1" : 3}
{"ts" : 1672545664000, "tag1" : "area1", "value1" : 4}
{"ts" : 1672545665000, "tag1" : "area1", "value1" : 5}
```
5. Click **Run Test** to output the results on the right.

6. The data template can be configured to simulate the Data Template in Sink and modify the data format of the output after SQL statement processing.

7. Click **Stop** to stop testing.
## Import and export rules

In the NeuronEX web UI, click **Data Processing** -> **Rules**. Click the **Import Rules** button. In the pop-up window, you can choose:
Expand Down
28 changes: 28 additions & 0 deletions en_US/streaming-processing/simulator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Simulator

<span style="background:green;color:white;padding:1px;margin:2px">Stream</span>
<span style="background:green;color:white;padding:1px;margin:2px">Scan table</span>

The NeuronEX data processing module can generate simulation data through the `Simulator` type of data source and provide a test data source when creating or updating rules.

## Create stream

Log in to NeuronEX and click **Data Processing** -> **Source**. On the **Stream Management** tab, click **Create Stream**.

In the pop-up **Source**/**Create** page, enter the following configuration:

- **Stream Name**: Enter the stream name
- **Whether the schema stream**: Unchecked.
- **Stream Type**: Select simulator
- **Configuration key**: You can edit and use the default configuration key, or click to add a configuration key and make the following settings in the pop-up dialog box.

- **Name**: Enter the configuration key name.
- **Loop**: If set to true, multiple pieces of json data defined in data will be sent in a loop.
- **Interval**: The time interval (milliseconds) between sending requests.
- **Message**: Customize json format message content and support defining multiple json messages.

- **Stream format**: supports json, binary, protobuf, delimited, custom. Select json format.
- **Shared**: Check to confirm whether to share the source.



13 changes: 9 additions & 4 deletions en_US/streaming-processing/sink/sink.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,17 @@ You can click to expand the **Advanced** section for more customized settings.

- **Concurrency**: Set the number of running threads. When the parameter value is greater than 1, the order in which messages are sent may not be guaranteed.
- **Buffer Length**: Set the number of cacheable messages. If the number of cached messages exceeds this limit, the sink will block message reception until the number of cached messages is less than the limit.
- **Buffer Size**: Set the number of messages sent in batches.
- **Linger Interval**: Set the interval for batch sending, in milliseconds.
- **Enable Cache**: Set whether to enable caching, optional values True, False
- **Clean Cache At Stop**: Set whether to clear the cache when stopping, optional values are True and False
- **Memory Cache Threshold**: The maximum number of messages cached in memory.
- **Resend Interval**: The interval in millisecond to resend the cached messages.
- **Memory Cache Threshold**: The maximum number of messages to be cached in memory.
- **Max Disk Cache**: The maximum number of messages cached on disk.
- **Resend Interval**: The time interval (milliseconds) for resending cached messages.

- **Clean Cache At Stop**: Whether to clean the cache when the rule stops.
- **Resend Alter Queue**: Whether to use the backup queue when resending cache. If set to true, cache will be sent to the alternate queue instead of the original queue. This will cause real-time messages and resent messages to be sent using different queues, and the order of the messages will change, but it can prevent message storms. The following resend related configurations can only take effect when set to true.
- **Resend Priority**: The priority of the resend cache, type int, default is 0. -1 means sending real-time data first; 0 means equal priority; 1 means sending cached data first.
- **Resend Indicator Field**: Resend cached field names.
- **Resend Destination**: MQTT sink: This attribute indicates the topic of retransmission. If not set, it will still be passed to the original theme.

## Data cache

Expand Down
1 change: 1 addition & 0 deletions en_US/streaming-processing/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Currently NeuronEX has the following built-in data source types and the loading
| [SQL](./sql.md) | Query data from the database ||||
| [File](./file.md) | Read data from a file ||||
| [Video](./video.md) | Query data from video stream ||||
| [Simulator](./simulator.md) | Generate simulated data for testing ||||

## Define and run

Expand Down
Binary file modified zh_CN/configuration/.DS_Store
Binary file not shown.
Binary file added zh_CN/configuration/_assets/plugin_add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zh_CN/configuration/_assets/plugin_options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zh_CN/configuration/_assets/plugin_update.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions zh_CN/configuration/ecp_edge_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

## 查看可用插件模块

插件管理页面显示所有可用的可插拔模块和详细信息,包括插件名称、关联节点类型、和描述信息,如下图所示,您可从下拉框中选择北向应用或南向设备的插件。
插件管理页面显示所有可用的可插拔模块和详细信息,包括插件名称、关联节点类型、插件类别、插件版本和描述信息,如下图所示,您可从下拉框中选择北向应用或南向设备的插件。

![plugin-options](./_assets/plugin-options.png)
![plugin-options](./_assets/plugin_options.png)

插件类型包括以下三种模式:

Expand All @@ -19,12 +19,16 @@

## 添加新的可插拔模块

在插件页面,点击左上角的**添加插件**按钮,上传本地的插件 .so 文件。
在插件页面,点击左上角的**添加插件**按钮,上传本地的插件 .so 文件和 .json 文件。

![plugin-options](./_assets/plugin_add.png)

具体的插件开发教程请参考 [SKD 教程](https://neugates.io/docs/zh/latest/dev-guide/sdk-tutorial/sdk-tutorial.html)

## 替换已有插件模块

在插件页面,点击每个插件卡片上的**替换**按钮,上传本地的插件 .so 文件。
在插件页面,点击每个插件卡片上的**替换插件**按钮,上传本地的插件 .so 文件和 .json 文件。

![plugin-options](./_assets/plugin_update.png)

具体的插件替换更新,请联系EMQ商务团队。
Loading

0 comments on commit a5a59c3

Please sign in to comment.