Hemera-avro package
This is a plugin to use Avro with Hemera.
Apache Avro™ is a data serialization system.
Features
- No schema for you pattern is required
- The request and response schema of a server method (
add
) is validated by Avro™ - Flexible base schema
- Easy to start
Example without payload schema
Only the protocol schema will be validated with Avro
const Hemera = // Use NATS driver >= 0.7.2const nats = const HemeraAvro = const hemera = nats logLevel: 'info' hemera
Example with payload schema
hemera
Type inference to auto-generate your schema
Useconst type = avroType// We can now encode or any array of floats using this type:const buf = typeconst val = type // [4, 6.1]// We can also access the auto-generated schema:const schema = typeconst JSON = JSON // Copy & Paste
Base Schema
The pattern is encoded to JSON byte-array when it's from type object
or array
. Primitive values (boolean, strings, numbers) are encoded with Avro.
The error, delegate, meta and request data are predefined with a fixed schema. Here a list of the specification.
- delegate: Can be a Map of strings, boolean, number
- meta: Can be a Map of strings, boolean, number
- result: You can use your own schema. If you don't define it the message is interpreted as binary (JSON encoded schema-less)
- error:
- name: Name of the error
- message: Message of the error
- stack: Stack of the error
- code: Code of the error
- statusCode: Code of the error when using hemera-web
- details: Can be a Map of strings, boolean, number to add additional data
- hops: An array of services which were involved in this request