Skip to content

Commit 2dc16f4

Browse files
authored
Merge pull request #295 from APIParkLab/feature/1.7-liujian
Fix: Issue where API portal's service list fails to retrieve when Influxdb is not initialized
2 parents 6892fa3 + b68496a commit 2dc16f4

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

module/application-authorization/iml.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,13 @@ func (i *imlAuthorizationModule) initGateway(ctx context.Context, partitionId st
200200
}
201201

202202
func (i *imlAuthorizationModule) online(ctx context.Context, s *service.Service) error {
203-
204203
clusters, err := i.clusterService.List(ctx)
205204
if err != nil {
206205
return err
207206
}
207+
if len(clusters) < 1 {
208+
return nil
209+
}
208210
authorizations, err := i.authorizationService.ListByApp(ctx, s.Id)
209211
if err != nil {
210212
return err

module/catalogue/iml.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,16 @@ func (i *imlCatalogueModule) genCommonWheres(ctx context.Context, clusterIds ...
181181
}
182182

183183
func (i *imlCatalogueModule) ProviderStatistics(ctx context.Context, start, end time.Time, serviceIds ...string) (map[string]int64, error) {
184+
// 判断是否配置influxdb
184185
clusterId := cluster.DefaultClusterID
185-
_, err := i.clusterService.Get(ctx, clusterId)
186+
_, err := i.monitorService.Get(ctx, clusterId)
187+
if err != nil {
188+
if errors.Is(err, gorm.ErrRecordNotFound) {
189+
return make(map[string]int64), nil
190+
}
191+
return nil, err
192+
}
193+
_, err = i.clusterService.Get(ctx, clusterId)
186194
if err != nil {
187195
return nil, err
188196
}

module/mcp/iml.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"net/http"
1010
"net/url"
11+
"strconv"
1112
"strings"
1213
"time"
1314

@@ -268,6 +269,8 @@ func (i *imlMcpModule) Invoke(ctx context.Context, req mcp.CallToolRequest) (*mc
268269
for _, value := range v {
269270
queryParam.Add(k, value)
270271
}
272+
case float64:
273+
queryParam.Add(k, strconv.FormatFloat(v, 'e', -1, 64))
271274
default:
272275
return nil, fmt.Errorf("invalid query param type: %T", v)
273276
}

0 commit comments

Comments
 (0)