MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / ProviderStatistics

Method ProviderStatistics

module/catalogue/iml.go:186–223  ·  view source on GitHub ↗
(ctx context.Context, start, end time.Time, serviceIds ...string)

Source from the content-addressed store, hash-verified

184}
185
186func (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
225func (i *imlCatalogueModule) Subscribe(ctx context.Context, subscribeInfo *catalogue_dto.SubscribeService) error {
226 if len(subscribeInfo.Applications) == 0 {

Callers 2

ServiceDetailMethod · 0.95
ServicesMethod · 0.95

Calls 3

genCommonWheresMethod · 0.95
statisticsMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected