avro-builder
avro-builder copied to clipboard
how to share code in the DSL
Is there a way to import (or otherwize) bring in shared fields into a record? (if not..this would be soooo great)
e.g, like this
record :foobar do
required :highlight_id, :string
import '../shared/all_events'
end
Does the extends method do what you're looking for:
https://github.com/salsify/avro-builder#extends
This adds the fields from another record. And the source record can be marked as abstract if you don't want to generate an avsc file for it: https://github.com/salsify/avro-builder#abstract-types
@tjwp can extends pull in a record from another record in another directory? imo, it would work better to include (pull in thru containment) than extends (like in inheritance)
The terminology used may be confusing but I think it does what you are looking for. It is adding the fields from the record referenced in the extends call, to the record where the call is made. And it can be in another directory. The reference uses the usual namespacing/name to locate the definition.