artio
artio copied to clipboard
Support custom/unknown tags in codecs
Artio codecs are nice in the sense that they are fast and make it easy to read values of known fields.
One thing that is hard is to be able to take into account some arbitrary custom fields (e.g. 10042=FOO
). Right now, the only solution is to define a new field in the XML dictionary, regenerate codecs, then hardcode the processing of the tag. This makes it difficult to set up a configurable gateway, where custom tags can be copied/mapped to whatever we like (any config change requires a rebuild).
I haven't had time to think this through but I feel like it would be easy to set an "unknown tag listener" in a Decoder, so it is notified whenever an unknown tag is encountered. Something like this:
@Override
public void onUnknownTag(int tag, DirectBuffer buffer, int offset, int len) {
...
}
This looks like something that could be nice and not that hard to strap on existing decoders.
Conversely, it would be nice to encode "unknown" fields through encoders. A quick and dirty way of doing it would be to declare a customFields
buffer + customFieldsLength
and some methods to populate/reset it.
What do you think? If time permits, I will try to experiment something and come up with a PR in case this is something of interest to other people.