Skip to content

Commit 5e87b68

Browse files
committed
fix: improve kafka-enhance configuration
1 parent 414ceda commit 5e87b68

File tree

3 files changed

+145
-140
lines changed

3 files changed

+145
-140
lines changed

connectors/kafka-enhanced-connector/src/main/java/io/tapdata/kafka/KafkaConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public KafkaSchemaMode getConnectionSchemaMode() {
6060
}
6161

6262
public String getConnectionScript() {
63-
return connectionConfigGet("script", "");
63+
return connectionConfigGet("analyzeScript", "");
6464
}
6565

6666
public String getNodeScript() {
67-
return nodeConfigGet("script", "");
67+
return nodeConfigGet("processScript", "");
6868
}
6969

7070
public KafkaSchemaMode getNodeSchemaMode() {

connectors/kafka-enhanced-connector/src/main/java/io/tapdata/kafka/schema_mode/CustomSchemaMode.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,20 @@ public List<ProducerRecord<Object, Object>> fromTapEvent(TapTable table, TapEven
162162
if (null == eventObj) {
163163
} else {
164164
Map<String, Object> res = (Map<String, Object>) eventObj;
165-
if (null == res.get("data")) {
166-
throw new RuntimeException("data cannot be null");
165+
if (null == res.get("value")) {
166+
throw new RuntimeException("value cannot be null");
167167
} else {
168-
Object obj = res.get("data");
168+
Object obj = res.get("value");
169169
if (obj instanceof Map) {
170-
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) res.get("data");
170+
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) res.get("value");
171171
if (map.containsKey("before") && map.get("before").isEmpty()) {
172172
map.remove("before");
173173
}
174174
if (map.containsKey("after") && map.get("after").isEmpty()) {
175175
map.remove("after");
176176
}
177-
res.put("data", map);
178-
body = TapSimplify.toJson(res.get("data"), JsonParser.ToJsonFeature.WriteMapNullValue);
177+
res.put("value", map);
178+
body = TapSimplify.toJson(res.get("value"), JsonParser.ToJsonFeature.WriteMapNullValue);
179179
} else {
180180
body = obj.toString();
181181
}

connectors/kafka-enhanced-connector/src/main/resources/spec_kafka_enhanced.json

Lines changed: 137 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,161 @@
3333
"x-decorator-props": {
3434
"tooltip": "${clusterURITip}"
3535
},
36+
"x-index": 1
37+
},
38+
"schemaRegister": {
39+
"type": "boolean",
40+
"title": "${schemaRegister}",
41+
"default": false,
42+
"x-decorator": "FormItem",
43+
"x-decorator-props": {
44+
"tooltip": "${schemaRegisterTip}"
45+
},
46+
"x-component": "Switch",
47+
"apiServerKey": "schemaRegister",
48+
"x-reactions": [
49+
{
50+
"target": "*(schemaRegisterUrl,registrySchemaType,basicAuth)",
51+
"fulfill": {
52+
"state": {
53+
"visible": "{{$self.value===true}}"
54+
}
55+
}
56+
},
57+
{
58+
"target": "*(schemaMode)",
59+
"fulfill": {
60+
"state": {
61+
"visible": "{{$self.value===false}}"
62+
}
63+
}
64+
}
65+
],
3666
"x-index": 2
3767
},
38-
"schemaMode": {
68+
"schemaRegisterUrl": {
69+
"required": true,
3970
"type": "string",
40-
"title": "${schemaMode}",
41-
"default": "TAP_STANDARD",
71+
"title": "${schemaRegisterUrl}",
72+
"x-decorator": "FormItem",
73+
"x-decorator-props": {
74+
"tooltip": "${schemaRegisterUrlTip}"
75+
},
76+
"x-component": "Input",
77+
"apiServerKey": "schemaRegisterUrl",
78+
"x-index": 3
79+
},
80+
"registrySchemaType": {
81+
"type": "string",
82+
"title": "${registrySchemaType}",
83+
"default": "JSON",
84+
"x-decorator": "FormItem",
85+
"x-component": "Select",
86+
"apiServerKey": "registrySchemaType",
87+
"x-index": 4,
88+
"enum": [
89+
{
90+
"label": "JSON",
91+
"value": "JSON"
92+
},
93+
{
94+
"label": "AVRO",
95+
"value": "AVRO"
96+
},
97+
{
98+
"label": "PROTOBUF",
99+
"value": "PROTOBUF"
100+
}
101+
]
102+
},
103+
"basicAuth": {
104+
"type": "boolean",
105+
"title": "${basicAuth}",
106+
"default": false,
107+
"x-decorator": "FormItem",
108+
"x-component": "Switch",
109+
"apiServerKey": "basicAuth",
110+
"x-reactions": [
111+
{
112+
"target": "*(authCredentialsSource,authUserName,authPassword)",
113+
"fulfill": {
114+
"state": {
115+
"visible": "{{$self.value===true}}"
116+
}
117+
}
118+
}
119+
],
120+
"x-index": 5
121+
},
122+
"authCredentialsSource": {
123+
"type": "string",
124+
"title": "${authCredentialsSource}",
125+
"default": "USER_INFO",
42126
"x-decorator": "FormItem",
43127
"x-component": "Radio.Group",
44128
"x-component-props": {
45129
"optionType": "button"
46130
},
47-
"x-index": 10,
131+
"x-index": 6,
48132
"enum": [
49133
{
50-
"label": "${schemaModeTapStandard}",
51-
"value": "TAP_STANDARD"
52-
},
53-
{
54-
"label": "${schemaModeOriginal}",
55-
"value": "ORIGINAL"
134+
"label": "USER_INFO",
135+
"value": "USER_INFO"
56136
},
57137
{
58-
"label": "${schemaModeCustom}",
59-
"value": "CUSTOM"
138+
"label": "SASL_INHERIT",
139+
"value": "SASL_INHERIT"
60140
}
61141
]
62142
},
63-
"script": {
143+
"authUserName": {
144+
"required": true,
145+
"type": "string",
146+
"title": "${authUserName}",
147+
"x-decorator": "FormItem",
148+
"x-component": "Input",
149+
"apiServerKey": "database_username",
150+
"x-index": 7
151+
},
152+
"authPassword": {
153+
"required": true,
154+
"type": "string",
155+
"title": "${authPassword}",
156+
"x-decorator": "FormItem",
157+
"x-component": "Password",
158+
"apiServerKey": "database_password",
159+
"x-index": 8
160+
},
161+
"schemaMode": {
162+
"type": "string",
163+
"title": "${schemaMode}",
164+
"x-decorator": "FormItem",
165+
"x-component": "Select",
166+
"default": "TAP_STANDARD",
167+
"enum": [
168+
{"label": "${schemaModeTapStandard}", "value": "TAP_STANDARD"},
169+
{"label": "${schemaModeOriginal}", "value": "ORIGINAL"},
170+
{"label": "${schemaModeCanal}", "value": "CANAL"},
171+
{"label": "${schemaModeDebezium}", "value": "DEBEZIUM"},
172+
{"label": "${schemaModeFlinkCDC}", "value": "FLINK_CDC"},
173+
{"label": "${schemaModeCustom}", "value": "CUSTOM"}
174+
],
175+
"x-index": 9
176+
},
177+
"analyzeScript": {
64178
"type": "string",
65179
"required": false,
66-
"default": "function analyze(head, key, value){\n\n\t\/\/ Enter your code at here\n\t return value;\n}",
180+
"default": "function analyze(header, key, value){\n\n\t\/\/ Enter your code at here\n\t return value;\n}",
67181
"x-decorator": "FormItem",
182+
"x-decorator-props": {
183+
"tooltip": "${analyzeScriptTip}"
184+
},
68185
"x-component": "JsEditor",
69186
"x-component-props": {
70187
"options": { "showPrintMargin": false, "useWrapMode": true },
71188
"includeBeforeAndAfter": true,
72-
"before": "function analyze(head, key, value){",
73-
"beforeRegexp": "^[^]*function\\s+analyze\\s*\\(head, key, value\\)\\{",
189+
"before": "function analyze(header, key, value){",
190+
"beforeRegexp": "^[^]*function\\s+analyze\\s*\\(header, key, value\\)\\{",
74191
"afterRegexp": "}[^}]*$",
75192
"after": "}"
76193
},
@@ -282,121 +399,6 @@
282399
"OPTIONAL_FIELDS": {
283400
"type": "void",
284401
"properties": {
285-
"schemaRegister": {
286-
"type": "boolean",
287-
"title": "${schemaRegister}",
288-
"default": false,
289-
"x-decorator": "FormItem",
290-
"x-decorator-props": {
291-
"tooltip": "${schemaRegisterTip}"
292-
},
293-
"x-component": "Switch",
294-
"apiServerKey": "schemaRegister",
295-
"x-reactions": [
296-
{
297-
"target": "*(schemaRegisterUrl,registrySchemaType,basicAuth)",
298-
"fulfill": {
299-
"state": {
300-
"visible": "{{$self.value===true}}"
301-
}
302-
}
303-
}
304-
],
305-
"x-index": 1
306-
},
307-
"schemaRegisterUrl": {
308-
"required": true,
309-
"type": "string",
310-
"title": "${schemaRegisterUrl}",
311-
"x-decorator": "FormItem",
312-
"x-decorator-props": {
313-
"tooltip": "${schemaRegisterUrlTip}"
314-
},
315-
"x-component": "Input",
316-
"apiServerKey": "schemaRegisterUrl",
317-
"x-index": 2
318-
},
319-
"registrySchemaType": {
320-
"type": "string",
321-
"title": "${registrySchemaType}",
322-
"default": "JSON",
323-
"x-decorator": "FormItem",
324-
"x-component": "Select",
325-
"apiServerKey": "registrySchemaType",
326-
"x-index": 3,
327-
"enum": [
328-
{
329-
"label": "JSON",
330-
"value": "JSON"
331-
},
332-
{
333-
"label": "AVRO",
334-
"value": "AVRO"
335-
},
336-
{
337-
"label": "PROTOBUF",
338-
"value": "PROTOBUF"
339-
}
340-
]
341-
},
342-
"basicAuth": {
343-
"type": "boolean",
344-
"title": "${basicAuth}",
345-
"default": false,
346-
"x-decorator": "FormItem",
347-
"x-component": "Switch",
348-
"apiServerKey": "basicAuth",
349-
"x-reactions": [
350-
{
351-
"target": "*(authCredentialsSource,authUserName,authPassword)",
352-
"fulfill": {
353-
"state": {
354-
"visible": "{{$self.value===true}}"
355-
}
356-
}
357-
}
358-
],
359-
"x-index": 4
360-
},
361-
"authCredentialsSource": {
362-
"type": "string",
363-
"title": "${authCredentialsSource}",
364-
"default": "USER_INFO",
365-
"x-decorator": "FormItem",
366-
"x-component": "Radio.Group",
367-
"x-component-props": {
368-
"optionType": "button"
369-
},
370-
"x-index": 5,
371-
"enum": [
372-
{
373-
"label": "USER_INFO",
374-
"value": "USER_INFO"
375-
},
376-
{
377-
"label": "SASL_INHERIT",
378-
"value": "SASL_INHERIT"
379-
}
380-
]
381-
},
382-
"authUserName": {
383-
"required": true,
384-
"type": "string",
385-
"title": "${authUserName}",
386-
"x-decorator": "FormItem",
387-
"x-component": "Input",
388-
"apiServerKey": "database_username",
389-
"x-index": 6
390-
},
391-
"authPassword": {
392-
"required": true,
393-
"type": "string",
394-
"title": "${authPassword}",
395-
"x-decorator": "FormItem",
396-
"x-component": "Password",
397-
"apiServerKey": "database_password",
398-
"x-index": 7
399-
},
400402
"kafkaSaslMechanism": {
401403
"type": "string",
402404
"title": "${kafkaSaslMechanism}",
@@ -756,11 +758,14 @@
756758
]
757759
}
758760
},
759-
"script": {
761+
"processScript": {
760762
"type": "string",
761763
"required": false,
762764
"default": "function process(record, op, conditionKeys){\n\n\t\/\/ Enter your code at here\n\t return record;\n}",
763765
"x-decorator": "FormItem",
766+
"x-decorator-props": {
767+
"tooltip": "${processScriptTip}"
768+
},
764769
"x-component": "JsEditor",
765770
"x-component-props": {
766771
"options": { "showPrintMargin": false, "useWrapMode": true },

0 commit comments

Comments
 (0)