Skip to content

feat: C++20 rewrite of hookla#6

Open
Yomanz wants to merge 1 commit into
masterfrom
lewis/sad-bhaskara-df4bd4
Open

feat: C++20 rewrite of hookla#6
Yomanz wants to merge 1 commit into
masterfrom
lewis/sad-bhaskara-df4bd4

Conversation

@Yomanz
Copy link
Copy Markdown
Member

@Yomanz Yomanz commented May 4, 2026

Summary

  • Full port of the Scala/Finch/Akka/Quill/Circe service to C++20, living in cpp/
  • All three implemented providers carried over: GitHub (5 events), GitLab (6 events), Sonarr (4 events); Radarr and Ombi remain stubs matching the Scala original
  • Same database schema — no migrations needed

Library mapping

Scala C++
Finch / Finagle Drogon v1.9 (C++20 co_await coroutines)
Akka actors Removed — no actor-to-actor messaging in this service
Quill + async driver libpqxx 7 with a mutex-guarded ConnectionPool
Circe nlohmann/json (NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE + manual enum overloads)
ackcord cpp-httplib (SSLClient to discord.com:443)
MacWire Explicit shared_ptr wiring in main.cpp
sbt CMake 3.25 + FetchContent
distroless JVM (~180 MB) debian:bookworm-slim (~30 MB, ~20 MB RSS idle)

Key structural changes from Scala

Handler dispatch — both provider-level and event-level dispatch use std::unordered_map<string, function<void(json, EventData)>> registered in each handler's constructor. No std::variant, no extra event class hierarchy. Adding a new event = one map entry.

BaseEvent class hierarchy collapsed — the Scala version had this layer because MacWire needed classes to wire. In C++ the event handlers are private methods on the provider handler (or free functions for complex ones like GitLab push).

JSON enums — each Scala StringEnum (GithubRefType, GithubCheckRunAction, SonarrEventType, etc.) becomes a C++ enum class + a hand-written from_json free function. ~100 lines that Circe/enumeratum generated automatically.

Nullable columns — each Option[T] in Scala models needs an explicit row["col"].is_null() check in EmbedOptionsService.cpp and friends.

Test plan

  • cmake -B build && cmake --build build compiles cleanly with clang-17 or gcc-13
  • docker build -f cpp/Dockerfile cpp/ produces a working image
  • POST to /process/:token with a GitHub push payload returns 200 success and sends a Discord embed
  • Invalid token returns 401
  • Unknown event name logs a warning and returns 200 (graceful no-op)
  • Sonarr test event (eventType: "Test" in body) sends the test embed

Direct port of the Scala/Finch/Akka/Quill/Circe service to modern C++.
Shows what the same webhook aggregation logic looks like with:
- Drogon v1.9 (HTTP server, C++20 coroutines)
- libpqxx 7 (PostgreSQL, raw SQL replacing Quill ORM)
- nlohmann/json (replacing Circe codec derivation)
- cpp-httplib (replacing ackcord for Discord webhook calls)
- Manual shared_ptr wiring in main.cpp (replacing MacWire)

All three implemented providers are ported (GitHub 5 events, GitLab 6 events,
Sonarr 4 events). Radarr and Ombi remain stubs, matching the Scala original.
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.

1 participant