Skip to content

Commit ee2e9b3

Browse files
authored
Allow notification batching (#53)
* Allow notification batching * Remove from auth request * Format * Update doc * Add prepare.sh * Update doc * Improve script
1 parent 1a8a029 commit ee2e9b3

4 files changed

Lines changed: 71 additions & 0 deletions

File tree

doc/docs.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
- [ServerMessage.HlsPlayable](#fishjam-ServerMessage-HlsPlayable)
9898
- [ServerMessage.HlsUploadCrashed](#fishjam-ServerMessage-HlsUploadCrashed)
9999
- [ServerMessage.HlsUploaded](#fishjam-ServerMessage-HlsUploaded)
100+
- [ServerMessage.NotificationBatch](#fishjam-ServerMessage-NotificationBatch)
100101
- [ServerMessage.PeerAdded](#fishjam-ServerMessage-PeerAdded)
101102
- [ServerMessage.PeerConnected](#fishjam-ServerMessage-PeerConnected)
102103
- [ServerMessage.PeerCrashed](#fishjam-ServerMessage-PeerCrashed)
@@ -1363,6 +1364,7 @@ Defines any type of message passed between FJ and server peer
13631364
| viewer_disconnected | [ServerMessage.ViewerDisconnected](#fishjam-ServerMessage-ViewerDisconnected) | | |
13641365
| streamer_connected | [ServerMessage.StreamerConnected](#fishjam-ServerMessage-StreamerConnected) | | |
13651366
| streamer_disconnected | [ServerMessage.StreamerDisconnected](#fishjam-ServerMessage-StreamerDisconnected) | | |
1367+
| notification_batch | [ServerMessage.NotificationBatch](#fishjam-ServerMessage-NotificationBatch) | | Batch |
13661368
| stream_connected | [ServerMessage.StreamConnected](#fishjam-ServerMessage-StreamConnected) | | **Deprecated.** |
13671369
| stream_disconnected | [ServerMessage.StreamDisconnected](#fishjam-ServerMessage-StreamDisconnected) | | **Deprecated.** |
13681370
| hls_playable | [ServerMessage.HlsPlayable](#fishjam-ServerMessage-HlsPlayable) | | **Deprecated.** |
@@ -1498,6 +1500,31 @@ Notification sent when the HLS recording is successfully uploaded to AWS S3
14981500

14991501

15001502

1503+
<a name="fishjam-ServerMessage-NotificationBatch"></a>
1504+
1505+
### ServerMessage.NotificationBatch
1506+
Carries multiple notifications in a single wire frame.
1507+
1508+
Constraints (documented, not schema-enforced):
1509+
- Each element&#39;s `content` MUST be a notification variant — never
1510+
Authenticated, AuthRequest, SubscribeRequest, or SubscribeResponse.
1511+
- NotificationBatch MUST NOT be nested inside another NotificationBatch.
1512+
The schema technically permits this, but senders must not emit
1513+
recursive batches and receivers may treat them as a protocol violation.
1514+
- Notifications are delivered in array order; consumers must process
1515+
them in order.
1516+
- Sent only for webhooks, for peers that .
1517+
1518+
1519+
| Field | Type | Label | Description |
1520+
| ----- | ---- | ----- | ----------- |
1521+
| notifications | [ServerMessage](#fishjam-ServerMessage) | repeated | |
1522+
1523+
1524+
1525+
1526+
1527+
15011528
<a name="fishjam-ServerMessage-PeerAdded"></a>
15021529

15031530
### ServerMessage.PeerAdded

fishjam/server_notifications.proto

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,21 @@ message ServerMessage {
233233
string streamer_id = 2;
234234
}
235235

236+
// Carries multiple notifications in a single wire frame.
237+
//
238+
// Constraints (documented, not schema-enforced):
239+
// - Each element's `content` MUST be a notification variant — never
240+
// Authenticated, AuthRequest, SubscribeRequest, or SubscribeResponse.
241+
// - NotificationBatch MUST NOT be nested inside another NotificationBatch.
242+
// The schema technically permits this, but senders must not emit
243+
// recursive batches and receivers may treat them as a protocol violation.
244+
// - Notifications are delivered in array order; consumers must process
245+
// them in order.
246+
// - Sent only for webhooks, for peers that .
247+
message NotificationBatch {
248+
repeated ServerMessage notifications = 1;
249+
}
250+
236251
reserved 12;
237252

238253
oneof content {
@@ -273,6 +288,9 @@ message ServerMessage {
273288
StreamerConnected streamer_connected = 26;
274289
StreamerDisconnected streamer_disconnected = 27;
275290

291+
// Batch
292+
NotificationBatch notification_batch = 33;
293+
276294
// Deprecated
277295

278296
StreamConnected stream_connected = 22 [deprecated = true];

fishjam_protos/lib/fishjam/server_notifications.pb.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,17 @@ defmodule Fishjam.ServerMessage.StreamerDisconnected do
443443
field :streamer_id, 2, type: :string, json_name: "streamerId"
444444
end
445445

446+
defmodule Fishjam.ServerMessage.NotificationBatch do
447+
@moduledoc false
448+
449+
use Protobuf,
450+
full_name: "fishjam.ServerMessage.NotificationBatch",
451+
protoc_gen_elixir_version: "0.16.0",
452+
syntax: :proto3
453+
454+
field :notifications, 1, repeated: true, type: Fishjam.ServerMessage
455+
end
456+
446457
defmodule Fishjam.ServerMessage do
447458
@moduledoc false
448459

@@ -572,6 +583,11 @@ defmodule Fishjam.ServerMessage do
572583
json_name: "streamerDisconnected",
573584
oneof: 0
574585

586+
field :notification_batch, 33,
587+
type: Fishjam.ServerMessage.NotificationBatch,
588+
json_name: "notificationBatch",
589+
oneof: 0
590+
575591
field :stream_connected, 22,
576592
type: Fishjam.ServerMessage.StreamConnected,
577593
json_name: "streamConnected",

prepare.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
find fishjam -name "*.proto" | sort | xargs docker run --rm -v $PWD/doc:/out -v $PWD:/protos pseudomuto/protoc-gen-doc --doc_opt=markdown,docs.md
6+
7+
buf format -w
8+
buf lint
9+
10+
(cd ./fishjam_protos; ./compile_proto.sh)

0 commit comments

Comments
 (0)