在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:app-sre/github-mirror开源软件地址:https://github.com/app-sre/github-mirror开源编程语言:Python 98.5%开源软件介绍:GitHub MirrorGitHub API mirror that caches the responses and implements conditional requests. With conditional requests, all the calls are forwarded to the Github API, but when the GitHub API replies with a 304 HTTP code, meaning that the resource has not changed, we serve the client with the previously cached response. That reduces the number of API calls that consume quota, helping you not to hit the API GitHub API rate limit. The mirror acts only on GET requests, by-passing other HTTP methods. The default cache backend is in-memory, and we also support Redis. The in-memory cache is shared among all the threads, but not shared between processes. Every time the server is started, the cache is initialized empty. Using Redis prevents the cache from being lost when the github mirror server is restarted. Quick StartRun the Docker container:
Use it as the Github API url:
After those two requests, the server log will show:
The second request was served from the cache and it did not consume the API calls quota. If you're using PyGithub, you have to pass the
Redis Cache BackendTo enable the Redis backend, set the environment variable:
In addition to that, you can provide the following optional configuration:
You will find more details about the Redis cache backend implementation in the Redis Cache Backend doc. MetricsThe service has a
With that, as the Github API rate limit is per hour, you can have the total HIT/MISS per hour with:
and
Plotting on Grafana, we have: Many more metrics are available. Check the User ValidationTo enable the user validation, the
The user validation, when enabled, will not allow unauthenticated requests to the Github Mirror. Please notice that, in order to validate the user, one additional get request
is made to the Github API, to the Offline ModeThere's a built-in mechanism to detect when the Github API is offline. To do so, we have a separate thread that keeps checking the url
When that happens, all the requests are served from the cache until we detect that the Github API is back online. Requests served from the cache when we are in offline mode will be accounted for in separate metrics:
and
ContributingFor contributing to the project, please follow the Development Guide. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论