-
Notifications
You must be signed in to change notification settings - Fork 1.6k
httpd: added listener index to http request #2800
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
base: master
Are you sure you want to change the base?
httpd: added listener index to http request #2800
Conversation
Seastar http server implementation supports multiple listeners. It may be required for the handler logic to know which listener the connection is coming from. Added listener_idx field to `httpd::request` to allow handler recognize listener. Signed-off-by: Michal Maslanka <[email protected]>
|
Index seems wrong, we should pass some interface that one can call methods on. |
|
So instead of: something like: and then application creates subclasses of |
|
How do you map listener index to the data you need? Presumably when you call |
N endpoints are listened on and we rely on the indexes being 0..N-1 in that order:
It looks possible, I'll ask. |
|
@xemul - BTW, I suppose we are guaranteed that |
I feel a little bad about having an abstract class that has no virtual methods, it basically says static_cast me because there is no elegant way to reach the virtual method. The routes thing is completely orthogonal, yes? You want each listener to respond to exactly the same routes, but still each request wants to know what port/IP it listened on. Anyway, your proposed solution looks okay. I don't think unique_ptr makes sense though, the listener should be owned by the user. And no need for _opaque to remind me forever that I don't like it. |
You could indeed use (addr, port) as a lookup key in a hash table, if it's not performance sensitive. That doesn't require adding anything except some accessors to the connection. |
Yes, that's the price we pay for type-erasure I guess?
That's right. |
Then why not look up the address/port? I don't mind a type-erased thing (I don't think the unique_ptr is necessary), but maybe the whole thing is unneeded. |
It's a good question and as above I'm not sure: I wasn't the original user, just trying to upstream things we are carrying in our fork that might make sense upstream. I'll move this into draft while I I look into it on our end. |
Seastar http server implementation supports multiple listeners. It may be required for the handler logic to know which listener the connection is coming from. Added listener_idx field to
httpd::requestto allow handler recognize listener.We have been using this in production for a couple of years. In Redpanda, we need to know which listener a request was made on to apply different authentication methods.