Open ignoramous opened 2 years ago
Deno.Conn
doesn't implement connection pooling. I feel like it's something that should be left to the 3rd party modules.
If there are missing APIs that are required to implement pooling then I'll be happy to accept a PR that adds relevant APIs.
Thanks. Does Deno impl connection pools of its own for HTTP/S?
Thanks. Does Deno impl connection pools of its own for HTTP/S?
For fetch
we use reqwest
which provides connection pooling, but for HTTP server bindings Deno.serveHttp()
this is up to the user to pool connections.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
Hi @crowlKats
I had opened this bug is for APIs to facilitate creating connection pools for TCP/UDP conns, while the linked PR, I believe, addresses pooling for http-server?
@ignoramous You are correct; I'll reopen this issue
I am unsure if
Deno.connect
requires clients to implement connection pooling, because the current API surface thatDeno.Conn
exposes makes it tricky to implement one (though, folks indeed have impl poolers atop it usingtry..catch
semantics).In comparing with NodeJS
net
, I believe equivalent of these two APIs are needed inDeno.Conn
(TCP):socket.readyState
tells if conn is open or half-open.socket.destroyed
tells if conn is open at all.socket.keepalive
.(Here's how we use those APIs to determine health of a tcp-conn).
NodeJS
net
also exposessocket.resume
andsocket.pause
, though those are not really required to build a pooler.From NodeJS
dgram
, for connected UDP sockets,Event.close
andEvent.error
come in handy to remove failed conns preemptively from the pool.(Here's how we use those events to evict udp-conns from the pool).
Of course, if Deno doesn't require client-code to pool (TCP/UDP) conns at all (like for HTTP), then that's even more awesome. From this github discussion, it is confirmed that
tokio
doesn't pool conns, but thattower
does... but I am not fluent in Rust to deduce anything from Deno's use oftower
.cc: @bartlomieju