-
Notifications
You must be signed in to change notification settings - Fork 176
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
cohttp-eio: Document Server.run
#961
Comments
I suppose there is an argument to be made I should have been a bit more careful considering it takes the < domain_mgr : Eio.Domain_manager.t
; net : Eio.Net.t
; clock : Eio.Time.clock
; .. > Because I get lazy and just have to give it all of the |
Thanks for the feedback. Indeed, the API needs to be documented, possibly sprinkled with examples if the text is not clear.
Not too sure about this since in the new OCaml 5.0 world, multicore is the new default. But yes, the default value need to be documented. |
Ah actually I misread the code and the error was a domain problem I created myself apologies, the cohttp server is single threaded by default my bad (unless Regarding the use of
After a cursory glance, I don't think the connection handler needs everything in |
Server.run
, possibly use single domain by default?Server.run
I think we should move Though I'm not a big fan of creating the socket and running the accept loop in a single function. You almost always want to split those (e.g. to allow receiving a listening socket from systemd, or to send a notification that the socket is ready after you start listening but before entering the loop). Also, both parts may have lots of options (e.g. to set various socket options on the listening socket and to control how many concurrent users to allow in the loop), so splitting it in two might make the code easier to read.
Yes, looks like this should just be taking a clock. |
I am open to this. Do you want the the function moved to |
Just to clarify on the above point. I think even after moving some of the functionality of |
I find it a little strange for a library to be getting things from the environment, it seems like something you should add to your binaries (dune executables) that you then pass to the library function (what is currently happening in |
We'll probably want to change a few other things:
|
What should happen if we reach/breach the specified number of connections? sleep and try accepting again? |
I was imagining something like: let pool = Semaphore.make max_connections in
while true do
Semaphore.acquire pool;
Net.accept_fork ... (fun flow addr ->
...
Semaphore.release pool
)
done |
Hello!
cohttp-eio
is yet unreleased but there is analpha
so hopefully that means you are happy to accept feedback :))I'm using the server in a real-world application and I think it would be good to document
Server.run
and all of the parameters, in particular what the default parameters are for each of the optional arguments.I also think it would be good to make the server use only one domain to accept connections by default, leaving it up to the user to add more if they please. I had assumed this and then happened to be using
Irmin
in the handlers (it was a REST server on top of an irmin store) and then was surprised by some weird bugs but the tl;dr is that Irmin is not domain-safe and I was reading/writing to it from multiple domains in parallel without realising it. I feel like potentially others might do the same.cc: @bikallem
The text was updated successfully, but these errors were encountered: