0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 18:07:17 +01:00
posthog/rust
Brett Hoerner 8f4df45984
feat: make rusty-hook Hog-aware, sending responses back via kafka (#23619)
Co-authored-by: Ben White <ben@posthog.com>
2024-07-16 11:12:48 -06:00
..
bin feat: make rusty-hook Hog-aware, sending responses back via kafka (#23619) 2024-07-16 11:12:48 -06:00
capture
common
docker/echo-server
feature-flags
hook-api feat: make rusty-hook Hog-aware, sending responses back via kafka (#23619) 2024-07-16 11:12:48 -06:00
hook-common feat: make rusty-hook Hog-aware, sending responses back via kafka (#23619) 2024-07-16 11:12:48 -06:00
hook-janitor feat: make rusty-hook Hog-aware, sending responses back via kafka (#23619) 2024-07-16 11:12:48 -06:00
hook-worker feat: make rusty-hook Hog-aware, sending responses back via kafka (#23619) 2024-07-16 11:12:48 -06:00
migrations
.dockerignore
.env
.gitignore
Cargo.lock feat: make rusty-hook Hog-aware, sending responses back via kafka (#23619) 2024-07-16 11:12:48 -06:00
Cargo.toml feat: make rusty-hook Hog-aware, sending responses back via kafka (#23619) 2024-07-16 11:12:48 -06:00
depot.json
docker-compose.yml
Dockerfile
Dockerfile.migrate
LICENSE
README.md

hog-rs

PostHog Rust service monorepo. This is not the Rust client library for PostHog.

capture

This is a rewrite of capture.py, in Rust.

Why?

Capture is very simple. It takes some JSON, checks a key in Redis, and then pushes onto Kafka. It's mostly IO bound.

We currently use far too much compute to run this service, and it could be more efficient. This effort should not take too long to complete, but should massively reduce our CPU usage - and therefore spend.

How?

I'm trying to ensure the rewrite at least vaguely resembles the Python version. This will both minimize accidental regressions, but also serve as a "rosetta stone" for engineers at PostHog who have not written Rust before.

rusty-hook

A reliable and performant webhook system for PostHog

Requirements

  1. Rust.
  2. Docker, or podman and podman-compose: To setup development stack.

Testing

  1. Start development stack:
docker compose -f docker-compose.yml up -d --wait
  1. Test:
# Note that tests require a DATABASE_URL environment variable to be set, e.g.:
# export DATABASE_URL=postgres://posthog:posthog@localhost:15432/test_database
# But there is an .env file in the project root that should be used automatically.
cargo test