如何使用 Golang 从 Azure eventhub 获取架构

How to fetch the schema from Azure eventhub using Golang

我在 eventhub 中创建了模式,我正在使用“github.com/Azure/azure-event-hubs-go/v3”包来使用 Go 接收消息和向 eventhub 发送消息。

如何使用 Schema serialize/deserialize 发送或接收的数据?

访问模式不依赖于正在使用的消息队列。

为了获取 avro 模式,我们可以使用标准 net/http 包,因为有 API 可以 return 模式。

URL 的格式如下:

如果知道 avro 主题和版本:

https://<schema_registry_url>/subjects/<subject_name>/versions/<version_number>

If the latest version schema is required `<version_number>` can be replaced with `latest`

如果架构 ID 已知:

https://<schema_registry_url>/schemas/ids/<id>