You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository serves as a **Default Template Repository** according official [GitHub Contributing Guidelines][ProjectSetup] for healthy contributions. It brings you clean default Templates for several areas:
This Go module offers a sophisticated HTTP client designed for seamless API interactions, with a strong emphasis on concurrency management, robust error handling, extensive logging, and adaptive rate limiting. It's particularly suitable for applications requiring high-throughput API interactions with complex authentication and operational resilience.
4
+
5
+
This client leverages API-specific SDKs to provide a comprehensive and consistent interface for interacting with various APIs, including Microsoft Graph, Jamf Pro, and others. It is designed to be easily extensible to support additional APIs and to be highly configurable to meet specific API requirements. It achieves this through using a modular design, with a core HTTP client and API-specific handlers that encapsulate the unique requirements of each API supported.
6
+
7
+
## Features
8
+
9
+
-**Comprehensive Authentication Support**: Robust support for various authentication schemes, including OAuth and Bearer Token, with built-in token management and validation.
10
+
-**Advanced Concurrency Management**: An intelligent Concurrency Manager dynamically adjusts concurrent request limits to optimize throughput and adhere to API rate limits.
11
+
-**Structured Error Handling**: Clear and actionable error reporting facilitates troubleshooting and improves reliability.
12
+
-**Performance Monitoring**: Detailed performance metrics tracking provides insights into API interaction efficiency and optimization opportunities.
13
+
-**Configurable Logging**: Extensive logging capabilities with customizable levels and formats aid in debugging and operational monitoring.
14
+
-**Adaptive Rate Limiting**: Dynamic rate limiting automatically adjusts request rates in response to API server feedback.
15
+
-**Flexible Configuration**: Extensive customization of HTTP client behavior to meet specific API requirements, including custom timeouts, retry strategies, header management, and more.
16
+
-**Header Management**: Easy and efficient management of HTTP request headers, ensuring compliance with API requirements.
17
+
-**Enhanced Logging with Zap**: Utilizes Uber's zap library for structured, high-performance logging, offering levels from Debug to Fatal, including structured context and dynamic adjustment based on the environment.
18
+
-**API Handler Interface**: Provides a flexible and extensible way to interact with different APIs, including encoding and decoding requests and responses, managing authentication endpoints, and handling API-specific logic.
19
+
20
+
## API Handler
21
+
22
+
The `APIHandler` interface abstracts the functionality needed to interact with various APIs, making the HTTP client adaptable to different API implementations. It includes methods for constructing resource and authentication endpoints, marshaling requests, handling responses, and managing API-specific headers.
23
+
24
+
### Implementations
25
+
26
+
Currently, the HTTP client supports the following API handlers:
27
+
28
+
-**Jamf Pro**: Tailored for interacting with Jamf Pro's API, providing specialized methods for device management and configuration.
29
+
-**Microsoft Graph**: Designed for Microsoft Graph API, enabling access to various Microsoft 365 services.
30
+
31
+
## Getting Started
32
+
33
+
### Installation
34
+
35
+
To use this HTTP client in your project, add the package to your Go module dependencies:
You can [generate](https://github.com/segraef/Template/generate) a new repository with the same directory structure and files as an existing repository. More details can be found [here][CreateFromTemplate].
35
116
36
117
## Reporting Issues and Feedback
37
118
@@ -43,7 +124,7 @@ If you are taking the time to mention a problem, even a seemingly minor one, it
43
124
44
125
## Feedback
45
126
46
-
If there is a feature you would like to see in here, please file an issue or feature request in the [GitHub Issues][GitHubIssues] page to provide direct feedback.
127
+
Contributions are welcome to make this HTTP client even better! Feel free to fork the repository, make your improvements, and submit a pull request. For major changes or new features, please file an issue or feature request in the [GitHub Issues][GitHubIssues] page to discuss what you would like to change.
Copy file name to clipboardExpand all lines: httpclient/httpclient_rate_handler.go
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,16 @@
3
3
/*
4
4
Components:
5
5
6
-
Backoff Strategy: A function that calculates the delay before the next retry. It will implement exponential backoff with jitter. This strategy is more effective than a fixed delay, as it ensures that in cases of prolonged issues, the client won't keep hammering the server with a high frequency.
7
-
Response Time Monitoring: We'll introduce a mechanism to track average response times and use deviations from this average to inform our backoff strategy.
8
-
Error Classifier: A function to classify different types of errors. Only transient errors should be retried.
9
-
Rate Limit Header Parser: For future compatibility, a function that can parse common rate limit headers (like X-RateLimit-Remaining and Retry-After) and adjust behavior accordingly.
6
+
Backoff Strategy: A function that calculates the delay before the next retry. It will
7
+
implement exponential backoff with jitter. This strategy is more effective than a fixed
8
+
delay, as it ensures that in cases of prolonged issues, the client won't keep hammering
9
+
the server with a high frequency.
10
+
Response Time Monitoring: We'll introduce a mechanism to track average response times and
11
+
use deviations from this average to inform our backoff strategy.
12
+
Error Classifier: A function to classify different types of errors. Only transient errors
13
+
should be retried.Rate Limit Header Parser: For future compatibility, a function that can
14
+
parse common rate limit headers (like X-RateLimit-Remaining and Retry-After) and adjust
0 commit comments