Skip to content

Commit 7c8007e

Browse files
committed
connpass API v2 のリクエスト制限に遵守した秒数を待つ #1699
cf. https://connpass.com/about/api/v2/
1 parent 35f7b56 commit 7c8007e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/event_service/providers/connpass.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ def fetch_events(group_id:, yyyymm: nil, yyyymmdd: nil)
4040
begin
4141
args = params.merge(param_period).compact
4242
res = @client.get_events(**args)
43-
rescue ConnpassApiV2::Error => e
44-
sleep 5 && retry if e.response&.status == 403
4543

44+
# APIキーごとに、現状「1秒間に1リクエストまで」 のリクエスト制限 (スロットリング) を設けています。
45+
# この制限を超過すると、HTTPステータスコード 429 Too Many Requests が返されます。
46+
# cf. https://connpass.com/about/api/v2/#section/%E6%A6%82%E8%A6%81/%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E5%88%B6%E9%99%90
47+
sleep 1
48+
rescue ConnpassApiV2::Error => e
49+
sleep 5 && retry if e.response&.status == 429
4650
raise e
4751
end
4852

0 commit comments

Comments
 (0)