Json 我们可以使用;其中一个;在合流平台模式注册表中?
我有一个用户余额变化的用例。我想将所有用户平衡事件放在一个主题中。但由于诸如推荐奖金、赢取奖金、取款、存款等多个事件,用户余额正在发生变化。这可以通过以下嵌套记录实现:Json 我们可以使用;其中一个;在合流平台模式注册表中?,json,apache-kafka,avro,confluent-platform,Json,Apache Kafka,Avro,Confluent Platform,我有一个用户余额变化的用例。我想将所有用户平衡事件放在一个主题中。但由于诸如推荐奖金、赢取奖金、取款、存款等多个事件,用户余额正在发生变化。这可以通过以下嵌套记录实现: { "name": "userBalance", "type": "record", "fields": [ { "name": "cashDeposit", "type": {
{
"name": "userBalance",
"type": "record",
"fields": [
{
"name": "cashDeposit",
"type":
{
"type" : "record",
"name" : "userCashDeposit",
"fields" : [
{"name": "id", "type": "long"},
{"name": "amount", "type": "float"}
]
}
},
{
"name": "cashWithdraw",
"type": {
"type" : "record",
"name" : "userCashWithdraw",
"fields" : [
{"name": "id", "type": "long"},
{"name": "amount", "type": "float"}
]
}
}
]
}
但这会使所有嵌套记录都符合要求,同时我希望严格实现这些事件中的任何一个都会出现在事件中,并严格遵守该事件的记录。Avro模式支持“oneOf”,但我找不到在任何地方用于汇合模式注册表用例的oneOf。有什么方法可以使用它吗?这可以工作:
{
"name": "userBalance",
"type": "record",
"fields": [
{
"name": "userBalance",
"type": [
{
"type" : "record",
"name" : "userCashDeposit",
"fields" : [
{"name": "id", "type": "long"},
{"name": "amount", "type": "float"}
]
},
{
"type" : "record",
"name" : "userCashWithdraw",
"fields" : [
{"name": "id", "type": "long"},
{"name": "amount", "type": "float"}
]
}
]
}
]
}