Hello everyone! I need help with some, maybe, basic thing... I have events flow:
(def events
(m/ap (loop []
(let [e @(http/get URL)]
(m/amb e (recur))))))
or (btw, what is better approach?)
(def events (m/seed (repeatedly @(http/get URL))))
and later I need to process the responses in a line. i am doing m/eduction and many logic inside.
It works well except the moment that events flow doing new requests while previous one is in process. That is not what I need. Can you advice me missionary-idiomatic approach to create a loop like request -> process -> response -> new request ?you want to process requests sequentially? you specifically do NOT want them to run in parallel?
• I think you can use (m/?> n flow) where n is the max concurrency factor (defaults to 1 if omitted)
• wrap the blocking future deref into a thread with m/via- giving you a task
• use (m/seed [a b c]) to make basically a queue of all the tasks you want to run
• consume the queue with m/>, optionally with >1 concurrency factor
https://cljdoc.org/d/missionary/missionary/b.40/api/missionary.core#?%3E
Yes, thank you. Looks like problem was in blocking future. My bad