FundingCircle / jackdaw

A Clojure library for the Apache Kafka distributed streaming platform.
https://fundingcircle.github.io/jackdaw/
BSD 3-Clause "New" or "Revised" License
369 stars 80 forks source link

Add divert? functions #237

Closed bn-darindouglass-zz closed 4 years ago

bn-darindouglass-zz commented 4 years ago

Bringing in context from Slack:

Some background: for one of our kstreams apps we have a util function call divert? that'll push off a record if a given predicate is true (i.e. to a failure topic, etc):

(defn divert? [stream pred topic]
  (let [[divert-stream continue-stream] (j/branch stream [pred (constantly true])]
    (j/to divert-stream topic)
    continue-stream)

This abstraction, IMO, would feel really good in the library proper because it provides a useful layer on top of j/branch to handle what i'd think is a common use-case (again, failure topics, etc);

mt3593 commented 4 years ago

Looks like a dup of #238