AvroCodec

dev.constructive.eo.avro.AvroCodec
See theAvroCodec companion object
trait AvroCodec[A]

A unified read/write/schema codec for Avro values, combining the kindlings-avro-derivation triplet (AvroEncoder[A], AvroDecoder[A], AvroSchemaFor[A]) into a single typeclass that user code summons once per type.

Why an extra wrapper at all? kindlings ships three independent typeclasses so users can encode- only or decode-only — but cats-eo-avro's optics always need both sides to be honest (a Prism's get decodes, its reverseGet / place encodes). Forcing every call site to thread two using parameters is noisy. AvroCodec[A] is the project-internal shorthand.

Why not vulcan? Vulcan 1.13.x pins apache-avro 1.11.5; kindlings-avro-derivation 0.1.2 pins 1.12.1. cats-eo-avro chose kindlings + avro 1.12 because it lines up with the rest of the ecosystem moving forward, and the typeclass surface is simpler (no Either[AvroError, A] threading on every call — kindlings' decoders throw on failure, which the prism layer wraps into AvroFailure).

'''Per the eo-avro plan (OQ-avro-1):''' the codec library at v0.1.0 is com.kubuszok:kindlings-avro-derivation — a choice of derivation BACKEND, not of typeclass surface. A codebase whose codecs are vulcan bridges them into this typeclass instead (issue #73): import dev.constructive.eo.avro.vulcan.given makes every in-scope vulcan.Codec[A] serve as an AvroCodec[A], or name it explicitly via dev.constructive.eo.avro.vulcan.AvroVulcan.codec — see the dev.constructive.eo.avro.vulcan.AvroVulcan scaladoc for the error mapping.

Attributes

Companion
object
Source
AvroCodec.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def decodeEither(any: Any): Either[Throwable, A]

Decode an Avro-shaped runtime value to an A, or surface the kindlings decoder's exception via Left. The decoder itself throws on bad input; this method wraps the throw to match the project's structured-failure conventions.

Decode an Avro-shaped runtime value to an A, or surface the kindlings decoder's exception via Left. The decoder itself throws on bad input; this method wraps the throw to match the project's structured-failure conventions.

Attributes

Source
AvroCodec.scala
def encode(a: A): Any

Encode an A to an Avro-shaped runtime value (an org.apache.avro.generic.IndexedRecord, a primitive box, an org.apache.avro.util.Utf8, or an org.apache.avro.generic.GenericArray — varies by A). The kindlings encoder is a pure (no-Either) shape; the optic layer never needs to recover here.

Encode an A to an Avro-shaped runtime value (an org.apache.avro.generic.IndexedRecord, a primitive box, an org.apache.avro.util.Utf8, or an org.apache.avro.generic.GenericArray — varies by A). The kindlings encoder is a pure (no-Either) shape; the optic layer never needs to recover here.

Attributes

Source
AvroCodec.scala
def schema: Schema

The Avro schema describing this codec's wire shape. Pulled off the encoder (or decoder — they agree by construction) so callers don't have to summon AvroSchemaFor[A] separately.

The Avro schema describing this codec's wire shape. Pulled off the encoder (or decoder — they agree by construction) so callers don't have to summon AvroSchemaFor[A] separately.

Attributes

Source
AvroCodec.scala