|
@@ -35,6 +35,15 @@ var (
|
|
|
DefaultMaxRedirects = 10
|
|
DefaultMaxRedirects = 10
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+type ClientConfig struct {
|
|
|
|
|
+ Endpoints []string
|
|
|
|
|
+ Transport CancelableTransport
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func New(cfg ClientConfig) (SyncableHTTPClient, error) {
|
|
|
|
|
+ return newHTTPClusterClient(cfg.Transport, cfg.Endpoints)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
type SyncableHTTPClient interface {
|
|
type SyncableHTTPClient interface {
|
|
|
HTTPClient
|
|
HTTPClient
|
|
|
Sync(context.Context) error
|
|
Sync(context.Context) error
|
|
@@ -57,10 +66,6 @@ type CancelableTransport interface {
|
|
|
CancelRequest(req *http.Request)
|
|
CancelRequest(req *http.Request)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func NewHTTPClient(tr CancelableTransport, eps []string) (SyncableHTTPClient, error) {
|
|
|
|
|
- return newHTTPClusterClient(tr, eps)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
func newHTTPClusterClient(tr CancelableTransport, eps []string) (*httpClusterClient, error) {
|
|
func newHTTPClusterClient(tr CancelableTransport, eps []string) (*httpClusterClient, error) {
|
|
|
c := httpClusterClient{
|
|
c := httpClusterClient{
|
|
|
transport: tr,
|
|
transport: tr,
|