Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add poll-interval to metadata. (From "X-Poll-Interval" events header.) #35

Merged
merged 1 commit into from

2 participants

@tjg

From the Events section of GitHub's API:

There is also an “X-Poll-Interval” header that specifies how often (in seconds) you are allowed to poll. In times of high server load, the time may increase. Please obey the header.

@Raynes Raynes merged commit e4defc0 into Raynes:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 2 deletions.
  1. +5 −2 src/tentacles/core.clj
  2. +6 −0 test/tentacles/core_test.clj
View
7 src/tentacles/core.clj
@@ -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]
View
6 test/tentacles/core_test.clj
@@ -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" ""}}))))))
Something went wrong with that request. Please try again.