|
| 1 | +# Redis |
| 2 | + |
| 3 | +> Redis source connector |
| 4 | +
|
| 5 | +## Description |
| 6 | + |
| 7 | +Used to read data from Redis. Only support batch mode. |
| 8 | + |
| 9 | +## Options |
| 10 | + |
| 11 | +| name | type | required | default value | |
| 12 | +|-----------|--------|----------|---------------| |
| 13 | +| host | string | yes | - | |
| 14 | +| port | int | yes | - | |
| 15 | +| keys | string | yes | - | |
| 16 | +| data_type | string | yes | - | |
| 17 | +| auth | string | No | - | |
| 18 | +| schema | config | No | - | |
| 19 | +| format | string | No | json | |
| 20 | + |
| 21 | +### host [string] |
| 22 | + |
| 23 | +redis host |
| 24 | + |
| 25 | +### port [int] |
| 26 | + |
| 27 | +redis port |
| 28 | + |
| 29 | +### keys [string] |
| 30 | + |
| 31 | +keys pattern |
| 32 | + |
| 33 | +**Tips:Redis source connector support fuzzy key matching, user needs to ensure that the matched keys are the same type** |
| 34 | + |
| 35 | +### data_type [string] |
| 36 | + |
| 37 | +redis data types, support `key` `hash` `list` `set` `zset` |
| 38 | + |
| 39 | +- key |
| 40 | +> The value of each key will be sent downstream as a single row of data. |
| 41 | +> For example, the value of key is `SeaTunnel test message`, the data received downstream is `SeaTunnel test message` and only one message will be received. |
| 42 | +
|
| 43 | + |
| 44 | +- hash |
| 45 | +> The hash key-value pairs will be formatted as json to be sent downstream as a single row of data. |
| 46 | +> For example, the value of hash is `name:tyrantlucifer age:26`, the data received downstream is `{"name":"tyrantlucifer", "age":"26"}` and only one message will be received. |
| 47 | +
|
| 48 | +- list |
| 49 | +> Each element in the list will be sent downstream as a single row of data. |
| 50 | +> For example, the value of list is `[tyrantlucier, CalvinKirs]`, the data received downstream are `tyrantlucifer` and `CalvinKirs` and only two message will be received. |
| 51 | +
|
| 52 | +- set |
| 53 | +> Each element in the set will be sent downstream as a single row of data |
| 54 | +> For example, the value of set is `[tyrantlucier, CalvinKirs]`, the data received downstream are `tyrantlucifer` and `CalvinKirs` and only two message will be received. |
| 55 | +
|
| 56 | +- zset |
| 57 | +> Each element in the sorted set will be sent downstream as a single row of data |
| 58 | +> For example, the value of sorted set is `[tyrantlucier, CalvinKirs]`, the data received downstream are `tyrantlucifer` and `CalvinKirs` and only two message will be received. |
| 59 | +
|
| 60 | +### auth [String] |
| 61 | + |
| 62 | +redis authentication password, you need it when you connect to an encrypted cluster |
| 63 | + |
| 64 | +### format [String] |
| 65 | + |
| 66 | +the format of upstream data, now only support `json` `text`, default `json`. |
| 67 | + |
| 68 | +when you assign format is `json`, you should also assign schema option, for example: |
| 69 | + |
| 70 | +upstream data is the following: |
| 71 | + |
| 72 | +```json |
| 73 | + |
| 74 | +{"code": 200, "data": "get success", "success": true} |
| 75 | + |
| 76 | +``` |
| 77 | + |
| 78 | +you should assign schema as the following: |
| 79 | + |
| 80 | +```hocon |
| 81 | +
|
| 82 | +schema { |
| 83 | + fields { |
| 84 | + code = int |
| 85 | + data = string |
| 86 | + success = boolean |
| 87 | + } |
| 88 | +} |
| 89 | +
|
| 90 | +``` |
| 91 | + |
| 92 | +connector will generate data as the following: |
| 93 | + |
| 94 | +| code | data | success | |
| 95 | +|------|-------------|---------| |
| 96 | +| 200 | get success | true | |
| 97 | + |
| 98 | +when you assign format is `text`, connector will do nothing for upstream data, for example: |
| 99 | + |
| 100 | +upstream data is the following: |
| 101 | + |
| 102 | +```json |
| 103 | + |
| 104 | +{"code": 200, "data": "get success", "success": true} |
| 105 | + |
| 106 | +``` |
| 107 | + |
| 108 | +connector will generate data as the following: |
| 109 | + |
| 110 | +| content | |
| 111 | +|---------| |
| 112 | +| {"code": 200, "data": "get success", "success": true} | |
| 113 | + |
| 114 | +### schema [Config] |
| 115 | + |
| 116 | +#### fields [Config] |
| 117 | + |
| 118 | +the schema fields of upstream data |
| 119 | + |
| 120 | +## Example |
| 121 | + |
| 122 | +simple: |
| 123 | + |
| 124 | +```hocon |
| 125 | + Redis { |
| 126 | + host = localhost |
| 127 | + port = 6379 |
| 128 | + keys = "key_test*" |
| 129 | + data_type = key |
| 130 | + format = text |
| 131 | + } |
| 132 | +``` |
| 133 | + |
| 134 | +```hocon |
| 135 | + Redis { |
| 136 | + host = localhost |
| 137 | + port = 6379 |
| 138 | + keys = "key_test*" |
| 139 | + data_type = key |
| 140 | + format = json |
| 141 | + schema { |
| 142 | + fields { |
| 143 | + name = string |
| 144 | + age = int |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | +``` |
| 149 | + |
0 commit comments