Hello!  For the Java API, I can see option 4 being useful for many reasons.

The XxxParser approach could be a bit more elegant for adding AVDL,
but also for providing parsers that have alternative or custom
configurations, or future/custom representations.

Likewise, the XxxFormatter approach (to replace the abused .toString)
could be used to provide the alternative representation or custom
configurations.  We already have AVRO-2832 which was proposed (and
never implemented) to solve the types of problems encountered by
AVRO-2822 (how to specify previously encountered Schema).  The
canonical format is pretty much a custom formatter for a schema, and
IIRC there was another proposition to have a canonical-like formatter
that also retained custom metadata (I can't find the JIRA).

I'm not sure about the factory/SPI approach -- it almost seems like
these classes would need to be explicitly chosen and configured by the
user, as opposed to plugged in.  I haven't given it too much thought
though!  Where would a pluggable version be appropriate?

All my best and thanks for the ideas, Ryan

On Tue, Mar 8, 2022 at 5:29 PM Oscar Westra van Holthe - Kind
<os...@westravanholthe.nl> wrote:
>
> Hi all,
>
> One change to the Java API I've been pondering is a parser/formatter
> separate from the Schema & Protocol classes.
> To implement this, I'm thinking of a combination of several pieces:
>
>    - An interface for the functionality
>    - An implementation for the current JSON format (.avsc & .avpr)
>    - A service provider interface (SPI) to discover implementations with
>    (e.g., to enable the IDL format)
>
> For the actual implementation, I see several options:
>
>    1. Nothing; keep what we have now
>    2. Create SchemaParser and ProtocolParser interfaces for parsing, but
>    keep the current toString() methods intact
>    3. Create SchemaFormat and ProtocolFormat for both parsing and formatting
>    (alternatively named SchemaFormatter & ProtocolFormatter, similar to
>    java.time.format.DateTimeFormatter)
>    4. Create both SchemaParser and ProtocolParser interfaces and
>    SchemaFormatter and ProtocolFormatter interfaces
>
> Which option do you prefer?
>
> Kind regards,
> Oscar
>
> --
>
> ✉️ Oscar Westra van Holthe - Kind <os...@westravanholthe.nl>

Reply via email to