Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mstoykov/xk6-counter
https://github.com/mstoykov/xk6-counter
xk6
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mstoykov/xk6-counter
- Owner: mstoykov
- License: mit
- Created: 2020-11-30T10:15:00.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-24T09:14:19.000Z (over 3 years ago)
- Last Synced: 2024-10-24T13:58:33.424Z (4 months ago)
- Topics: xk6
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 8
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xk6-counter
This is a [k6](https://go.k6.io/k6) extension using the [xk6](https://github.com/grafana/xk6) system.
| :exclamation: This is a proof of concept, isn't supported by the k6 team, and may break in the future. USE AT YOUR OWN RISK! |
| ---------------------------------------------------------------------------------------------------------------------------- |This projects implements a singular local counter(name is bad) that goes up. It will return the current value before
increasing it, and each VU will get a different value. Which means that it can be used to iterate over an array, where:
1. only one element will be used by each VU
2. the array doesn't need to be sharded between the VUs it will "dynamically" balance between them even if some elements take longer to process| This totally doesn't work in distributed manner, so if there are multiple k6 instances you will need a separate service (API endpoint) which to do it. |
| ---------------------------------------------------------------------------------------------------------------------------- |Predominantly because of the above this is very unlikely to ever get in k6 in it's current form, so please don't open issues :D.
## Build
To build a `k6` binary with this extension, first ensure you have the prerequisites:
- [gvm](https://github.com/moovweb/gvm)
- [Git](https://git-scm.com/)Then, install [xk6](https://github.com/grafana/xk6) and build your custom k6 binary with the Kafka extension:
1. Install `xk6`:
```shell
$ go install go.k6.io/xk6/cmd/xk6@latest
```2. Build the binary:
```shell
$ xk6 build --with github.com/mstoykov/xk6-counter@latest
```# example
```javascript
import counter from "k6/x/counter"
export default function() {
console.log(counter.up(), __VU, __ITER)
}
```