diff --git a/content/400-pulse/250-database-setup/index.mdx b/content/400-pulse/250-database-setup/index.mdx index dfc023b474..cdc4b59460 100644 --- a/content/400-pulse/250-database-setup/index.mdx +++ b/content/400-pulse/250-database-setup/index.mdx @@ -6,12 +6,6 @@ tocDepth: 3 toc: true --- - - -Prepare your database to work with Prisma Pulse. - - - ## 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). diff --git a/content/400-pulse/300-database-events.mdx b/content/400-pulse/300-database-events.mdx index 6709185536..75ea6b5321 100644 --- a/content/400-pulse/300-database-events.mdx +++ b/content/400-pulse/300-database-events.mdx @@ -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) + diff --git a/content/400-pulse/400-api-reference.mdx b/content/400-pulse/400-api-reference.mdx index 7553985104..0146bbf4dd 100644 --- a/content/400-pulse/400-api-reference.mdx +++ b/content/400-pulse/400-api-reference.mdx @@ -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 diff --git a/static/img/pulse/with-name.png b/static/img/pulse/with-name.png new file mode 100644 index 0000000000..c6c4077f9d Binary files /dev/null and b/static/img/pulse/with-name.png differ diff --git a/static/img/pulse/without-name.png b/static/img/pulse/without-name.png new file mode 100644 index 0000000000..db2d23aeae Binary files /dev/null and b/static/img/pulse/without-name.png differ