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

Add RL response headers in correct phase #144

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

adam-cattermole
Copy link
Member

@adam-cattermole adam-cattermole commented Nov 13, 2024

This passes the response_headers back up to the filter layer so that we can add the headers only at the last phase

Adding these headers before we send to the upstream service is not allowed, and if you set rateLimitHeaders: DRAFT_VERSION_03 for limitador the shim will panic without this change.

@adam-cattermole
Copy link
Member Author

Apologies to @didierofrivia here I incorrectly suggested to break this #95 (comment)

@adam-cattermole adam-cattermole marked this pull request as ready for review November 13, 2024 11:25
@adam-cattermole adam-cattermole requested a review from a team as a code owner November 13, 2024 11:25
@adam-cattermole adam-cattermole self-assigned this Nov 13, 2024
@adam-cattermole adam-cattermole changed the title Add response headers in correct phase Add RL response headers in correct phase Nov 13, 2024
@adam-cattermole adam-cattermole linked an issue Nov 13, 2024 that may be closed by this pull request
if GrpcService::process_grpc_response(
operation,
resp_size,
&mut self.response_headers_to_add,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a code smell... this seems to invert the indirection between the state machine possibly progressing and the result of such a progress... Not a huge deal, I don't think this is even a first. "Just" mentioning it...

The way I think about it: something happens, this has a "result" (i.e. some output) and that output is dealt with. Which in this particular case would be adding the headers to this Vec, but the action knows nothing about that Vec, instead it merely returns the entries to add to a caller that then knows what to do with them.

Copy link
Member Author

@adam-cattermole adam-cattermole Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so you think it'd be preferable to have some kind of GrpcResult containing the response headers to let the filter deal with that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind for now... we probably would want to go to the drawing board at some point and design this a little more thoroughly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this.. I realise we would likely change a lot of things here, but how about this alternative in latest commit?

Copy link
Member

@didierofrivia didierofrivia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies to @didierofrivia here I incorrectly suggested to break this #95 (comment)

No worries, at the time it made sense to me too!

👍🏼

@adam-cattermole adam-cattermole merged commit 3c8fc45 into main Nov 13, 2024
13 checks passed
@adam-cattermole adam-cattermole deleted the fix-rl-response-headers branch November 13, 2024 14:10
@adam-cattermole adam-cattermole added the bug Something isn't working label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Response is not added to response.success.headers
3 participants