Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the size of a response #413

Merged
merged 1 commit into from
Nov 21, 2023
Merged

Limit the size of a response #413

merged 1 commit into from
Nov 21, 2023

Conversation

Florimond
Copy link
Member

From the begining, mqtt.go defines a maximum size for a response. However if the limit was met, it resulted in an error and no message was sent. Now, the Query itself limits the size of a frame and messages are sent to the client, but only those whose total size <= to the total size of allowed in a response.

Implications on the current API: for a subscribe request with a Last=X parameter, the client will receive the last messages whose total size is <= to the max size of a response, with a maximum of X messages. This behavior is an improvement over just getting an error.

From the begining, mqtt.go defines a maximum size for a response.
However if the limit was met, it resulted in an error and no message was
sent. Now, the Query itself limits the size of a frame and messages are
sent to the client, but only those whose total size <= to the total size
of allowed in a response.

Implications on the current API: for a subscribe request with a Last=X
parameter, the client will receive the last messages whose total size is <= to
the max size of a response, with a maximum of X messages. This behavior is an
improvement over just getting an error.
@coveralls
Copy link

Coverage Status

coverage: 93.099% (-0.01%) from 93.109%
when pulling 766c0e0 on response_size_limitation
into 30adcd2 on master.

@Florimond Florimond self-assigned this Nov 19, 2023
@Florimond Florimond merged commit 92c4c9e into master Nov 21, 2023
3 checks passed
@Florimond Florimond deleted the response_size_limitation branch November 21, 2023 21:15
Florimond added a commit that referenced this pull request Nov 21, 2023
The history api allows to retrieve any number of messages stored in a channel.
As the number of messages that can return in a single response is limited by
the size of a response (as per #413), a system of pagination is required.
This system is implemented with the introduction of the StartFromID query
parameter. An client that already received a response with a certain number of
messages can send a new request to the API with the StartFromID set to the ID
of the last message it received. The storage query will then start retreiving
messages starting at that ID to provide the API the next page of messages in
its response.
Florimond added a commit that referenced this pull request Nov 22, 2023
The history api allows to retrieve any number of messages stored in a channel.
As the number of messages that can be returned in a single response is limited
by the size of a response (as per #413), a system of pagination is required.
This system is implemented with the introduction of the StartFromID query
parameter. An client that already received a response with a certain number of
messages can send a new request to the API with the StartFromID set to the ID
of the oldest message it received (first in the array). The storage query will
then begin to retrieve messages starting at the ID preceding the ID provided in
the query, to generate the next page of messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants