-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Sessions] Add meta.size to bfetched responses #95774
Conversation
Pinging @elastic/kibana-app-services (Team:AppServices) |
@@ -134,6 +135,11 @@ export const createStreamingBatchedFunction = <Payload, Result extends object>( | |||
if (response.error) { | |||
items[response.id].future.reject(response.error); | |||
} else if (response.result !== undefined) { | |||
if (typeof response.result === 'object') { | |||
response.result.meta = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't really like it that we are adding things to actual response, i would preffer to se meta information separate from actual responses.
also, i think this information could be useful on the server as well, and i would really prefer to keep our server/client API as similar as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried that the responses now may contain this meta
property which is not expected. And it is unfortunate to add the BatchResultBase
interface, as Peter also mentioned.
Could you please make it such that the result data is not modified, i.e. with the extra meta
property? One way that comes to mind could be to return the whole response
, like so (instead of just response.result
):
That way you can use response.json.length
to get the size of the raw response. And response.result
to get the response data as before.
@streamich yep, thanks! |
@elasticmachine merge upstream |
ignoring request to update branch, pull request is closed |
Summary
Since we want to avoid stringifying responses to calculate their size, after consulting with @ppisljar, I added a new
meta
section to the response coming from anybfetch
function.It will contain the response's size in bytes, so it can then be used anywhere it's needed.
Specifically, I intend to use it in #92439 for its cache eviction logic.
I split this out to a separate PR to simplify testing and reviewing.
Checklist
Delete any items that are not applicable to this PR.
For maintainers