refactor(events): consolidate outbox-relay Kafka wiring into @fuzefront/core - #530
Open
izzywdev wants to merge 4 commits into
Open
refactor(events): consolidate outbox-relay Kafka wiring into @fuzefront/core#530izzywdev wants to merge 4 commits into
izzywdev wants to merge 4 commits into
Conversation
…nt/core Follow-up to #520. Moves the generic relay wiring out of security-service so every backend service (and the future Python fuzefront-events mirror) shares one install-and-go surface. - @fuzefront/shared: SCHEMA_BY_TOPIC registry + schemaForTopic + partitionKeyForPayload (the contract owns schema lookup and key derivation). - @fuzefront/core: createKafkaOutboxPublisher + startOutboxRelayFromEnv, plus an injectable makeOutboxPublisher seam for unit testing. Adds @fuzefront/shared dep (both core consumers — applications, security — build shared's kafka barrel first). - security-service: outboxRelay collapses to a thin delegate calling startOutboxRelayFromEnv({ db }); schema map + key derivation + producer deleted. Tests: shared registry (6), core publisher incl. envelope/key/schema-vs-raw/DLQ/ no-broker no-op (11 total). shared/core/security type-check clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HxwMXu8tusGrFcZe6iC9j8
Contributor
Automated code review (gate-code-review)Credit balance is too low Report-only — this check never blocks merge. |
The consolidation added the first @fuzefront/core -> @fuzefront/shared/kafka import; the 'Identity UI + Security (unit)' job built core before shared, so tsc resolved shared from its stale committed dist and failed on the new registry exports (schemaForTopic/partitionKeyForPayload). Build shared first. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HxwMXu8tusGrFcZe6iC9j8
Contributor
Automated code review (gate-code-review)Credit balance is too low Report-only — this check never blocks merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Description
Follow-up to #520. Moves the generic outbox-relay wiring — topic→schema validation, partition-key derivation, and the Kafka publish/DLQ adapter — out of
security-serviceand into the shared backend package, so every backend service (and the planned Pythonfuzefront-eventsmirror, FFRNT-176) shares one install-and-go surface:startOutboxRelayFromEnv({ db }).No behaviour change — pure consolidation. The contract package owns the schema lookup,
@fuzefront/coreowns the transport, the service owns only its own emit/consume logic.🔄 Type of Change
🧪 Testing
@fuzefront/sharedtsc -p tsconfig.kafka.jsonclean; registry tests (6) — schema resolution, unmapped→undefined, key derivation@fuzefront/coretsc --noEmitclean; publisher tests (11 total) — envelope+key, schema-validated vs raw path, DLQ, and no-broker no-op — via an injectable producer seamsecurity-servicetsc --noEmitclean against the new core surface🔧 Implementation Details
Changes Made
@fuzefront/shared: newSCHEMA_BY_TOPICregistry +schemaForTopic()+partitionKeyForPayload()— the contract now owns schema lookup and the ordering-key rule (so language bindings derive them identically).@fuzefront/core:createKafkaOutboxPublisher(config)+startOutboxRelayFromEnv({ db, … }), with an injectablemakeOutboxPublisher(getProducer)seam for unit tests. Adds a@fuzefront/shareddependency — safe: the only core consumers (applications,security) buildshared's kafka barrel before core in their Dockerfiles; the backend monolith doesn't use core.security-service:services/outboxRelay.tscollapses to a thin delegate callingstartOutboxRelayFromEnv({ db }); the duplicated schema map + key derivation + producer are deleted. Bootstrap (index.ts) is unchanged.Code Quality
🔗 Related Issues and PRs
📝 Additional Notes
Deployment Notes
KAFKA_BROKERS/OUTBOX_RELAY_INTERVAL_MSbehaviour, sameevent_outboxtable.Future Work
fuzefront-events.🤖 Generated with Claude Code
Generated by Claude Code