 
 ;; bucket distributor main entry point
 
+(defrecord RabbitBucketDistributor [options default-buckets peer-id state-atom 
+                              broadcast! broadcast-consumer peers-future partition-future])
+
 (defn start-bucket-distributor! 
   [conn bucket-name default-buckets ^ScheduledExecutorService scheduler options]
 

(defn- bucket-consumer-shutdown-handler!
  "Cleans up resources on consumer shutdown based on observing changes to
   the consumer state."
  [old-state {:keys [instance-id status active empty-signal ch consumer-tag]}]

  (cond
    ;; Let the shutdown thread know (via blockingqueue) when all the active

    (le/declare ch exchange-name "fanout")
    (lq/bind ch queue-name exchange-name)
  
    (map->BroadcastConsumer {:ch ch
                             :consumer-tag (lc/subscribe ch queue-name handler)})))

(defn stop-broadcast-consumer! 
  "Shuts down the broadcast consumer. Returns nil."
