Skip to content

Commit ef89b79

Browse files
mizchiclaude
andcommitted
style: apply deno fmt to bench, docs, and source files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1012a31 commit ef89b79

22 files changed

Lines changed: 763 additions & 599 deletions

bench/config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// Shared configuration for k6 benchmark tests
22

3-
export const BASE_URL = __ENV.BASE_URL || "http://localhost:8788";
4-
export const AUTH_TOKEN = __ENV.AUTH_TOKEN || "";
3+
export const BASE_URL = __ENV.BASE_URL || 'http://localhost:8788';
4+
export const AUTH_TOKEN = __ENV.AUTH_TOKEN || '';
55
export const RUN_ID = __ENV.RUN_ID || `run-${Date.now()}`;
66

77
// WebSocket URL derived from BASE_URL
8-
const wsScheme = BASE_URL.startsWith("https") ? "wss" : "ws";
9-
const wsHost = BASE_URL.replace(/^https?:\/\//, "");
8+
const wsScheme = BASE_URL.startsWith('https') ? 'wss' : 'ws';
9+
const wsHost = BASE_URL.replace(/^https?:\/\//, '');
1010
export const WS_URL = `${wsScheme}://${wsHost}`;
1111

1212
export function authHeaders() {
13-
const headers = { "Content-Type": "application/json" };
13+
const headers = { 'Content-Type': 'application/json' };
1414
if (AUTH_TOKEN) {
15-
headers["Authorization"] = `Bearer ${AUTH_TOKEN}`;
15+
headers['Authorization'] = `Bearer ${AUTH_TOKEN}`;
1616
}
1717
return headers;
1818
}

bench/helpers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Trend, Counter } from "k6/metrics";
2-
import { RUN_ID } from "./config.js";
1+
import { Counter, Trend } from 'k6/metrics';
2+
import { RUN_ID } from './config.js';
33

44
// Generate a unique room name per VU and scenario
55
export function roomName(scenario, vuId) {
@@ -13,13 +13,13 @@ export function senderName(scenario, vuId) {
1313

1414
// Simple UUID v4 generator (good enough for bench IDs)
1515
export function uuid() {
16-
const hex = "0123456789abcdef";
17-
let id = "";
16+
const hex = '0123456789abcdef';
17+
let id = '';
1818
for (let i = 0; i < 36; i++) {
1919
if (i === 8 || i === 13 || i === 18 || i === 23) {
20-
id += "-";
20+
id += '-';
2121
} else if (i === 14) {
22-
id += "4";
22+
id += '4';
2323
} else if (i === 19) {
2424
id += hex[(Math.random() * 4) | 8];
2525
} else {

bench/run-all.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
1-
import healthFn from "./scenarios/health.js";
2-
import publishPollFn from "./scenarios/publish-poll.js";
3-
import inboxFn from "./scenarios/inbox.js";
4-
import presenceFn from "./scenarios/presence.js";
5-
import websocketFn from "./scenarios/websocket.js";
6-
import gitServeFn from "./scenarios/git-serve.js";
1+
import healthFn from './scenarios/health.js';
2+
import publishPollFn from './scenarios/publish-poll.js';
3+
import inboxFn from './scenarios/inbox.js';
4+
import presenceFn from './scenarios/presence.js';
5+
import websocketFn from './scenarios/websocket.js';
6+
import gitServeFn from './scenarios/git-serve.js';
77

88
// Combined runner: each scenario starts at a staggered offset.
99
// Individual scenario files also work standalone with their own `options`.
1010

1111
export const options = {
1212
scenarios: {
1313
health: {
14-
executor: "ramping-vus",
14+
executor: 'ramping-vus',
1515
startVUs: 1,
1616
stages: [
17-
{ duration: "5s", target: 10 },
18-
{ duration: "5s", target: 50 },
19-
{ duration: "5s", target: 0 },
17+
{ duration: '5s', target: 10 },
18+
{ duration: '5s', target: 50 },
19+
{ duration: '5s', target: 0 },
2020
],
21-
startTime: "0s",
22-
exec: "health",
21+
startTime: '0s',
22+
exec: 'health',
2323
},
2424
publish_poll: {
25-
executor: "ramping-vus",
25+
executor: 'ramping-vus',
2626
startVUs: 1,
2727
stages: [
28-
{ duration: "10s", target: 10 },
29-
{ duration: "10s", target: 50 },
30-
{ duration: "10s", target: 0 },
28+
{ duration: '10s', target: 10 },
29+
{ duration: '10s', target: 50 },
30+
{ duration: '10s', target: 0 },
3131
],
32-
startTime: "10s",
33-
exec: "publishPoll",
32+
startTime: '10s',
33+
exec: 'publishPoll',
3434
},
3535
inbox: {
36-
executor: "ramping-vus",
36+
executor: 'ramping-vus',
3737
startVUs: 1,
3838
stages: [
39-
{ duration: "10s", target: 10 },
40-
{ duration: "10s", target: 30 },
41-
{ duration: "5s", target: 0 },
39+
{ duration: '10s', target: 10 },
40+
{ duration: '10s', target: 30 },
41+
{ duration: '5s', target: 0 },
4242
],
43-
startTime: "40s",
44-
exec: "inbox",
43+
startTime: '40s',
44+
exec: 'inbox',
4545
},
4646
presence: {
47-
executor: "ramping-vus",
47+
executor: 'ramping-vus',
4848
startVUs: 1,
4949
stages: [
50-
{ duration: "10s", target: 10 },
51-
{ duration: "10s", target: 50 },
52-
{ duration: "5s", target: 0 },
50+
{ duration: '10s', target: 10 },
51+
{ duration: '10s', target: 50 },
52+
{ duration: '5s', target: 0 },
5353
],
54-
startTime: "40s",
55-
exec: "presence",
54+
startTime: '40s',
55+
exec: 'presence',
5656
},
5757
websocket: {
58-
executor: "ramping-vus",
58+
executor: 'ramping-vus',
5959
startVUs: 1,
6060
stages: [
61-
{ duration: "10s", target: 10 },
62-
{ duration: "10s", target: 50 },
63-
{ duration: "5s", target: 0 },
61+
{ duration: '10s', target: 10 },
62+
{ duration: '10s', target: 50 },
63+
{ duration: '5s', target: 0 },
6464
],
65-
startTime: "70s",
66-
exec: "websocket",
65+
startTime: '70s',
66+
exec: 'websocket',
6767
},
6868
git_serve: {
69-
executor: "constant-vus",
69+
executor: 'constant-vus',
7070
vus: 5,
71-
duration: "30s",
72-
startTime: "100s",
73-
exec: "gitServe",
71+
duration: '30s',
72+
startTime: '100s',
73+
exec: 'gitServe',
7474
},
7575
},
7676
thresholds: {
77-
http_req_duration: ["p(95)<500", "p(99)<1000"],
78-
http_req_failed: ["rate<0.05"],
77+
http_req_duration: ['p(95)<500', 'p(99)<1000'],
78+
http_req_failed: ['rate<0.05'],
7979
},
8080
};
8181

bench/scenarios/git-serve.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import http from "k6/http";
2-
import { check, sleep } from "k6";
3-
import { Trend } from "k6/metrics";
4-
import { BASE_URL, authHeaders } from "../config.js";
1+
import http from 'k6/http';
2+
import { check, sleep } from 'k6';
3+
import { Trend } from 'k6/metrics';
4+
import { authHeaders, BASE_URL } from '../config.js';
55

6-
const registerLatency = new Trend("git_register_latency", true);
7-
const infoLatency = new Trend("git_info_latency", true);
8-
const pollLatency = new Trend("git_poll_latency", true);
6+
const registerLatency = new Trend('git_register_latency', true);
7+
const infoLatency = new Trend('git_info_latency', true);
8+
const pollLatency = new Trend('git_poll_latency', true);
99

1010
export const options = {
1111
scenarios: {
1212
git_serve: {
13-
executor: "constant-vus",
13+
executor: 'constant-vus',
1414
vus: 5,
15-
duration: "60s",
15+
duration: '60s',
1616
},
1717
},
1818
thresholds: {
19-
git_register_latency: ["p(95)<500"],
20-
git_info_latency: ["p(95)<300"],
21-
http_req_failed: ["rate<0.05"],
19+
git_register_latency: ['p(95)<500'],
20+
git_info_latency: ['p(95)<300'],
21+
http_req_failed: ['rate<0.05'],
2222
},
2323
};
2424

@@ -35,8 +35,8 @@ export default function () {
3535
registerLatency.add(registerRes.timings.duration);
3636

3737
const registerOk = check(registerRes, {
38-
"register status 200": (r) => r.status === 200,
39-
"register has session": (r) => {
38+
'register status 200': (r) => r.status === 200,
39+
'register has session': (r) => {
4040
const body = r.json();
4141
return body.ok === true && body.session_id;
4242
},
@@ -49,7 +49,7 @@ export default function () {
4949

5050
const { session_id, session_token } = registerRes.json();
5151
const sessionHeaders = Object.assign({}, headers, {
52-
"x-session-token": session_token,
52+
'x-session-token': session_token,
5353
});
5454

5555
// Get session info
@@ -61,8 +61,8 @@ export default function () {
6161
infoLatency.add(infoRes.timings.duration);
6262

6363
check(infoRes, {
64-
"info status 200": (r) => r.status === 200,
65-
"info session active": (r) => {
64+
'info status 200': (r) => r.status === 200,
65+
'info session active': (r) => {
6666
const body = r.json();
6767
return body.ok === true && body.active === true;
6868
},
@@ -71,14 +71,14 @@ export default function () {
7171
// Poll with short timeout (no pending requests expected)
7272
const pollRes = http.get(
7373
`${BASE_URL}/api/v1/serve/poll?session=${session_id}&timeout=1`,
74-
{ headers: sessionHeaders, timeout: "5s" },
74+
{ headers: sessionHeaders, timeout: '5s' },
7575
);
7676

7777
pollLatency.add(pollRes.timings.duration);
7878

7979
check(pollRes, {
80-
"poll status 200": (r) => r.status === 200,
81-
"poll ok": (r) => r.json().ok === true,
80+
'poll status 200': (r) => r.status === 200,
81+
'poll ok': (r) => r.json().ok === true,
8282
});
8383

8484
sleep(2);

bench/scenarios/health.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import http from "k6/http";
2-
import { check, sleep } from "k6";
3-
import { BASE_URL, authHeaders } from "../config.js";
1+
import http from 'k6/http';
2+
import { check, sleep } from 'k6';
3+
import { authHeaders, BASE_URL } from '../config.js';
44

55
export const options = {
66
scenarios: {
77
health: {
8-
executor: "ramping-vus",
8+
executor: 'ramping-vus',
99
startVUs: 1,
1010
stages: [
11-
{ duration: "10s", target: 10 },
12-
{ duration: "10s", target: 50 },
13-
{ duration: "10s", target: 100 },
14-
{ duration: "10s", target: 0 },
11+
{ duration: '10s', target: 10 },
12+
{ duration: '10s', target: 50 },
13+
{ duration: '10s', target: 100 },
14+
{ duration: '10s', target: 0 },
1515
],
1616
},
1717
},
1818
thresholds: {
19-
http_req_duration: ["p(95)<200", "p(99)<500"],
20-
http_req_failed: ["rate<0.01"],
19+
http_req_duration: ['p(95)<200', 'p(99)<500'],
20+
http_req_failed: ['rate<0.01'],
2121
},
2222
};
2323

@@ -26,16 +26,16 @@ export default function () {
2626

2727
const healthRes = http.get(`${BASE_URL}/health`, { headers });
2828
check(healthRes, {
29-
"health status 200": (r) => r.status === 200,
30-
"health body ok": (r) => {
29+
'health status 200': (r) => r.status === 200,
30+
'health body ok': (r) => {
3131
const body = r.json();
32-
return body.status === "ok";
32+
return body.status === 'ok';
3333
},
3434
});
3535

3636
const rootRes = http.get(`${BASE_URL}/`, { headers });
3737
check(rootRes, {
38-
"root status 200": (r) => r.status === 200,
38+
'root status 200': (r) => r.status === 200,
3939
});
4040

4141
sleep(0.5);

0 commit comments

Comments
 (0)