Allow options updates after stream initializes #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for features requested in #2
A client can update their
wantedCollections
andwantedDids
after connecting to the socket by sending a JSON payload in a Websocket Text message to Jetstream.Some limitations apply around the size of the message: right now the message can be at most 10MB in size, contain 100 collection filters, and contain 10,000 DID filters.
Additionally, a client can connect with
?requireHello=true
in the query params to pause replay/live-tail until the first Options Update message is sent by the client over the socket.Invalid Options Updates in
requireHello
mode or normal operating mode will result in the client being disconnected.Clients can now also request compression via the
compress=true
query parameter to help support websocket libraries that don't provide an interface for adding headers to the initial GET request.Subscribers can send messages using the
SubscriberSourcedMessage
framing below:This framing will allow us to potentially add other control messages we may want to send from the Client to the Jetstream server in the future.
To send an Options Update, provide the string
options_update
in thetype
field and aSubscriberOptionsUpdatePayload
in thepayload
field.The shape for a
SubscriberOptionsUpdatePayload
is as follows:If either array is empty, the relevant filter will be disabled (i.e. sending empty
wantedDids
will mean a client gets messages for all DIDs again).An example Subscriber Sourced Message with an Options Update payload is as follows:
The above payload will filter such that a client receives only posts, and only from a the specified DID.