Confluent Schema Registry与Go应用程序

huangapple 未分类评论72阅读模式
英文:

Confluent Schema registry with Go application

问题

我理解到你想要将Confluent Schema Registry(CSR)与一个Golang应用程序集成。你的设置如下所示:
客户端C连接到服务器S1(Go应用程序),S1将数据写入另一个服务器S2。
C -> S1 -> S2

我想要将CSR与S1集成,这样当C提交任何写入请求到S1时,S1将使用CSR根据相应的模式验证提交的数据。如果数据有效,S1将将数据转发到S2。在这里,客户端C对CSR一无所知。
是否可以进行这样的集成?我找到的所有文档都是关于如何使用CSR将数据发布到Kafka。

为了进行这样的集成,我需要一个CSR的库。使用具有REST API的独立的CSR应用程序将不起作用,因为如果我对每个提交给S1的写入请求进行API调用,将会有巨大的网络开销。因此,我希望使用已经允许从独立的CSR服务器缓存数据并在本地进行验证的SDK/库。

如果有Java中的类似解决方案,那也可以。

英文:

I understand that Confluent Schema Registry(CSR) uses kafka for schema storage. I am trying to integrate CSR with a golang application. My set up is as follows:
Client C connects to Server S1(go app), S1 writes to another server S2.
C -> S1->S2

I want to integrate CSR with S1 such that when C submits any write to S1, S1 will use CSR to validate the submitted data against the respective schema. If it is valid, S1 will forward data to S2. Client C does not know anything about CSR here.
Can such an integration be done? All documentation I could find was about how to use CSR for publishing data into kafka.

For such an integration, I would need a library of CSR. Using CSR as standalone application with REST APIs will not work since there will be huge network overhead if I make an API call to CSR for every write request submitted to S1. So I want to use sdk/library which already allows to cache the data from CSR standalone server, and can do validations locally.

If there is anything such in java, that will also work.

答案1

得分: 0

> 将CSR与golang应用程序集成

这是一个基于Java的独立服务器。它不能在Golang中“嵌入”。您需要使用REST来与其集成。

> 客户端C对CSR一无所知

请求的两端的客户端(通常是Kafka主题)需要知道注册表,以便通过存储的模式对数据进行序列化和反序列化。否则,您可以将模式定义嵌入到每个应用程序中,或者使用其他远程HTTP服务,而不需要使用Kafka。

> 如果我对每个提交给S1的写入请求都进行API调用,将会有巨大的网络开销。

注册表REST客户端会缓存所有看到的模式,并且不会在“每个请求”上进行调用(至少在与KafkaAvroDeserializer一起提供的Java实现中)。


总的来说,听起来您应该使用OpenAPI或gRPC,而不是Confluent Schema Registry,因为您没有提到您想要使用Kafka,只是想要验证服务之间的请求。如果您将这些网络调用替换为Kafka生产者/消费者请求,那么设置基于Kafka的模式注册表就有意义了。

英文:

> integrate CSR with a golang application

It's a Java-based standalone server. It cannot be "embedded" in Golang. You need to use REST to integrate with it.

> Client C does not know anything about CSR

Clients on both sides of the request (most commonly, a Kafka topic) need to be aware of the Registry in order to both serialize and deserialize the data via a stored schema. Otherwise, you can embed the schema definitions within each app, or some other remote HTTP service, and not need Kafka at all.

> there will be huge network overhead if I make an API call to CSR for every write request submitted to S1.

The Registry REST Client caches all schemas it sees, and does not make a call "every request" (at least the Java implementation included with KafkaAvroDeserializer).


Overall, sounds like you should be using OpenAPI, or gRPC. Not Confluent Schema Registry since you did not mention you wanted to use Kafka, only to validate your service-to-service requests... If you replaced those network calls with Kafka producer/consumer requests instead, then it would make sense to setup a kafka-based Schema Registry.

huangapple
  • 本文由 发表于 2022年8月11日 16:03:26
  • 转载请务必保留本文链接:https://java.coder-hub.com/73317264.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定