Skip to content

Commit 517610e

Browse files
committed
make fmt
1 parent c19a4b1 commit 517610e

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

mcp-server/pkg/formatter/formatter.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ func NewPrometheusDataFormatter(timezone string) *PrometheusDataFormatter {
2424

2525
// FormattedTimeData 格式化后的时间数据结构
2626
type FormattedTimeData struct {
27-
Timestamp string `json:"timestamp"` // 格式化的时间戳
28-
TimestampUnix float64 `json:"timestamp_unix"` // 原始Unix时间戳
29-
Value interface{} `json:"value"` // 数据值
30-
Metric map[string]string `json:"metric"` // 指标标签
31-
Metadata map[string]interface{} `json:"metadata"` // 元数据信息
27+
Timestamp string `json:"timestamp"` // 格式化的时间戳
28+
TimestampUnix float64 `json:"timestamp_unix"` // 原始Unix时间戳
29+
Value any `json:"value"` // 数据值
30+
Metric map[string]string `json:"metric"` // 指标标签
31+
Metadata map[string]any `json:"metadata"` // 元数据信息
3232
}
3333

3434
// PrometheusResponse Prometheus查询响应结构
3535
type PrometheusResponse struct {
3636
Status string `json:"status"`
3737
Data struct {
38-
ResultType string `json:"resultType"`
39-
Result []interface{} `json:"result"`
38+
ResultType string `json:"resultType"`
39+
Result []any `json:"result"`
4040
} `json:"data"`
4141
}
4242

@@ -82,7 +82,7 @@ func (f *PrometheusDataFormatter) FormatPrometheusData(rawData string, includeMe
8282
var response PrometheusResponse
8383
if err := json.Unmarshal([]byte(rawData), &response); err != nil {
8484
// 如果标准格式解析失败,尝试解析为数组格式(兼容旧版本)
85-
var arrayResult []interface{}
85+
var arrayResult []any
8686
if arrayErr := json.Unmarshal([]byte(rawData), &arrayResult); arrayErr != nil {
8787
return "", fmt.Errorf("解析Prometheus响应失败: %w", err)
8888
}
@@ -118,7 +118,7 @@ func (f *PrometheusDataFormatter) FormatPrometheusData(rawData string, includeMe
118118
}
119119

120120
// 创建最终的响应结构
121-
finalResponse := map[string]interface{}{
121+
finalResponse := map[string]any{
122122
"status": "success",
123123
"result_type": response.Data.ResultType,
124124
"result_count": len(formattedResults),
@@ -137,17 +137,17 @@ func (f *PrometheusDataFormatter) FormatPrometheusData(rawData string, includeMe
137137
}
138138

139139
// formatVectorResult 格式化瞬时向量查询结果
140-
func (f *PrometheusDataFormatter) formatVectorResult(results []interface{}, includeMetadata bool) []FormattedTimeData {
140+
func (f *PrometheusDataFormatter) formatVectorResult(results []any, includeMetadata bool) []FormattedTimeData {
141141
var formattedResults []FormattedTimeData
142142

143143
for _, result := range results {
144-
if resultMap, ok := result.(map[string]interface{}); ok {
144+
if resultMap, ok := result.(map[string]any); ok {
145145
formattedData := FormattedTimeData{
146146
Metric: make(map[string]string),
147147
}
148148

149149
// 处理指标标签
150-
if metric, ok := resultMap["metric"].(map[string]interface{}); ok {
150+
if metric, ok := resultMap["metric"].(map[string]any); ok {
151151
for key, value := range metric {
152152
if strValue, ok := value.(string); ok {
153153
formattedData.Metric[key] = strValue
@@ -156,7 +156,7 @@ func (f *PrometheusDataFormatter) formatVectorResult(results []interface{}, incl
156156
}
157157

158158
// 处理值
159-
if value, ok := resultMap["value"].([]interface{}); ok && len(value) >= 2 {
159+
if value, ok := resultMap["value"].([]any); ok && len(value) >= 2 {
160160
if timestamp, ok := value[0].(float64); ok {
161161
// 格式化时间戳
162162
formattedTime, err := f.FormatTimestampWithTimezone(timestamp, "")
@@ -172,7 +172,7 @@ func (f *PrometheusDataFormatter) formatVectorResult(results []interface{}, incl
172172

173173
// 添加元数据(可选)
174174
if includeMetadata {
175-
formattedData.Metadata = map[string]interface{}{
175+
formattedData.Metadata = map[string]any{
176176
"result_type": "vector",
177177
"processed_at": time.Now().Format("2006-01-02T15:04:05-07:00"),
178178
}
@@ -186,14 +186,14 @@ func (f *PrometheusDataFormatter) formatVectorResult(results []interface{}, incl
186186
}
187187

188188
// formatMatrixResult 格式化范围向量查询结果
189-
func (f *PrometheusDataFormatter) formatMatrixResult(results []interface{}, includeMetadata bool) []FormattedTimeData {
189+
func (f *PrometheusDataFormatter) formatMatrixResult(results []any, includeMetadata bool) []FormattedTimeData {
190190
var formattedResults []FormattedTimeData
191191

192192
for _, result := range results {
193-
if resultMap, ok := result.(map[string]interface{}); ok {
193+
if resultMap, ok := result.(map[string]any); ok {
194194
// 处理指标标签
195195
metric := make(map[string]string)
196-
if metricData, ok := resultMap["metric"].(map[string]interface{}); ok {
196+
if metricData, ok := resultMap["metric"].(map[string]any); ok {
197197
for key, value := range metricData {
198198
if strValue, ok := value.(string); ok {
199199
metric[key] = strValue
@@ -202,9 +202,9 @@ func (f *PrometheusDataFormatter) formatMatrixResult(results []interface{}, incl
202202
}
203203

204204
// 处理时间序列数据
205-
if values, ok := resultMap["values"].([]interface{}); ok {
205+
if values, ok := resultMap["values"].([]any); ok {
206206
for _, valuePoint := range values {
207-
if point, ok := valuePoint.([]interface{}); ok && len(point) >= 2 {
207+
if point, ok := valuePoint.([]any); ok && len(point) >= 2 {
208208
formattedData := FormattedTimeData{
209209
Metric: metric,
210210
}
@@ -223,7 +223,7 @@ func (f *PrometheusDataFormatter) formatMatrixResult(results []interface{}, incl
223223

224224
// 添加元数据(可选)
225225
if includeMetadata {
226-
formattedData.Metadata = map[string]interface{}{
226+
formattedData.Metadata = map[string]any{
227227
"result_type": "matrix",
228228
"processed_at": time.Now().Format("2006-01-02T15:04:05-07:00"),
229229
}
@@ -240,11 +240,11 @@ func (f *PrometheusDataFormatter) formatMatrixResult(results []interface{}, incl
240240
}
241241

242242
// formatScalarResult 格式化标量查询结果
243-
func (f *PrometheusDataFormatter) formatScalarResult(results []interface{}, includeMetadata bool) []FormattedTimeData {
243+
func (f *PrometheusDataFormatter) formatScalarResult(results []any, includeMetadata bool) []FormattedTimeData {
244244
var formattedResults []FormattedTimeData
245245

246246
if len(results) > 0 {
247-
if scalar, ok := results[0].([]interface{}); ok && len(scalar) >= 2 {
247+
if scalar, ok := results[0].([]any); ok && len(scalar) >= 2 {
248248
formattedData := FormattedTimeData{
249249
Metric: make(map[string]string),
250250
}
@@ -263,7 +263,7 @@ func (f *PrometheusDataFormatter) formatScalarResult(results []interface{}, incl
263263

264264
// 添加元数据(可选)
265265
if includeMetadata {
266-
formattedData.Metadata = map[string]interface{}{
266+
formattedData.Metadata = map[string]any{
267267
"result_type": "scalar",
268268
"processed_at": time.Now().Format("2006-01-02T15:04:05-07:00"),
269269
}

mcp-server/pkg/models/models.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import (
66

77
// StepResult 定义通用步骤结果结构
88
type StepResult struct {
9-
StepName string `json:"step_name"`
10-
Status string `json:"status"` // success / failed / warning
11-
Summary string `json:"summary"`
12-
Details map[string]interface{} `json:"details"`
13-
Timestamp string `json:"timestamp"`
9+
StepName string `json:"step_name"`
10+
Status string `json:"status"` // success / failed / warning
11+
Summary string `json:"summary"`
12+
Details map[string]any `json:"details"`
13+
Timestamp string `json:"timestamp"`
1414
}
1515

1616
// NewStepResult 工具函数:创建成功结果
17-
func NewStepResult(step string, summary string, details map[string]interface{}) StepResult {
17+
func NewStepResult(step string, summary string, details map[string]any) StepResult {
1818
return StepResult{
1919
StepName: step,
2020
Status: "success",

mock/s3/services/metadata/internal/repository/postgres.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (r *PostgreSQLRepository) Delete(ctx context.Context, bucket, key string) e
148148
// List 列出元数据
149149
func (r *PostgreSQLRepository) List(ctx context.Context, bucket, prefix string, limit, offset int) ([]*models.Metadata, error) {
150150
var query string
151-
var args []interface{}
151+
var args []any
152152

153153
if prefix != "" {
154154
query = `
@@ -158,7 +158,7 @@ func (r *PostgreSQLRepository) List(ctx context.Context, bucket, prefix string,
158158
ORDER BY key
159159
LIMIT $3 OFFSET $4
160160
`
161-
args = []interface{}{bucket, prefix + "%", limit, offset}
161+
args = []any{bucket, prefix + "%", limit, offset}
162162
} else {
163163
query = `
164164
SELECT bucket, key, size, content_type, md5_hash, status, created_at
@@ -167,7 +167,7 @@ func (r *PostgreSQLRepository) List(ctx context.Context, bucket, prefix string,
167167
ORDER BY key
168168
LIMIT $2 OFFSET $3
169169
`
170-
args = []interface{}{bucket, limit, offset}
170+
args = []any{bucket, limit, offset}
171171
}
172172

173173
rows, err := r.db.QueryContext(ctx, query, args...)

mock/s3/services/queue/internal/repository/redis_queue.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (r *RedisQueueRepository) EnqueueDeleteTask(ctx context.Context, task *mode
5959

6060
// 同时存储到哈希表中用于状态查询和更新
6161
taskKey := fmt.Sprintf("task:delete:%s", task.ID)
62-
if err := r.client.HSet(ctx, taskKey, map[string]interface{}{
62+
if err := r.client.HSet(ctx, taskKey, map[string]any{
6363
"data": data,
6464
"status": task.Status,
6565
"created_at": task.CreatedAt.Unix(),
@@ -105,7 +105,7 @@ func (r *RedisQueueRepository) DequeueDeleteTask(ctx context.Context, timeout ti
105105
func (r *RedisQueueRepository) UpdateDeleteTaskStatus(ctx context.Context, taskID string, status models.TaskStatus, errorMsg string) error {
106106
taskKey := fmt.Sprintf("task:delete:%s", taskID)
107107

108-
fields := map[string]interface{}{
108+
fields := map[string]any{
109109
"status": status,
110110
"updated_at": time.Now().Unix(),
111111
}
@@ -143,7 +143,7 @@ func (r *RedisQueueRepository) EnqueueSaveTask(ctx context.Context, task *models
143143

144144
// 同时存储到哈希表中用于状态查询和更新
145145
taskKey := fmt.Sprintf("task:save:%s", task.ID)
146-
if err := r.client.HSet(ctx, taskKey, map[string]interface{}{
146+
if err := r.client.HSet(ctx, taskKey, map[string]any{
147147
"data": data,
148148
"status": task.Status,
149149
"created_at": task.CreatedAt.Unix(),
@@ -189,7 +189,7 @@ func (r *RedisQueueRepository) DequeueSaveTask(ctx context.Context, timeout time
189189
func (r *RedisQueueRepository) UpdateSaveTaskStatus(ctx context.Context, taskID string, status models.TaskStatus, errorMsg string) error {
190190
taskKey := fmt.Sprintf("task:save:%s", taskID)
191191

192-
fields := map[string]interface{}{
192+
fields := map[string]any{
193193
"status": status,
194194
"updated_at": time.Now().Unix(),
195195
}

mock/s3/shared/server/service_bootstrap.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ func (sb *ServiceBootstrap) deregisterFromConsul() {
379379
} else {
380380
registerAddress = sb.Config.GetHost()
381381
}
382-
383-
serviceID := fmt.Sprintf("%s-%s-%d",
384-
sb.Config.GetServiceName(),
385-
registerAddress,
382+
383+
serviceID := fmt.Sprintf("%s-%s-%d",
384+
sb.Config.GetServiceName(),
385+
registerAddress,
386386
sb.Config.GetPort())
387387

388388
if err := sb.ConsulClient.DeregisterService(ctx, serviceID); err != nil {

0 commit comments

Comments
 (0)