 (ns fault.patterns
   (:require [fault.core :as core])
-  (:import (fault ServiceExecutor)))
+  (:import (fault ServiceExecutor RejectedActionException)))
 
 (set! *warn-on-reflection* true)
 

                           (reduced (persistent! acc1))
                           acc1)))
                     (transient #{})
                     (repeatedly rand-fn)))))))
                                               (iterate next-fn start-idx)))))))

(defn submit-load-balanced-action [load-balancer key->fn timeout-millis]
  (some (fn [[key {:keys [service]}]]
          (try (core/submit-action ^ServiceExecutor service
                                   (get key->fn key)
                                   timeout-millis)
               (catch RejectedActionException _ nil)))
        (load-balancer)))

(defn perform-load-balanced-action [load-balancer key->fn]
  (some (fn [[key {:keys [service]}]]
          (try (core/perform-action service (get key->fn key))
               (catch RejectedActionException _ nil)))
        (load-balancer)))

(defn shotgun [key->service action-count]
  (let [key-service-tuples (vec key->service)
