cosmo
cosmo copied to clipboard
feat(router): implement Cosmo Streams v1
Summary by CodeRabbit
-
New Features
- Hook-driven subscription & stream lifecycle (on-start, receive, publish) for provider-agnostic event auth, transformation, filtering, and initial messages.
- Generic stream event model enabling mutable/immutable events and multi-event publishing.
-
Configuration
- New subscription_hooks with on_receive_events (max concurrent handlers, handler timeout) and runtime hook wiring.
-
Documentation
- ADR/RFC and examples for hook usage and provider integration.
-
Tests
- Extensive unit/integration tests covering hooks across Kafka, NATS, Redis and failure scenarios.
Checklist
- [x] I have discussed my proposed changes in an issue and have received approval to proceed.
- [x] I have followed the coding standards of the project.
- [x] Tests or benchmarks have been added or updated.
- [x] Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
- [x] I have read the Contributors Guide.
Context
This pull request implements Cosmo Streams v1. It rebrands and extends EDFS by the ability to add hooks in form of new custom modules:
SubscriptionOnStart: A handler running before a subscription is establishedOnReceiveEvents: A handler running whenever events are received from a message provider, before being passed to clientsOnPublishEvents: A handler running before events are getting sent to message providers
These custom modules extend EDFS´s capabilities by allowing custom authorization logic, event filtering, etc.
The preview docs explains this in more detail. It's a good place to see what the hooks are capable of and how to use them. https://wundergraphinc-topics-streams-v1.mintlify.app/overview
Related pull requests
There are two other pull requests, which contribute to the initial release of Cosmo Streams.
Cosmo Docs: https://github.com/wundergraph/cosmo-docs/pull/187 Engine: https://github.com/wundergraph/graphql-go-tools/pull/1309
[!IMPORTANT]
This pull request must not be merged before the engine pull request has been merged. The router´s go.mod in this pull request currently points to a version of the engine from the Cosmo Streams branch and once we have an official version of the engine with these changes included, this pull requests gets updated to use that.