Fork me on GitHub
#clojure
<
2022-07-07
>
Ivan Koz11:07:46

is there a way to make a kind of lazy source in core.async, to create a value only when <! (take) was called on a channel?

rolt16:07:46

are you sure you need core async ? because it feels like you could just consume your lazy source

Joshua Suskalo14:07:06

Make an eager go-loop that puts onto a channel with no buffer.

Joshua Suskalo14:07:35

It will do what you're asking in effect, except that it will precompute each element when the previous one was taken.

Ivan Koz14:07:00

"when the previous one was taken" that's exactly what i'm trying to get around of, the element is computed from a http request, which shouldn't be made in advance

dpsutton14:07:09

reverse the backpressure. have two channels. put on one some token indicating you are ready. have the producer make the request and send the response back on the other channel

Drew Verlee15:07:29

Whats the trade off between sharing a https://http-kit.github.io/client.html between requests or creating a new one each request? The docs say it' "lightweight" but I don't really understand what that means. I see it says that a "TPC connection and SSLEngine get reused if possible" how does a system make that possible? Thd docs say "it" (i assume the clients) wants to keep a TCP connection alive for a while... that implies i want to share the client between requests right? The way of expressing that with a deref is interesting:

; keepalive for 30s
@(http/get "" {:keepalive 30000})
 ; will reuse the previous TCP connection
@(http/get "" {:keepalive 30000})
 ; disable keepalive for this request
@(http/get "" {:keepalive -1})

rolt16:07:00

lightweight usually means using coroutines instead of spawning a thread for each requests keepalive adds a tiny amount of TCP calls, if you were to do a single request, but save a usually bigger amount of network calls by avoid the necessity to run the TCP handshake for each request. The single client thing is done behind the hood, upon your first request. Though you can manually create and use one if you want.

Drew Verlee16:07:54

> The single client thing is done behind the hood, upon your first request. Would you do that by calling new on org.httpkit.client.HttpClient e.g (HttpClient. (some configuration?)

rolt16:07:12

you have a make-client function

👍 1
Job17:07:17

what skills do i need to get a job writing clojure? im aiming at general software engineering roles and backend roles. i have a background in common lisp and scheme. I know enough common lisp to write a compiler. I have once. so thats kind my background. i dont have real world experience but I have gotten interviews before for clojure roles. thanks

seancorfield17:07:41

This is a good topic for #jobs-discuss rather than #clojure

Job17:07:07

sorry, ill copy and paste there

1
seancorfield17:07:59

Cool. Now it's posted there, I've deleted it from here. Thank you!