Skip to content

logging, unit testing, and rate limiting#121

Merged
Eskan0r merged 16 commits intomainfrom
feat/log_test_limit
Mar 24, 2026
Merged

logging, unit testing, and rate limiting#121
Eskan0r merged 16 commits intomainfrom
feat/log_test_limit

Conversation

@Owen-Isenhart
Copy link
Copy Markdown
Contributor

do not fear, 6k of these lines are just package-lock.json on server since i guess npm install was never run on it. and the rest are pretty simple changes that should not break anything (most are just unit tests and the others are logs and validation)

so, this adds and changes unit tests (since some were like 3k lines of garbage), and i made a makefile so instead of having to run everything one by one you can just run "make test" from the root, and it will test everything. there are more commands for if you just want to test the go files or just the server files or whatever, you can find those with "make help"

next, there's now structured logging throughout the backend (central service, rtc service, server), with log levels, context, tracking, and metadata. an example structure looks like this:
{
"timestamp": "2026-03-08T12:34:56.789Z",
"level": "INFO",
"service": "central-service",
"message": "Request processed",
"correlation_id": "req-123",
"user_id": "user-456",
"room_id": "room-789",
"status_code": 200,
"duration_ms": 45.23,
"metadata": {...}
}

last, we now have rate limiting so that ryan's server hopefully does not explode if someone gets stuck on two sum and tries to submit it 10k times within 20 seconds. thats about it, i think i also added some input validation stuff so we shouldn't be getting zipbombed n shit but yea.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bsg Ready Ready Preview, Comment Mar 17, 2026 1:41am

Request Review

@Owen-Isenhart Owen-Isenhart marked this pull request as ready for review March 9, 2026 02:16
Copy link
Copy Markdown
Contributor

@Eskan0r Eskan0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good twin, add some sort of readme for those who dont know how to run makefiles, i asked calvin rq he doesnt know how to run anything makefile related. given he prob wont run backend tests but would make future stuff easier if we have anyone knew inheriting your work or something else

@Eskan0r
Copy link
Copy Markdown
Contributor

Eskan0r commented Mar 10, 2026

also can you comment out

tunnel:
image: cloudflare/cloudflared:latest
container_name: acm-cloudflare-tunnel
restart: always
command: tunnel --no-autoupdate run --token ${CF_TUNNEL_TOKEN}

in docker-compose.yml also

Comment thread central-service/utils/middleware.go
Comment thread central-service/utils/rate_limiter.go
Copy link
Copy Markdown
Contributor

@devsheth05 devsheth05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fire PR found lil memory leak in main.go under worker
err = p.Produce(&kafka.Message{
TopicPartition: kafka.TopicPartition{Topic: &egressTopic, Partition: kafka.PartitionAny},
Value: payload,
}, nil)

the nil is why its like dumping stuff into p.Events() queue.
Because there is currently no code anywhere in main.go that reads from p.Events() to clear it or anything (i might be wrong and didn't look hard enough), the queue just be storing the receipts infinitely until the worker crashes

maybe fix would be to create a single background loop that constantly reads and discards those receipts from the global Events() channel

@Eskan0r Eskan0r merged commit 85bf38e into main Mar 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants