index.ts
5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import { FormSchema } from '/@/components/Form';
/**
* Kafka表单相关默认值配置
*/
class KafkaFormPartialConfig {
static topicPattern = 'my-topic'; //消息主题默认值
static bootstrapServers = 'localhost:9092'; //服务器
static retries = 0; //重连次数
static batchSize = 16384; //生产者并发
static linger = 0; //缓存时间
static bufferMemory = 33554432; //最大缓存
static acks = '-1'; //响应码
static keySerializer = 'org.apache.kafka.common.serialization.StringSerializer'; //键序列化
static valueSerializer = 'org.apache.kafka.common.serialization.StringSerializer'; //值序列化
static kafkaHeadersCharset = 'UTF-8'; //字符集
//acks Select options配置
static getAcks() {
return [
{ label: 'all', value: 'all' },
{ label: '-1', value: '-1' },
{ label: '0', value: '0' },
{ label: '1', value: '1' },
];
}
//kafkaHeadersCharset Select options配置
static getkafkaHeadersCharset() {
return [
{ label: 'US-ASCII', value: 'US' },
{ label: 'ISO-8859-1', value: 'ISO-8859-1' },
{ label: 'UTF-8', value: 'UTF-8' },
{ label: 'UTF-16BE', value: 'UTF-16BE' },
{ label: 'UTF-16LE', value: 'UTF-16LE' },
{ label: 'UTF-16', value: 'UTF-16' },
];
}
}
export const modelKafkaForm: FormSchema[] = [
{
field: 'name',
label: '名称',
colProps: { span: 12 },
required: true,
component: 'Input',
componentProps: {
maxLength: 255,
placeholder: '请输入名称',
},
},
{
field: 'topicPattern',
label: '消息主题',
colProps: { span: 12 },
required: true,
component: 'Input',
defaultValue: KafkaFormPartialConfig.topicPattern,
componentProps: {
maxLength: 255,
placeholder: '请输入消息主题',
},
},
{
field: 'bootstrapServers',
label: '服务器',
colProps: { span: 12 },
component: 'Input',
defaultValue: KafkaFormPartialConfig.bootstrapServers,
required: true,
componentProps: {
maxLength: 255,
placeholder: 'localhost:9092',
},
},
{
field: 'retries',
label: '重连次数',
colProps: { span: 12 },
component: 'InputNumber',
defaultValue: KafkaFormPartialConfig.retries,
componentProps: {
maxLength: 255,
},
},
{
field: 'batchSize',
label: '生产者并发',
colProps: { span: 12 },
component: 'InputNumber',
defaultValue: KafkaFormPartialConfig.batchSize,
componentProps: {
maxLength: 255,
},
},
{
field: 'linger',
label: '缓存时间',
colProps: { span: 12 },
component: 'InputNumber',
defaultValue: KafkaFormPartialConfig.linger,
componentProps: {
maxLength: 255,
},
},
{
field: 'bufferMemory',
label: '最大缓存',
colProps: { span: 12 },
component: 'InputNumber',
defaultValue: KafkaFormPartialConfig.bufferMemory,
componentProps: {
maxLength: 255,
},
},
{
field: 'acks',
component: 'Select',
label: '响应码',
colProps: { span: 12 },
defaultValue: KafkaFormPartialConfig.acks,
componentProps: {
placeholder: '请选择响应码',
options: KafkaFormPartialConfig.getAcks(),
},
},
{
field: 'keySerializer',
label: '键序列化',
colProps: { span: 24 },
required: true,
component: 'Input',
defaultValue: KafkaFormPartialConfig.keySerializer,
componentProps: {
maxLength: 255,
placeholder: 'org.apache.kafka.common.serialization.StringSerializer',
},
},
{
field: 'valueSerializer',
label: '值序列化',
colProps: { span: 24 },
required: true,
component: 'Input',
defaultValue: KafkaFormPartialConfig.valueSerializer,
componentProps: {
maxLength: 255,
placeholder: 'org.apache.kafka.common.serialization.StringSerializer',
},
},
{
field: 'otherProperties',
label: '其他属性',
colProps: { span: 24 },
component: 'JAddInput',
},
{
field: 'addMetadataKeyValuesAsKafkaHeaders',
label: '是否启用',
colProps: { span: 12 },
component: 'Checkbox',
renderComponentContent: '将消息的元数据以键值对的方式添加到Kafka消息头中',
},
{
field: 'kafkaHeadersCharset',
component: 'Select',
label: '字符集',
required: true,
colProps: { span: 12 },
defaultValue: KafkaFormPartialConfig.kafkaHeadersCharset,
componentProps: {
placeholder: '请选择字符集编码',
options: KafkaFormPartialConfig.getkafkaHeadersCharset(),
},
ifShow: ({ values }) => {
return !!values.addMetadataKeyValuesAsKafkaHeaders;
},
},
{
field: 'description',
label: '说明',
colProps: { span: 24 },
component: 'InputTextArea',
componentProps: {
maxLength: 255,
rows: 4,
placeholder: '请输入说明',
},
},
];