{"id":13342884,"url":"https://github.com/dgzlopes/xk6-kv","last_synced_at":"2025-03-23T22:33:11.986Z","repository":{"id":45181144,"uuid":"353471156","full_name":"dgzlopes/xk6-kv","owner":"dgzlopes","description":"A k6 extension to share key-value data between VUs.","archived":false,"fork":false,"pushed_at":"2022-01-03T08:22:12.000Z","size":1880,"stargazers_count":8,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-24T13:58:40.339Z","etag":null,"topics":["badgerdb","k6","k6-extension","xk6"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgzlopes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-31T19:42:37.000Z","updated_at":"2024-02-04T22:19:10.000Z","dependencies_parsed_at":"2022-08-29T22:52:15.136Z","dependency_job_id":null,"html_url":"https://github.com/dgzlopes/xk6-kv","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Fxk6-kv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Fxk6-kv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Fxk6-kv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Fxk6-kv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgzlopes","download_url":"https://codeload.github.com/dgzlopes/xk6-kv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221919595,"owners_count":16901810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["badgerdb","k6","k6-extension","xk6"],"created_at":"2024-07-29T19:30:06.577Z","updated_at":"2024-10-28T19:34:41.332Z","avatar_url":"https://github.com/dgzlopes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xk6-kv\n\nThis is a [k6](https://go.k6.io/k6) extension using the [xk6](https://github.com/grafana/xk6) system.\n\n| :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! |\n|------|\n\n## Build\n\nTo build a `k6` binary with this extension, first ensure you have the prerequisites:\n\n- [Go toolchain](https://go101.org/article/go-toolchain.html)\n- Git\n\nThen:\n\n1. Install `xk6`:\n  ```shell\n  $ go install go.k6.io/xk6/cmd/xk6@latest\n  ```\n\n2. Build the binary:\n  ```shell\n  $ xk6 build --with github.com/dgzlopes/xk6-kv@latest\n  ```\n\n## Example\n\n```javascript\n// script.js\nimport kv from 'k6/x/kv';\n\nexport const options = {\n  scenarios: {\n    generator: {\n      exec: 'generator',\n      executor: 'per-vu-iterations',\n      vus: 5,\n    },\n    results: {\n      exec: 'results',\n      executor: 'per-vu-iterations',\n      startTime: '1s',\n      maxDuration: '2s',\n      vus: 1,\n    },\n    ttl: {\n      exec: 'ttl',\n      executor: 'constant-vus',\n      startTime: '3s',\n      vus: 1,\n      duration: '2s',\n    },\n  },\n};\n\nconst client = new kv.Client();\n\nexport function generator() {\n  client.set(`hello_${__VU}`, 'world');\n  client.setWithTTLInSecond(`ttl_${__VU}`, `ttl_${__VU}`, 5);\n}\n\nexport function results() {\n  console.log(client.get(\"hello_1\"));\n  client.delete(\"hello_1\");\n  try {\n    var keyDeleteValue = client.get(\"hello_1\");\n    console.log(typeof (keyDeleteValue));\n  }\n  catch (err) {\n    console.log(\"empty value\", err);\n  }\n  var r = client.viewPrefix(\"hello\");\n  for (var key in r) {\n    console.log(key, r[key])\n  }\n}\n\nexport function ttl() {\n  try {\n    console.log(client.get('ttl_1'));\n  }\n  catch (err) {\n    console.log(\"empty value\", err);\n  }\n}\n```\n\nResult output:\n\n```\n$ ./k6 run script.js\n\n          /\\      |‾‾| /‾‾/   /‾‾/   \n     /\\  /  \\     |  |/  /   /  /    \n    /  \\/    \\    |     (   /   ‾‾\\  \n   /          \\   |  |\\  \\ |  (‾)  | \n  / __________ \\  |__| \\__\\ \\_____/ .io\n\n  execution: local\n     script: example.js\n     output: -\n\n  scenarios: (100.00%) 3 scenarios, 7 max VUs, 10m30s max duration (incl. graceful stop):\n           * generator: 1 iterations for each of 5 VUs (maxDuration: 10m0s, exec: generator, gracefulStop: 30s)\n           * results: 1 iterations for each of 1 VUs (maxDuration: 2s, exec: results, startTime: 1s, gracefulStop: 30s)\n           * ttl: 1 looping VUs for 2s (exec: ttl, startTime: 3s, gracefulStop: 30s)\n\nINFO[0001] world                                         source=console\nINFO[0001] empty value error in get value with key hello_1  source=console\nINFO[0001] hello_12 world                                source=console\nINFO[0001] hello_2 world                                 source=console\nINFO[0001] hello_7 world                                 source=console\nINFO[0001] hello_9 world                                 source=console\nINFO[0001] hello_5 world                                 source=console\nINFO[0001] hello_8 world                                 source=console\nINFO[0001] hello_4 world                                 source=console\nINFO[0001] hello_6 world                                 source=console\nINFO[0001] hello_10 world                                source=console\nINFO[0001] hello_11 world                                source=console\nINFO[0001] hello_13 world                                source=console\nINFO[0001] hello_14 world                                source=console\nINFO[0001] hello_15 world                                source=console\nINFO[0001] hello_3 world                                 source=console\nINFO[0003] ttl_1                                         source=console\nINFO[0005] empty value error in get value with key ttl_1  source=console\nINFO[0005] empty value error in get value with key ttl_1  source=console\nINFO[0005] empty value error in get value with key ttl_1  source=console\nINFO[0005] empty value error in get value with key ttl_1  source=console\n\nrunning (00m05.0s), 0/7 VUs, 47297 complete and 0 interrupted iterations\ngenerator ✓ [======================================] 5 VUs  00m00.0s/10m0s  5/5 iters, 1 per VU\nresults   ✓ [======================================] 1 VUs  0.0s/2s         1/1 iters, 1 per VU\nttl       ✓ [======================================] 1 VUs  2s             \n\n     data_received........: 0 B   0 B/s\n     data_sent............: 0 B   0 B/s\n     iteration_duration...: avg=36.8µs min=15.66µs med=22.64µs max=53.39ms p(90)=79.34µs p(95)=95.68µs\n     iterations...........: 47297 9457.107597/s\n     vus..................: 1     min=0         max=1\n     vus_max..............: 7     min=7         max=7\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgzlopes%2Fxk6-kv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgzlopes%2Fxk6-kv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgzlopes%2Fxk6-kv/lists"}