spring-cloud / spring-cloud-schema-registry

A schema registry implementation for Spring Cloud Stream
47 stars 28 forks source link

Add support for external Protocol (avpr) and IDL (avpl) definitions #2

Open sabbyanandan opened 5 years ago

sabbyanandan commented 5 years ago

@dmarmugi commented on Mon Aug 27 2018

Hi folks, Currently (Elmhurst), you can set spring.cloud.stream.schema.avro.schema-locations to reference external Avro Schema (avsc) files which get registered and retrieved from the Schema Registry.

Protocol files can be used to define a group of related schema, which simplifies code generation when there's interdependent definitions. IDL files offer an expressive DSL for describing protocol files without the JSON boilerplate.

The request is to add new properties which accept *.avpr/*.avdl files, or expand the schemaLocations handler (AvroSchemaRegistryClientMessageConverter#afterPropertiesSet)? to accept those files in addition to avsc.

There is already a Protocol.getTypes() which returns a Collection<Schema> and (this mailing list response)[https://sematext.com/opensee/m/Avro/F2svI1h929p1EU7B12?subj=Re+How+to+define+Protocol+from+AVDL+] suggests that creating a Protocol from an IDL is pretty straightforward as well:

import org.apache.avro.compiler.idl.Idl;
...
Protocol p = new Idl(new File("MyProtocol.avdl")).CompilationUnit();