feat(wstransport): add support for concurrent accept #181
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR helps address logos-messaging/logos-messaging-nim#3634 by adding public APIs
acceptStreamandprocessHttpRequesttoHttpServer.Also added a "Test accept" test suite which tests both
acceptandacceptStreamwithprocessHttpRequest.Rationale
Client code that doesn't tolerate the head-of-line blocking of the existing
acceptAPI can instead (i) callacceptStreamin a loop, in a dedicated task to create remote-client sockets from the server socket, and (ii) spawn new tasks to callprocessHttpRequestand wait for and process HTTP headers arriving from the client socket (which can take a long time and shouldn't block new remote-client sockets).Alternatives (tried before):
accept: Even with a fix to Chronos' inability to handle StreamServer.accept multitasking we have observed very weird behavior; in any case, this kind of solution fights Chronos and is not ideal.accept: even if it's still nominally just anacceptAPI, client code still has to asyncSpawn, in addition to the asyncSpawn insideaccept.HttpRequestobject becomes "hollow" and needs to be populated later; clients need to know that a future insideHttpRequestmust be awaited before accessing its data fields.