Skip to content

Instantly share code, notes, and snippets.

@dangets
Created June 28, 2018 15:14
Show Gist options
  • Save dangets/10fb58858fbdb039c7f03e7f09917719 to your computer and use it in GitHub Desktop.
Save dangets/10fb58858fbdb039c7f03e7f09917719 to your computer and use it in GitHub Desktop.
Avro Union Types
[
{ "namespace": "com.dangets.customer",
"type": "record",
"name": "Address",
"fields": [
{"name": "receiver", "type": "string"},
{"name": "streetAddress", "type": "string"},
{"name": "addressLocality", "type": "string"},
{"name": "addressRegion", "type": "string"},
{"name": "postalCode", "type": "string"}
]
},
{ "namespace": "com.dangets.customer",
"type": "record",
"name": "CustomerCreated",
"fields": [
{"name": "customerId", "type": "int"},
{"name": "name", "type": "string"},
{"name": "address", "type": "Address"}
]
},
{ "namespace": "com.dangets.customer",
"type": "record",
"name": "CustomerAddressChanged",
"fields": [
{"name": "customerId", "type": "int"},
{"name": "newAddress", "type": "Address"}
]
},
{ "namespace": "com.dangets.customer",
"type": "record",
"name": "CustomerInvoicePaid",
"fields": [
{"name": "customerId", "type": "int"},
{"name": "invoiceId", "type": "long"}
]
},
{ "namespace": "com.dangets.customer",
"type": "record",
"name": "CustomerEvent",
"fields": [
{"name": "customerId", "type": "int"},
{"name": "event", "type": ["CustomerCreated", "CustomerAddressChanged", "CustomerInvoicePaid"] }
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment