Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,30 @@
]
},
{
"group": "Event-Driven Federated Subscriptions (EDFS)",
"icon": "calendar-users",
"group": "Cosmo Streams (EDFS)",
"icon": "wave",
"pages": [
"router/event-driven-federated-subscriptions-edfs",
"router/cosmo-streams",
{
"group": "NATS",
"icon": "puzzle-piece",
"pages": [
"router/event-driven-federated-subscriptions-edfs/nats",
"router/event-driven-federated-subscriptions-edfs/nats/stream-and-consumer-configuration"
"router/cosmo-streams/nats",
"router/cosmo-streams/nats/stream-and-consumer-configuration"
]
},
"router/event-driven-federated-subscriptions-edfs/kafka",
"router/event-driven-federated-subscriptions-edfs/redis",
"router/event-driven-federated-subscriptions-edfs/custom-modules"
"router/cosmo-streams/kafka",
"router/cosmo-streams/redis",
{
"group": "Custom Modules",
"icon": "cubes",
"pages": [
"router/cosmo-streams/custom-modules",
"router/cosmo-streams/custom-modules/subscription-on-start",
"router/cosmo-streams/custom-modules/on-receive-event",
"router/cosmo-streams/custom-modules/on-publish-event"
]
}
Comment thread
alepane21 marked this conversation as resolved.
]
},
"router/compliance-and-data-management",
Expand Down Expand Up @@ -738,5 +747,11 @@
"gtm": {
"tagId": "GTM-5GPL7DQH"
}
}
},
"redirects": [
{
"source": "/router/event-driven-federated-subscriptions-edfs/:path*",
"destination": "/router/cosmo-streams/:path*"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Event-Driven Federated Subscriptions (EDFS)"
description: "EDFS combines the power of GraphQL Federation and Event-Driven Architecture (Kafka, NATS, Redis) to update a user GraphQL Subscription after an event occurs in your system."
title: "Cosmo Streams (EDFS)"
description: "Cosmo Streams (formally known as EDFS) combines the power of GraphQL Federation and Event-Driven Architecture to update a user GraphQL Subscription after an event occurs in your system."
icon: "circle-info"
sidebarTitle: "Overview"
---
Expand All @@ -9,7 +9,7 @@ sidebarTitle: "Overview"
![](/images/router/EDFS.png)
</Frame>

Event Driven Federated Subscriptions (EDFS) solves 3 major problems when it comes to GraphQL Federation and Subscriptions by directly connecting the Router to an event source like Kafka and NATS and making it a part of the Graph.
Cosmo Streams solves 3 major problems when it comes to GraphQL Federation and Subscriptions by directly connecting the Router to an event source like Kafka and NATS and making it a part of the Graph.

## Intro

Expand Down Expand Up @@ -38,9 +38,9 @@ Furthermore, classic Subscriptions with Federation are quite expensive when it c

## Specification

Enter Event-Driven Federated Subscriptions, a simple way to scale Federated Subscriptions in a resource-efficient manner.
Enter Cosmo Streams, a simple way to scale Federated Subscriptions in a resource-efficient manner.

EDFS supports three event providers:
Cosmo Streams supports three event providers:

<CardGroup cols={3}>
<Card title="Kafka" icon="sitemap" href="/router/event-driven-federated-subscriptions-edfs/kafka">
Expand All @@ -58,7 +58,7 @@ Each provider consists of at least Publish and Subscribe capabilities. For NATS,

Our goal is to integrate with various technologies rather than agree on a single unified interface. This approach allows us to leverage the strengths of each technology. This philosophy is reflected in how we structure the directives, naming parameters, exposing features as they would appear in their respective ecosystems.

Here is an overview about all EDFS directives:
Here is an overview about all Cosmo Streams directives:

```js
# Nats and JetStream integration
Expand Down Expand Up @@ -120,7 +120,7 @@ An Event-Driven Subgraph does not need to be implemented. It is simply a Subgrap

## Prerequisites

To use EDFS, you need to have an Event Source running and connected to the Router. Currently, we support NATS, Kafka, and Redis. For simplicity, NATS is used to explain the examples.
To use Cosmo Streams, you need to have an Event Source running and connected to the Router. Currently, we support NATS, Kafka, and Redis. For simplicity, NATS is used to explain the examples.

To get started, run a NATS instance and add the following configuration to your `config.yaml` Router Configuration:

Expand Down Expand Up @@ -315,7 +315,7 @@ Here's an **invalid** message as the `__typename` field is missing:

</CodeGroup>

It's important to send the `__typename` field because this allows EDFS to also work for Union and Interface types.
It's important to send the `__typename` field because this allows Cosmo Streams to also work for Union and Interface types.

It's worth noting that the Router will not send any responses before you publish a message on the topic. If you need the most recent result, first make a Query, and then subscribe to the Topic. The Router will send the first response only after a message is published on the rendered topic.

Expand Down Expand Up @@ -437,11 +437,11 @@ The Cosmo Router deduplicates Subscriptions internally to save resources. If mul

### Statelessness of Subgraphs

With EDFS, the Router connects directly to the Event Source but doesn't require any stateful connections, e.g. WebSocket, to the Subgraphs. This makes the Subgraphs much simpler to reason about and easier to deploy. Serverless deployment options usually have limitations on request length. With an Event Broker in the middle, Subgraphs can be stateless without having to give up on Subscriptions.
With Cosmo Streams, the Router connects directly to the Event Source but doesn't require any stateful connections, e.g. WebSocket, to the Subgraphs. This makes the Subgraphs much simpler to reason about and easier to deploy. Serverless deployment options usually have limitations on request length. With an Event Broker in the middle, Subgraphs can be stateless without having to give up on Subscriptions.

### Efficiency, CPU & Memory Consumption (Epoll/Kqueue)

EDFS is built on top of Event-Driven principles, which means that the implementation is non-blocking, as CPU efficient as possible, and has a very low memory footprint.
Cosmo Streams is built on top of Event-Driven principles, which means that the implementation is non-blocking, as CPU efficient as possible, and has a very low memory footprint.

We're using Epoll and Kqueue on Systems that support it (Linux, Darwin, etc.) to be as efficient as possible.

Expand All @@ -451,10 +451,10 @@ The Router supports multi-core out of the box and is capable of scaling up to a

### Publish Events from any System, not just Subgraphs

It's worth noting that publishing Entity update Events is not limited to just Subgraphs. EDFS is designed to fully decouple the API Consumer from the implementation of the Event-Driven Architecture.
It's worth noting that publishing Entity update Events is not limited to just Subgraphs. Cosmo Streams is designed to fully decouple the API Consumer from the implementation of the Event-Driven Architecture.

A client can create a Job via a Mutation and Subscribe to the Job state via EDFS. Next, the Mutation can kick off a long-running process that will be handled by one or many systems in the background. At each step, e.g. when an increment of work is done, each subsystem can publish a message to indicate that the state of an Entity has changed.
A client can create a Job via a Mutation and Subscribe to the Job state via Cosmo Streams. Next, the Mutation can kick off a long-running process that will be handled by one or many systems in the background. At each step, e.g. when an increment of work is done, each subsystem can publish a message to indicate that the state of an Entity has changed.

Once the message is published by one of the sub-systems, the Router can Query all Subgraphs to resolve the current state of the Job.

With EDFS, each Subgraph can add fields to an Entity that it's responsible for and publish events to the Message Broker when a long-running Operation updates the overall state of an Entity.
With Cosmo Streams, each Subgraph can add fields to an Entity that it's responsible for and publish events to the Message Broker when a long-running Operation updates the overall state of an Entity.
17 changes: 17 additions & 0 deletions docs/router/cosmo-streams/custom-modules.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "Custom Modules"
sidebarTitle: Overview
description: "Customize Streams behavior with powerful handlers for subscription lifecycle, event processing, and data transformation."
icon: "circle-info"
---

Cosmo Router provides powerful handlers to hook into the event processing of Cosmo Streams.
These handlers allow you to implement custom logic for subscription lifecycle management, event processing and data transformation.

## Available Hooks

The Cosmo Streams system provides three main hook interfaces that you can implement with [Custom Modules](/router/custom-modules):

- [`SubscriptionOnStartHandler`](/router/event-driven-federated-subscriptions-edfs/custom-modules/subscription-on-start): Called when a client subscribes
- [`OnReceiveEventHandler`](/router/event-driven-federated-subscriptions-edfs/custom-modules/on-receive-event): Called when events are received from a message broker
- [`OnPublishEventHandler`](/router/event-driven-federated-subscriptions-edfs/custom-modules/on-publish-event): Called when events are going to be sent to a message broker
Loading