Skip to content

Commit

Permalink
fix http client
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Aug 17, 2024
1 parent 774a388 commit 9308d58
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"context"
"errors"
"fmt"
"net/http"
"regexp"
"runtime"
"strings"
Expand Down Expand Up @@ -61,8 +60,7 @@ type Cluster struct {
status atomic.Int32
socketStatus atomic.Int32
socket *socket.Socket
client *http.Client
cachedCli *http.Client
client *HTTPClient

authTokenMux sync.RWMutex
authToken *ClusterToken
Expand All @@ -73,6 +71,7 @@ func NewCluster(
name string, opts config.ClusterOptions, gcfg config.ClusterGeneralConfig,
storageManager *storage.Manager,
statManager *StatManager,
client *HTTPClient,
) (cr *Cluster) {
storages := make([]int, len(opts.Storages))
for i, name := range opts.Storages {
Expand All @@ -85,6 +84,7 @@ func NewCluster(
storageManager: storageManager,
storages: storages,
statManager: statManager,
client: client,
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (cr *Cluster) GetConfig(ctx context.Context) (cfg *OpenbmclapiAgentConfig,
if err != nil {
return
}
res, err := cr.cachedCli.Do(req)
res, err := cr.client.DoUseCache(req)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (cr *Cluster) GetFileList(ctx context.Context, fileMap map[string]*StorageF
if err != nil {
return err
}
res, err := cr.cachedCli.Do(req)
res, err := cr.client.DoUseCache(req)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func migrateConfig(data []byte, cfg *config.Config) {
if v, ok := oldConfig["keepalive-timeout"].(int); ok {
cfg.Advanced.KeepaliveTimeout = v
}
if oldConfig["clusters"].(map[string]any) == nil {
if oldConfig["clusters"] == nil {
id, ok1 := oldConfig["cluster-id"].(string)
secret, ok2 := oldConfig["cluster-secret"].(string)
publicHost, ok3 := oldConfig["public-host"].(string)
Expand Down
2 changes: 1 addition & 1 deletion runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (r *Runner) InitClusters(ctx context.Context) {
r.clusters = make(map[string]*cluster.Cluster)
gcfg := r.GetClusterGeneralConfig()
for name, opts := range r.Config.Clusters {
cr := cluster.NewCluster(name, opts, gcfg, r.storageManager, r.statManager)
cr := cluster.NewCluster(name, opts, gcfg, r.storageManager, r.statManager, r.client)
if err := cr.Init(ctx); err != nil {
log.TrErrorf("error.init.failed", err)
} else {
Expand Down

0 comments on commit 9308d58

Please sign in to comment.