killme2008 / clj-rate-limiter

Rate limiter for clojure that supports a rolling window, either in-memory or backed by redis
Eclipse Public License 1.0
23 stars 5 forks source link

"nth not supported on this type" Exception #6

Open TomerG2 opened 10 months ago

TomerG2 commented 10 months ago

Trying to use this library and I'm getting the following exception: nth not supported on this type (This only occurs when using redis)

Here's my code:

(ns app.clj_rate_limit_example
  (:require
    [clj-rate-limiter.core :as r]))

(def redis {:pool {}
            :spec {:uri "redis://:*****@localhost:6379"}})

(def limiter (r/create
               (r/rate-limiter-factory :redis
                                       :redis redis
                                       :namespace "APIs"
                                       :interval 1000
                                       :max-in-interval 100)))

(def limiter-mem (r/create
                   (r/rate-limiter-factory :memory
                                           :interval 1000
                                           :max-in-interval 100)))

(defn -main []
  (println "Check rate limit: Mem")
  (println (r/allow? limiter-mem "key1"))
  (println "Done - check rate limit: Mem")

  (println "Check rate limit: Redis")
  (println (r/permit? limiter "key1"))
  (println "Done - check rate limit: Redis"))

This is the output:

Check rate limit: Mem
true
Done - check rate limit: Mem
Check rate limit: Redis
Execution error (UnsupportedOperationException) at clj-rate-limiter.core/match-exec-ret (core.clj:145).
nth not supported on this type: ExceptionInfo

I'd appreciate any pointers/help!

TomerG2 commented 10 months ago

Update: