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
KTOR-4766 - Add basic support to use UnixSockets with CIO #3342
base: main
Are you sure you want to change the base?
Conversation
4aa20ec
to
d81391a
Compare
eafe8a8
to
e43245b
Compare
Hey @hfhbd, sorry for the delay. Could you rebase it on the main branch? I will take a look |
You do accept breaking changes now, don't you? |
Yep, we do :) |
timeout: WeakTimeoutQueue, | ||
serverJobName: CoroutineName, | ||
acceptJobName: CoroutineName, | ||
selector: SelectorManager, |
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.
This argument can be eliminated. Right now it's only for:
serverJob.invokeOnCompletion {
selector.close()
}
but serverJob
is available in the returned HttpServer
instance as rootServerJob
.
So the caller can do
val selector = ...
val server = httpServer(...)
server.rootServerJob.invokeOnCancelation {
selector.cancel()
}
I would absolutely love the new Can we merge that separately from the CIO application stuff? I would love to discuss propagating support for unix domain sockets into the public API, but also a non-internal API for wrapping arbitrary |
Hey @JakeWharton, thanks for the feedback! Sure, it would be great! We already have some basic Unix socket API in the Could you also tell me what you mean by separating the HTTP server from the CIO application? At the moment, the CIO is responsible for making HTTP over sockets. |
The built-in unix domain socket support relies on Immediately, I am trying to wrap Android's In general, I would like to see setup of the transport sufficiently decoupled from the actual HTTP server so that I can set up whatever mechanism I want. A litmus test for this being successful would be using a file watcher on a folder that has
Sorry I was a little imprecise here. I was referring to the |
I'll also add that the client should ideally support similar levels of layering if it doesn't already. What use an HTTP server listening on an UDS in the abstract namespace if I can't also send it requests from the client using that mechanism as its transport? |
@JakeWharton, thanks for the clarification! Got it! It looks possible. Let me play with it and check what API needs to be public and how we can expose it. It seems it should be all done on the Btw if you already have an idea of how to do this, please let me know |
Prior to this my usage of ktor server has never exceeded the most basic setup of one or two routes. I'm just now starting to investigate more wild usages so still trying to learn the structure of the internals. |
e43245b
to
15bc894
Compare
15bc894
to
55130c1
Compare
Subsystem
CIO Client and Server
Motivation
Add basic support for unix sockets with a custom CIO client and server. Native (and better) support would require breaking changes.
Solution
Extract resolving the socketAddress into new functions without breaking changes. A user can now implement unix socket support using a custom cio client/server with minimal code.