Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CF Metrics, Tests, and Fixes #33

Merged
merged 39 commits into from
Jul 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1a924b7
direct port of cf server PoC from tx5 repo
neonphog Jun 18, 2024
3d29dd9
make test
neonphog Jun 18, 2024
79f9174
update deps
neonphog Jun 18, 2024
29f3a6d
integrate with server-o-bahn suite
neonphog Jun 19, 2024
cd4d0de
fix windows ts runner
neonphog Jun 28, 2024
fcd4f6b
ci fix
neonphog Jun 28, 2024
52343be
try through node itself
neonphog Jun 28, 2024
0fac197
do we need to resume?
neonphog Jun 28, 2024
171f70f
only run cf test on linux
neonphog Jun 28, 2024
01b6908
protocol update
neonphog Jul 1, 2024
4cb9928
ensure message ordering through batching
neonphog Jul 4, 2024
df80bf1
concurrency fixes
neonphog Jul 4, 2024
28f6eea
rate limiting
neonphog Jul 4, 2024
b71017c
cleanup
neonphog Jul 4, 2024
7a04088
fmt
neonphog Jul 4, 2024
ba3934e
cleanup and comments
neonphog Jul 5, 2024
d54e5b9
test2 different behavior
neonphog Jul 5, 2024
bd326e9
Update ts/sbd-server/server-o-bahn-runner.mjs
neonphog Jul 8, 2024
15883da
Update ts/sbd-server/src/index.ts
neonphog Jul 8, 2024
6a92bdc
bad sig test
neonphog Jul 9, 2024
ebea871
Merge branch 'cf-sbd-server' into cf-testing
neonphog Jul 9, 2024
93c53d8
test 4 & 5
neonphog Jul 9, 2024
07a015a
msg-too-big
neonphog Jul 9, 2024
680360e
order stress
neonphog Jul 9, 2024
49a7a9e
Merge branch 'main' into cf-testing
neonphog Jul 9, 2024
89bb5e4
tweaks
neonphog Jul 10, 2024
ed9c52a
address code review comments
neonphog Jul 10, 2024
6aa92aa
cloudflare metrics
neonphog Jul 11, 2024
a44ce50
Merge branch 'main' into cf-metrics
neonphog Jul 11, 2024
b081518
new test style
neonphog Jul 12, 2024
ebefd77
checkpoint
neonphog Jul 12, 2024
1429022
add dead state tracking to signal DO
neonphog Jul 15, 2024
37f5c25
cleanup
neonphog Jul 15, 2024
68fde2c
docs
neonphog Jul 15, 2024
2e42ad6
Update ts/sbd-server/src/prom.ts
neonphog Jul 18, 2024
022e137
update
neonphog Jul 18, 2024
ef515d8
npm --verbose ci
neonphog Jul 18, 2024
89bcc66
npm install
neonphog Jul 18, 2024
2ec0136
older node
neonphog Jul 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
new test style
neonphog committed Jul 12, 2024
commit b081518a9705039e10c50323a232b51f818a3ffb
528 changes: 487 additions & 41 deletions ts/sbd-server/package-lock.json

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions ts/sbd-server/package.json
Original file line number Diff line number Diff line change
@@ -2,22 +2,24 @@
"name": "sbd-signal",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev",
"test:fmt": "prettier -w src",
"test:type": "tsc --noEmit",
"test:fmt": "prettier -w src test",
"test:type": "tsc --noEmit --project ./src/tsconfig.json",
"test:unit": "vitest run",
"test": "npm run test:fmt && npm run test:type && npm run test:unit"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240620.0",
"@cloudflare/vitest-pool-workers": "^0.4.11",
"@cloudflare/workers-types": "^4.20240712.0",
"node-cleanup": "^2.1.2",
"prettier": "^3.3.2",
"typescript": "^5.5.2",
"vitest": "^1.6.0",
"wrangler": "^3.63.1"
"typescript": "^5.5.3",
"vitest": "1.5.0",
"wrangler": "^3.64.0"
},
"dependencies": {
"@noble/ed25519": "^2.1.0",
19 changes: 13 additions & 6 deletions ts/sbd-server/src/common.ts
Original file line number Diff line number Diff line change
@@ -19,6 +19,11 @@ export const BATCH_DUR_MS = 0;
*/
export const LIMIT_NANOS_PER_BYTE = 8000;

/**
* How many nanoseconds of rate limiting burst graceperiod is allowed
*/
export const LIMIT_NANOS_BURST = LIMIT_NANOS_PER_BYTE * 16 * 16 * 1024;

/**
* Milliseconds connections are allowed to remain idle before being closed.
*/
@@ -29,26 +34,28 @@ export const LIMIT_IDLE_MILLIS = 10000;
*/
export const MAX_MESSAGE_BYTES = 20000;

/**
/*
/ **
* Cloudflare worker environment objects.
*/
* /
export interface EnvExplicit {
SBD_COORDINATION: KVNamespace;
SIGNAL: DurableObjectNamespace;
RATE_LIMIT: DurableObjectNamespace;
}
/**
/ **
* Cloudflare worker environment variables.
*/
* /
export interface EnvVars {
[index: string]: string;
}
/**
/ **
* Combined Cloudflare Env type.
*/
* /
export type Env = EnvExplicit & EnvVars;
*/

/**
* Mixin to allow errors with status codes.
20 changes: 20 additions & 0 deletions ts/sbd-server/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Cloudflare worker environment objects.
*/
interface EnvExplicit {
SBD_COORDINATION: KVNamespace;
SIGNAL: DurableObjectNamespace;
RATE_LIMIT: DurableObjectNamespace;
}

/**
* Cloudflare worker environment variables.
*/
interface EnvVars {
[index: string]: string;
}

/**
* Combined Cloudflare Env type.
*/
type Env = EnvExplicit & EnvVars;
3 changes: 2 additions & 1 deletion ts/sbd-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ export { DoSignal };
export default {
async fetch(
request: Request,
env: common.Env,
env: Env,
ctx: ExecutionContext,
): Promise<Response> {
try {
@@ -120,6 +120,7 @@ export default {
const ipStub = env.RATE_LIMIT.get(ipId) as DurableObjectStub<DoRateLimit>;
const { shouldBlock } = await ipStub.bytesReceived(
Date.now(),
ip,
pubKeyStr,
1,
);
111 changes: 0 additions & 111 deletions ts/sbd-server/src/rate-limit.test.ts

This file was deleted.

Loading