mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-05 16:06:55 +08:00
feat: update
This commit is contained in:
@@ -21,12 +21,12 @@ func (h *FormatHandler) ProcessTask(ctx context.Context, task *mq.Task) mq.Resul
|
||||
var data map[string]any
|
||||
err := json.Unmarshal(task.Payload, &data)
|
||||
if err != nil {
|
||||
return mq.Result{Error: fmt.Errorf("failed to unmarshal task payload: %w", err)}
|
||||
return mq.Result{Error: fmt.Errorf("failed to unmarshal task payload: %w", err), Ctx: ctx}
|
||||
}
|
||||
|
||||
formatType, ok := h.Payload.Data["format_type"].(string)
|
||||
if !ok {
|
||||
return mq.Result{Error: fmt.Errorf("format_type not specified")}
|
||||
return mq.Result{Error: fmt.Errorf("format_type not specified"), Ctx: ctx}
|
||||
}
|
||||
|
||||
var result map[string]any
|
||||
@@ -48,12 +48,12 @@ func (h *FormatHandler) ProcessTask(ctx context.Context, task *mq.Task) mq.Resul
|
||||
case "trim":
|
||||
result = h.formatTrim(data)
|
||||
default:
|
||||
return mq.Result{Error: fmt.Errorf("unsupported format_type: %s", formatType)}
|
||||
return mq.Result{Error: fmt.Errorf("unsupported format_type: %s", formatType), Ctx: ctx}
|
||||
}
|
||||
|
||||
resultPayload, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
return mq.Result{Error: fmt.Errorf("failed to marshal result: %w", err)}
|
||||
return mq.Result{Error: fmt.Errorf("failed to marshal result: %w", err), Ctx: ctx}
|
||||
}
|
||||
|
||||
return mq.Result{Payload: resultPayload, Ctx: ctx}
|
||||
|
Reference in New Issue
Block a user