Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xvzf/xk6-avro
k6 extension supporting avro textual and binary representations
https://github.com/xvzf/xk6-avro
avro goavro k6 xk6
Last synced: 2 months ago
JSON representation
k6 extension supporting avro textual and binary representations
- Host: GitHub
- URL: https://github.com/xvzf/xk6-avro
- Owner: xvzf
- Created: 2021-12-08T11:26:49.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-27T10:39:16.000Z (over 2 years ago)
- Last Synced: 2024-06-20T12:41:43.354Z (4 months ago)
- Topics: avro, goavro, k6, xk6
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# xk6-avro
![CI](https://github.com/xvzf/xk6-avro/actions/workflows/test.yaml/badge.svg)
This extension wraps the [goavro](https://github.com/linkedin/goavro`) library into a k6 extension.
You can build the extension using:
```bash
xk6 build --with github.com/xvzf/xk6-avro
```## Example
```javascript
import avro from "k6/x/avro"const codec = avro.NewCodec(`{
"type": "record",
"name": "LongList",
"fields" : [
{"name": "next", "type": ["null", "LongList"], "default": null}
]
}`)
let binary = codec.binaryFromTextual(`{"next":{"LongList":{}}}`)
console.log(binary)let textual = codec.textualFromBinary(binary)
console.log(textual)// When actually doing an HTTP request using the k6 http client, data has to be passed as ArrayBuffer:
const binaryAB = new Uint8Array(binary).buffer
http.post(`https://example.com/avro-receiver`, binaryAB, {headers: {"Content-Type": "binary/avro"}})
```