Skip to content

Commit

Permalink
add note about resuming streams
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed May 24, 2024
1 parent 536608b commit 83723a6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
6 changes: 0 additions & 6 deletions content/400-pulse/250-database-setup/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ tocDepth: 3
toc: true
---

<TopBlock>

Prepare your database to work with Prisma Pulse.

</TopBlock>

## General database instruction

Prisma Pulse requires your database to be configured in a specific way. To get your database ready for Prisma Pulse, follow the general database instructions [here](/pulse/database-setup/general-database-instructions).
Expand Down
21 changes: 21 additions & 0 deletions content/400-pulse/300-database-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,24 @@ With event persistence enabled, pricing is impacted as follows:
- **Event storage**: The amount of disk space the stored events consume (in GiB)

See the [subscription plans](https://www.prisma.io/pricing) for more details. Pricing applies regardless of whether you use `subscribe()` or `stream()`.

## Resuming event streams

The `stream()` API offers the option to provide a [`name`](/pulse/api-reference#options) argument which makes a stream _resumable_:

```ts
const stream = await prisma.user.stream({
name: "all-user-events"
})
```

If a `name` is provided, Pulse tracks the delivery of events with a _cursor_. Only if the event is acknowledged on the receiver side, the cursor associated with that `name` will move.

In case a stream is unavailable for some reason, e.g. because your server was down, the receiver can't acknowledge any events. Once the stream is available again, the stream will pick up at the last cursor position and deliver any events that haven't been acknowledged in the meantime:

![](/img/pulse/with-name.png)

If the `name` option is omitted, no cursor will be associated with the stream and events that happen while a stream is down will not be delivered:`

![](/img/pulse/without-name.png)

2 changes: 2 additions & 0 deletions content/400-pulse/400-api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ const stream = await prisma.user.stream({
});
```

Learn more about resuming streams [here](/pulse/database-events#resuming-event-streams)

#### Filter for new `User` records with a non-null value for `name`

```ts
Expand Down
Binary file added static/img/pulse/with-name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/pulse/without-name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 83723a6

Please sign in to comment.