We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kafkamq 提供一种插件机制:将数据([]byte)通过 HTTP 发送到外部handle,经过处理后再通过response返回行协议的json格式数据。实现定制化数据。
增加如下配置:(以最终配置为准)
http url
message_points
debug
threads
is_response_point
pipeline
header_check
外部插件有一些约束:
The text was updated successfully, but these errors were encountered:
kafkamq收到消息后,合并成一个包含100条消息的包,发送到指定的http url上,数据结构如下:
[ { "topic": "bfySpan", "value": "dmFsdWUx" }, { "topic": "bfySpan", "value": "dmFsdWUy" }, { "topic": "bfySpan", "value": "dmFsdWUz" }, { "topic": "bfySpan", "value": "dmFsdWU0" } ]
go 数据结构:
type KafkaMessage struct { Topic string `json:"topic"` Value []byte `json:"value"` } func TestMashellJson(t *testing.T) { messages := []KafkaMessage{ {Topic: "bfySpan", Value: []byte("value1")}, {Topic: "bfySpan", Value: []byte("value2")}, {Topic: "bfySpan", Value: []byte("value3")}, {Topic: "bfySpan", Value: []byte("value4")}, } // 将多个消息打包为HTTP请求的主体 jsonData, err := json.MarshalIndent(messages, "", " ") if err != nil { fmt.Println("Error marshaling JSON:", err) return } fmt.Println(string(jsonData)) }
response 如果返回数据,应该返回行协议的json格式:
[ { "measurement": "abc", "tags": { "t1": "b", "t2": "d" }, "fields": { "f1": 123, "f2": 3.4, "f3": "strval" }, "time": 1624550216 }, { "measurement": "def", "tags": { "t1": "b", "t2": "d" }, "fields": { "f1": 123, "f2": 3.4, "f3": "strval" }, "time": 1624550216 } ]
py 可以参考 GitHub InfulxDB-python
返回的 header 也应该说明该数据的类型:
X-category=tracing
datakit 支持数据类型
只要接收到数据 就代表kafkamq将数据发送成功,无论解析如何 就应该返回200, 后等待下一个请求。
如果解析失败,则建议将kafkamq配置中的debug=true 这时候,不会再进行json的组装和序列化。 而是 请求的body就是消息本身。
debug=true
多线程: http Handle 本身就是支持多线程,并且消息与消息之间没有顺序关系。
异步:kafkamq 在发送到py成功之后,不等待response code 200,立即接收下一个100条消息,等待py返回200后,马上再次发送。
按照上述方案,kafkamq 需要一天的开发的时间。
Sorry, something went wrong.
No branches or pull requests
kafkamq 提供一种插件机制:将数据([]byte)通过 HTTP 发送到外部handle,经过处理后再通过response返回行协议的json格式数据。实现定制化数据。
增加如下配置:(以最终配置为准)
http url
stringmessage_points
int 一次发送的消息点数debug
bool 值, 当开启debug功能,message_points
则无效,如果开启debug模式,则将原始byte数据发送,不再进行消息合并。threads
int 多线程工作is_response_point
是否将行协议数据发送回来pipeline
脚本header_check
特殊的头部检测(bfy定制化,并非通用)外部插件有一些约束:
The text was updated successfully, but these errors were encountered: