(ctx context.Context, start, end time.Time, serviceIds ...string)
| 184 | } |
| 185 | |
| 186 | func (i *imlCatalogueModule) ProviderStatistics(ctx context.Context, start, end time.Time, serviceIds ...string) (map[string]int64, error) { |
| 187 | // 判断是否配置influxdb |
| 188 | clusterId := cluster.DefaultClusterID |
| 189 | _, err := i.monitorService.Get(ctx, clusterId) |
| 190 | if err != nil { |
| 191 | if errors.Is(err, gorm.ErrRecordNotFound) { |
| 192 | return make(map[string]int64), nil |
| 193 | } |
| 194 | return nil, err |
| 195 | } |
| 196 | _, err = i.clusterService.Get(ctx, clusterId) |
| 197 | if err != nil { |
| 198 | return nil, err |
| 199 | } |
| 200 | |
| 201 | wheres, err := i.genCommonWheres(ctx, clusterId) |
| 202 | if err != nil { |
| 203 | return nil, err |
| 204 | } |
| 205 | |
| 206 | if len(serviceIds) > 0 { |
| 207 | wheres = append(wheres, monitor.MonWhereItem{ |
| 208 | Key: "provider", |
| 209 | Operation: "in", |
| 210 | Values: serviceIds, |
| 211 | }) |
| 212 | } |
| 213 | statisticMap, err := i.statistics(ctx, clusterId, "provider", start, end, wheres, 0) |
| 214 | if err != nil { |
| 215 | return nil, err |
| 216 | } |
| 217 | resultMap := make(map[string]int64) |
| 218 | for key, item := range statisticMap { |
| 219 | resultMap[key] = item.RequestTotal |
| 220 | } |
| 221 | |
| 222 | return resultMap, nil |
| 223 | } |
| 224 | |
| 225 | func (i *imlCatalogueModule) Subscribe(ctx context.Context, subscribeInfo *catalogue_dto.SubscribeService) error { |
| 226 | if len(subscribeInfo.Applications) == 0 { |
no test coverage detected