Skip to content

Commit 25a7d66

Browse files
fix project structure
1 parent aaf2323 commit 25a7d66

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

http-client.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
package ehttpclient
22

33
import (
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)

internal/cb/http-cb-client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"sync"
77
"time"
88

9-
"github.com/RassulYunussov/ehttpclient/common"
9+
"github.com/RassulYunussov/ehttpclient/internal/common"
1010
)
1111

1212
type circuitBreakerBackedHttpClient struct {

common/interface.go renamed to internal/common/interface.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ package common
22

33
import "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
96
type 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)

internal/noop/http-noop-client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55
"time"
66

7-
"github.com/RassulYunussov/ehttpclient/common"
7+
"github.com/RassulYunussov/ehttpclient/internal/common"
88
)
99

1010
type noOpHttpClient struct {

internal/resilient/http-resilient-client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
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

0 commit comments

Comments
 (0)