Fork me on GitHub
#clojure
<
2022-01-15
>
wombawomba10:01:10

I have a feeling there's a function like (fn [xs] (reductions conj [] xs)) somewhere in the standard lib, but I can't find it. Am I mistaken?

Nazral11:01:46

isn't this like (into [] xs) ? nevermind

stephenmhopper21:01:51

@ghadi I plan on making heavy use of iteration. What’s your recommended pattern for handling failures that happen when using iteration to call external APIs? Have you implemented retry logic with iteration for failed calls?

👍 1
stephenmhopper21:01:07

I’m assuming you use halt-when. Do you throw exceptions ever? What general guidelines / recommendations can you provide?

stephenmhopper22:01:44

@ghadi Thanks for the explanations below. That’s all very helpful. I’ll probably end up putting retry logic into the step! function. I was completely unaware of halt-when until about 60 minutes ago when I watched the Zoom call video thing covering the current alpha Clojure release. That get-textract-results example is very helpful. I really like the way that I can handle errors while still returning the results that were created / accumulated up to that point. This will greatly clean up my code!

ghadi22:01:38

@stephenmhopper I think it makes sense to put retry logic in either the step! or within the caller of iteration

ghadi22:01:09

I have a couple usages with the cognitect aws-api client where the :some? arg looks for an anomaly

ghadi22:01:39

but, in that case, if :some? is false on an anomaly, the anomaly will not be included in the output

ghadi22:01:45

you can also include the anomaly in the output by making it a valid output in :some? , then having the :kf not proceed to the next step upon an anomaly

ghadi22:01:20

in that scenario, into + halt-when + iteration works nicely together

ghadi22:01:26

note that now with a expression like (into [] (halt-when ...) coll) , it can return a non-vector because halt-when is in charge of the return value

ghadi22:01:37

in the example above aws/invoke does retry automatically. It will return an anomaly if the retry policy is exhausted