missionary

2024-11-05T12:10:32.645539Z

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 ?

Dustin Getz (Hyperfiddle) 2024-11-05T17:03:15.549639Z

you want to process requests sequentially? you specifically do NOT want them to run in parallel?

Dustin Getz (Hyperfiddle) 2024-11-05T17:07:15.553159Z

• 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

Dustin Getz (Hyperfiddle) 2024-11-05T17:07:20.427569Z

https://cljdoc.org/d/missionary/missionary/b.40/api/missionary.core#?%3E

2024-11-05T17:12:49.216999Z

Yes, thank you. Looks like problem was in blocking future. My bad