使用带有架构注册表的 ruby gem avro turf 编码数据时出现错误 "unknown keyword: version"

Got error "unknown keyword: version" when encode data using ruby gem avro turf with schema registry

我用过Rubygemavro_turf将数据转成二进制发布到Kafka。但是在尝试编码数据时出现错误 unknown keyword: version。 我在 localhost:8081 上启动了 Confluent Schema Registry。我可以在终端上创建和阅读主题。

我扫描它的source code,编码函数中有一个"version"参数。

我 curl curl -X GET http://127.0.0.1:8081/subjects/avro-test/versions/1 到 Schema Registry 并获取此数据

{"subject":"avro-test","version":1,"id":1,"schema":"{\"type\":\"record\",\"name\":\"evolution\",\"namespace\":\"com.landoop\",\"doc\":\"This is a sample Avro schema to get you started. Please edit\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"phone\",\"type\":\"string\"},{\"name\":\"email\",\"type\":\"string\"}]}"}

这是我当前的代码

require "avro_turf/messaging"

avro = AvroTurf::Messaging.new(registry_url: "http://localhost:8081/")

data = avro.encode('{ "name" => "hello, world", "phone": "01232323", "email": "hello@gmail.com" }', subject: 'avro-test', version: 1)

请帮我解决。

I scan its source code, there is a "version" param in encode function.

是的,问题是,您正在查看 master 分支的当前状态。截至目前,它包含未发布的更改,包括此关键字。

所以要么等下个版本发布,要么直接用master

gem "avro_turf", github: "dasch/avro_turf"