Skip to content

Commit 9308d58

Browse files
committed
fix http client
1 parent 774a388 commit 9308d58

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

cluster/cluster.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"context"
2424
"errors"
2525
"fmt"
26-
"net/http"
2726
"regexp"
2827
"runtime"
2928
"strings"
@@ -61,8 +60,7 @@ type Cluster struct {
6160
status atomic.Int32
6261
socketStatus atomic.Int32
6362
socket *socket.Socket
64-
client *http.Client
65-
cachedCli *http.Client
63+
client *HTTPClient
6664

6765
authTokenMux sync.RWMutex
6866
authToken *ClusterToken
@@ -73,6 +71,7 @@ func NewCluster(
7371
name string, opts config.ClusterOptions, gcfg config.ClusterGeneralConfig,
7472
storageManager *storage.Manager,
7573
statManager *StatManager,
74+
client *HTTPClient,
7675
) (cr *Cluster) {
7776
storages := make([]int, len(opts.Storages))
7877
for i, name := range opts.Storages {
@@ -85,6 +84,7 @@ func NewCluster(
8584
storageManager: storageManager,
8685
storages: storages,
8786
statManager: statManager,
87+
client: client,
8888
}
8989
return
9090
}

cluster/requests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (cr *Cluster) GetConfig(ctx context.Context) (cfg *OpenbmclapiAgentConfig,
209209
if err != nil {
210210
return
211211
}
212-
res, err := cr.cachedCli.Do(req)
212+
res, err := cr.client.DoUseCache(req)
213213
if err != nil {
214214
return
215215
}

cluster/storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (cr *Cluster) GetFileList(ctx context.Context, fileMap map[string]*StorageF
101101
if err != nil {
102102
return err
103103
}
104-
res, err := cr.cachedCli.Do(req)
104+
res, err := cr.client.DoUseCache(req)
105105
if err != nil {
106106
return err
107107
}

config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func migrateConfig(data []byte, cfg *config.Config) {
5656
if v, ok := oldConfig["keepalive-timeout"].(int); ok {
5757
cfg.Advanced.KeepaliveTimeout = v
5858
}
59-
if oldConfig["clusters"].(map[string]any) == nil {
59+
if oldConfig["clusters"] == nil {
6060
id, ok1 := oldConfig["cluster-id"].(string)
6161
secret, ok2 := oldConfig["cluster-secret"].(string)
6262
publicHost, ok3 := oldConfig["public-host"].(string)

runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (r *Runner) InitClusters(ctx context.Context) {
225225
r.clusters = make(map[string]*cluster.Cluster)
226226
gcfg := r.GetClusterGeneralConfig()
227227
for name, opts := range r.Config.Clusters {
228-
cr := cluster.NewCluster(name, opts, gcfg, r.storageManager, r.statManager)
228+
cr := cluster.NewCluster(name, opts, gcfg, r.storageManager, r.statManager, r.client)
229229
if err := cr.Init(ctx); err != nil {
230230
log.TrErrorf("error.init.failed", err)
231231
} else {

0 commit comments

Comments
 (0)