Skip to content

Commit f01b0c7

Browse files
authored
🎉 Source Github: add handling the secondary rate limits (#10193)
* Source Github: add handling the secondary rate limits
1 parent 2573fa1 commit f01b0c7

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
- name: GitHub
239239
sourceDefinitionId: ef69ef6e-aa7f-4af1-a01d-ef775033524e
240240
dockerRepository: airbyte/source-github
241-
dockerImageTag: 0.2.17
241+
dockerImageTag: 0.2.18
242242
documentationUrl: https://docs.airbyte.io/integrations/sources/github
243243
icon: github.svg
244244
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,7 @@
21442144
supportsNormalization: false
21452145
supportsDBT: false
21462146
supported_destination_sync_modes: []
2147-
- dockerImage: "airbyte/source-github:0.2.17"
2147+
- dockerImage: "airbyte/source-github:0.2.18"
21482148
spec:
21492149
documentationUrl: "https://docs.airbyte.io/integrations/sources/github"
21502150
connectionSpecification:

airbyte-integrations/connectors/source-github/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.2.17
15+
LABEL io.airbyte.version=0.2.18
1616
LABEL io.airbyte.name=airbyte/source-github

airbyte-integrations/connectors/source-github/source_github/streams.py

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import time
66
from abc import ABC, abstractmethod
77
from copy import deepcopy
8+
from time import sleep
89
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Union
910
from urllib import parse
1011

@@ -65,6 +66,13 @@ def should_retry(self, response: requests.Response) -> bool:
6566
self.logger.info(
6667
f"Rate limit handling for stream `{self.name}` for the response with {response.status_code} status code with message: {response.text}"
6768
)
69+
70+
# Handling secondary rate limits for Github
71+
# Additional information here: https://docs.github.com/en/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits
72+
elif response.headers.get("Retry-After"):
73+
time_delay = int(response.headers["Retry-After"])
74+
self.logger.info(f"Handling Secondary Rate limits, setting sync delay for {time_delay} second(s)")
75+
sleep(time_delay)
6876
return retry_flag
6977

7078
def backoff_time(self, response: requests.Response) -> Union[int, float]:

docs/integrations/sources/github.md

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Your token should have at least the `repo` scope. Depending on which streams you
9292

9393
| Version | Date | Pull Request | Subject |
9494
|:--------|:-----------| :--- |:-------------------------------------------------------------------------------------------------------------|
95+
| 0.2.18 | 2021-02-09 | [10193](https://github.com/airbytehq/airbyte/pull/10193) | Add handling secondary rate limits |
9596
| 0.2.17 | 2021-02-02 | [9999](https://github.com/airbytehq/airbyte/pull/9999) | Remove BAD_GATEWAY code from backoff_time |
9697
| 0.2.16 | 2021-02-02 | [9868](https://github.com/airbytehq/airbyte/pull/9868) | Add log message for streams that are restricted for OAuth. Update oauth scopes. |
9798
| 0.2.15 | 2021-01-26 | [9802](https://github.com/airbytehq/airbyte/pull/9802) | Add missing fields for auto_merge in pull request stream |

0 commit comments

Comments
 (0)