Skip to content

refactor(notification-service): drop unused Svix client from wiring - #4739

Draft
tothandras wants to merge 1 commit into
mainfrom
claude/exciting-curie-r5dv6v
Draft

refactor(notification-service): drop unused Svix client from wiring#4739
tothandras wants to merge 1 commit into
mainfrom
claude/exciting-curie-r5dv6v

Conversation

@tothandras

@tothandras tothandras commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Overview

cmd/notification-service wired a real Svix client and webhook handler into its notification.Service, but the binary can never use it:

  • Its only runtime path is the Kafka consumer → Service.CreateEvent, which validates the rule and persists pending events + delivery statuses to Postgres.
  • The webhook handler is only invoked from channel/rule CRUD (openmeter/notification/service/channel.go, rule.go), which is reachable only through the HTTP API served by cmd/server.
  • Webhook delivery to Svix happens exclusively via the leader-elected reconcile loop in openmeter/notification/eventhandler/, which is wired and started only in cmd/server (wire already pruned NewNotificationEventHandler in this binary since nothing consumes it).

This PR switches the binary to the existing common.NotificationService wire set (noop webhook handler), which was defined for exactly this case but previously unused.

Behavior change: constructing the real Svix handler is not side-effect-free — webhooksvix.New registers notification event types with the Svix API at startup and (by default) fails startup on error. This PR removes that startup-time Svix dependency from notification-service, meaning the worker no longer fail-fasts on bad Svix config and can now start (and keep persisting pending events) while Svix is unreachable. Event type registration still happens at cmd/server startup (as well as cmd/balance-worker and cmd/jobs, which retain the full wiring), and cmd/server is required for delivery anyway.

Also included:

  • Corrected the notification skill docs: the wire set split was documented backwards (cmd/server uses the full set, not the noop one), and the described EventHandler.Dispatch async path has no call sites — delivery is purely reconcile-loop driven.
  • gofmt of pre-existing struct field misalignment in cmd/notification-service/wire.go.

Notes for reviewer

  • Verified: go generate ./cmd/notification-service/... (wire) reproduces the committed wire_gen.go with zero diff, and go vet -tags=dynamic / go build -tags=dynamic ./cmd/notification-service/... pass against librdkafka v2.15.0 (built from the same source pin the flake uses).
  • cmd/balance-worker and cmd/jobs construct the same unused Svix webhook handler; they are intentionally left untouched here and could be follow-ups if desired.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EsKVSPEKRuNu3xc2Tww6Ae

The notification-service binary only consumes Kafka system events and
persists pending notification events via Service.CreateEvent; webhook
delivery and reconciliation run exclusively in cmd/server, and the
webhook handler is only reachable through channel/rule CRUD served by
the HTTP API. The real Svix webhook handler was constructed solely to
satisfy NewNotificationService, which also coupled worker startup to
Svix availability via construction-time event type registration.

Switch to the common.NotificationService wire set (noop webhook
handler) so the worker no longer constructs a Svix client it cannot
use. Event type registration still happens at cmd/server startup.

Also document the wire set split in the notification skill and remove
the stale EventHandler.Dispatch flow description (no call sites exist;
delivery is reconcile-loop driven).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsKVSPEKRuNu3xc2Tww6Ae
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ff396c8d-565d-4d55-a038-a056f1dc8150

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/exciting-curie-r5dv6v

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

2 participants