You can use Tablestore CLI to create and manage tunnels that consume incremental, full, or full-plus-incremental data from data tables.
Prerequisites
-
Tablestore CLI installed and access credentials configured. For more information, see Tablestore CLI.
-
A data table with Stream (the data change log feature) enabled. For more information, see Data table operations.
Create a tunnel
Run the following command to create a tunnel for a data table.
create_tunnel -n <tunnelName>
|
Parameter |
Required |
Description |
|
-t, --table |
No |
The name of the data table. Not required if you have already selected a data table by using the |
|
-n, --name |
Yes |
The name of the tunnel. |
|
-m, --mode |
No |
The tunnel type. Valid values:
|
Example
Create a tunnel named t1 for a data table.
create_tunnel -n t1
Sample output:
New tunnel created, its id is '9933470d-8a5e-4972-a5b0-b7ae6f836460'.
List tunnels
Run the following command to list all tunnels for a data table.
list_tunnel
|
Parameter |
Required |
Description |
|
-t, --table |
No |
The name of the data table. Not required if you have already selected a data table by using the |
Example
list_tunnel
View tunnel details
Run the following command to view tunnel and channel details.
describe_tunnel -n <tunnelName>
|
Parameter |
Required |
Description |
|
-t, --table |
No |
The name of the data table. Not required if you have already selected a data table by using the |
|
-n, --name |
Yes |
The name of the tunnel. |
|
-o, --output |
No |
Saves the output to a local file. |
Example
View the details of the t1 tunnel.
describe_tunnel -n t1
Sample output:
Tunnel Info:
+--------------------------------------+------------+------------+---------------+---------+
| TunnelId | TunnelName | TunnelType | Stage | Expired |
+--------------------------------------+------------+------------+---------------+---------+
| 9933470d-8a5e-4972-a5b0-b7ae6f836460 | t1 | Stream | ProcessStream | false |
+--------------------------------------+------------+------------+---------------+---------+
Channel Info:
+-------------------------------------------------------+-------------+---------------+----------+-------------------------------+
| ChannelId | ChannelType | ChannelStatus | ClientId | ChannelRPO |
+-------------------------------------------------------+-------------+---------------+----------+-------------------------------+
| cfd2c05b-54b6-48ec-aa6f-feb427f0ca57_1635771329155688 | Stream | OPEN | | 1970-01-01 08:00:00 +0800 CST |
+-------------------------------------------------------+-------------+---------------+----------+-------------------------------+
Simulate tunnel consumption
Run a simulated consumption to preview the data format in a tunnel.
consume_tunnel -n <tunnelName> -m mock_consume
|
Parameter |
Required |
Description |
|
-c, --channel |
No |
The channel ID. If not specified, all channels are consumed. |
|
-t, --table |
No |
The name of the data table. Not required if you have already selected a data table by using the |
|
-n, --name |
Yes |
The name of the tunnel. |
|
-m, --mode |
Yes |
The consumption mode. Valid values:
|
Example
Simulate data consumption on the t1 tunnel.
consume_tunnel -n t1 -m mock_consume
After you run the command, the CLI waits for incoming data. When data is written to the table, the consumption records appear in the output. Sample output:
{"Type":0,"Timestamp":1636360028961786,"SequenceInfo":{"Epoch":0,"Timestamp":1636360028961786,"RowIndex":1},"PrimaryKey":{"PrimaryKeys":[{"ColumnName":"uid","Value":"86"},{"ColumnName":"pid","Value":6771}]},"Columns":[{"Type":0,"Name":"name","Value":"redchen","Timestamp":1636360028962},{"Type":0,"Name":"country","Value":"china","Timestamp":1636360028962}]}
Delete a tunnel
Run the following command to delete a tunnel from a data table.
drop_tunnel -n <tunnelName> -y
|
Parameter |
Required |
Description |
|
-t, --table |
No |
The name of the data table. Not required if you have already selected a data table by using the |
|
-n, --name |
Yes |
The name of the tunnel. |
|
-y, --yes |
Yes |
Skips the interactive confirmation prompt and proceeds with the deletion. |
Example
Delete the t1 tunnel.
drop_tunnel -n t1 -y