Skip to content

Avro and Protobuf wire codecs as optional plugins #73

Description

@pathosDev

The `Codec` interface (#6) ships with `jsonCodec` (pass-through) and `zodCodec` (validate via Zod schema). The original issue noted Avro / Protobuf as out-of-scope for v1.

Scope:

  • `avroCodec(schema)` (peer-dep: `avsc` or similar)

    • `encode`: validate + serialize to Avro binary.
    • `decode`: deserialize + validate.
    • Wire shape: base64-encoded bytes inside the JSON envelope (so journal layers stay JSON-shaped).
  • `protobufCodec(messageType)` (peer-dep: `protobufjs`)

    • Same shape: encode/decode via protobuf.js's `MessageType`.
    • Wire shape: base64.
  • Both codecs play nicely with `SchemaRegistry` — register the codec instance with the version, the registry handles the rest.

Tests:

  • Round-trip a value through the codec.
  • Schema mismatch on decode (wrong magic, wrong fields) surfaces a clear error.
  • Versioned via `SchemaRegistry`: v1 Avro codec + v2 Protobuf codec coexist (different versions of the same manifest can use different wire formats).

Estimate: 3-5 days.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: lowNice-to-have / niche / demand-driven

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions