Mercurial > code > home > repos > light9
comparison web/lib/avro.ts @ 2395:ef3cde3e81e8
switch collector output from json to avro (still over WS)
author | drewp@bigasterisk.com |
---|---|
date | Thu, 16 May 2024 15:03:50 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2394:7578f855d18b | 2395:ef3cde3e81e8 |
---|---|
1 import * as avrojs from "avro-js"; | |
2 export namespace avro { | |
3 export async function loadType(typeName: string): Promise<avrojs.types.Type> { | |
4 const schemaSource = await (await fetch(`/avro/${typeName}.avsc`)).json(); | |
5 return await avrojs.parse(schemaSource); | |
6 } | |
7 | |
8 export async function parseBlob(type: avrojs.types.Type, b: Blob): Promise<avrojs.types.Record> { | |
9 const jsMsg = type.fromBuffer(Buffer.from(await b.arrayBuffer())); | |
10 return jsMsg; | |
11 } | |
12 } |