File tree Expand file tree Collapse file tree 5 files changed +17
-9
lines changed Expand file tree Collapse file tree 5 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 11package ehttpclient
22
33import (
4+ "net/http"
45 "time"
56
6- "github.com/RassulYunussov/ehttpclient/common"
77 "github.com/RassulYunussov/ehttpclient/internal/cb"
88 "github.com/RassulYunussov/ehttpclient/internal/noop"
99 "github.com/RassulYunussov/ehttpclient/internal/resilient"
1010)
1111
12+ // Enhanced HttpClient backed by resiliency patterns.
13+ // Includes: retry & circuit breaker policies.
14+ // Retriable errors: http-5xx, network errors
15+ // Non-retriable errors: context.DeadlineExceeded|context.Canceled|gobreaker.ErrOpenState|gobreaker.ErrTooManyRequests
16+ type EnhancedHttpClient interface {
17+ // method should have a semantic resource name that will be used to separate circuit breakers
18+ DoResourceRequest (resource string , r * http.Request ) (* http.Response , error )
19+ // classic HttpClient interface support, gets resource from path + method
20+ Do (r * http.Request ) (* http.Response , error )
21+ }
22+
1223// Get new instance of EnhancedHttpClient
13- func Create (timeout time.Duration , opts ... func (* enhancedHttpClientCreationParameters ) * enhancedHttpClientCreationParameters ) common. EnhancedHttpClient {
24+ func Create (timeout time.Duration , opts ... func (* enhancedHttpClientCreationParameters ) * enhancedHttpClientCreationParameters ) EnhancedHttpClient {
1425 enhancedHttpClientCreationParameters := new (enhancedHttpClientCreationParameters )
1526 for _ , o := range opts {
1627 enhancedHttpClientCreationParameters = o (enhancedHttpClientCreationParameters )
Original file line number Diff line number Diff line change 66 "sync"
77 "time"
88
9- "github.com/RassulYunussov/ehttpclient/common"
9+ "github.com/RassulYunussov/ehttpclient/internal/ common"
1010)
1111
1212type circuitBreakerBackedHttpClient struct {
Original file line number Diff line number Diff line change @@ -2,10 +2,7 @@ package common
22
33import "net/http"
44
5- // Enhanced HttpClient backed by resiliency patterns.
6- // Includes: retry & circuit breaker policies.
7- // Retriable errors: http-5xx, network errors
8- // Non-retriable errors: context.DeadlineExceeded|context.Canceled|gobreaker.ErrOpenState|gobreaker.ErrTooManyRequests
5+ // Common interface for all decorators
96type EnhancedHttpClient interface {
107 // method should have a semantic resource name that will be used to separate circuit breakers
118 DoResourceRequest (resource string , r * http.Request ) (* http.Response , error )
Original file line number Diff line number Diff line change 44 "net/http"
55 "time"
66
7- "github.com/RassulYunussov/ehttpclient/common"
7+ "github.com/RassulYunussov/ehttpclient/internal/ common"
88)
99
1010type noOpHttpClient struct {
Original file line number Diff line number Diff line change 88 "net/http"
99 "time"
1010
11- "github.com/RassulYunussov/ehttpclient/common"
11+ "github.com/RassulYunussov/ehttpclient/internal/ common"
1212 "github.com/sony/gobreaker/v2"
1313)
1414
You can’t perform that action at this time.
0 commit comments