Skip to content

Commit

Permalink
Merge pull request #35 from tjg/poll-interval
Browse files Browse the repository at this point in the history
Add poll-interval to metadata. (From "X-Poll-Interval" events header.)
  • Loading branch information
Raynes committed Aug 21, 2013
2 parents b0d3567 + f64f655 commit e4defc0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/tentacles/core.clj
Expand Up @@ -33,10 +33,13 @@

(defn extract-useful-meta
[h]
(let [{:strs [etag last-modified x-ratelimit-limit x-ratelimit-remaining]} h]
(let [{:strs [etag last-modified x-ratelimit-limit x-ratelimit-remaining
x-poll-interval]}
h]
{:etag etag :last-modified last-modified
:call-limit (when x-ratelimit-limit (Long/parseLong x-ratelimit-limit))
:call-remaining (when x-ratelimit-remaining (Long/parseLong x-ratelimit-remaining))}))
:call-remaining (when x-ratelimit-remaining (Long/parseLong x-ratelimit-remaining))
:poll-interval (when x-poll-interval (Long/parseLong x-poll-interval))}))

(defn api-meta
[obj]
Expand Down
6 changes: 6 additions & 0 deletions test/tentacles/core_test.clj
Expand Up @@ -10,3 +10,9 @@
(is (= 60 (:call-limit (core/api-meta
(core/safe-parse {:status 200 :headers {"x-ratelimit-limit" "60"
"content-type" ""}}))))))

(deftest poll-limit-details-are-propagated
(is (= 61 (:poll-interval (core/api-meta
(core/safe-parse {:status 200
:headers {"x-poll-interval" "61"
"content-type" ""}}))))))

0 comments on commit e4defc0

Please sign in to comment.