Mercurial > code > home > repos > light9
annotate web/lib/avro.ts @ 2405:69ca2b2fc133
overcomplicated attempt at persisting the pane layout in the rdf graph
this was hard because we have to somehow wait for the graph to load before config'ing the panes
author | drewp@bigasterisk.com |
---|---|
date | Fri, 17 May 2024 16:58:26 -0700 |
parents | ef3cde3e81e8 |
children |
rev | line source |
---|---|
2395
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
1 import * as avrojs from "avro-js"; |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
2 export namespace avro { |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
3 export async function loadType(typeName: string): Promise<avrojs.types.Type> { |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
4 const schemaSource = await (await fetch(`/avro/${typeName}.avsc`)).json(); |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
5 return await avrojs.parse(schemaSource); |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
6 } |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
7 |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
8 export async function parseBlob(type: avrojs.types.Type, b: Blob): Promise<avrojs.types.Record> { |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
9 const jsMsg = type.fromBuffer(Buffer.from(await b.arrayBuffer())); |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
10 return jsMsg; |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
11 } |
ef3cde3e81e8
switch collector output from json to avro (still over WS)
drewp@bigasterisk.com
parents:
diff
changeset
|
12 } |