feat: update

This commit is contained in:
sujit
2025-08-12 09:02:29 +05:45
parent 82c1afbc8e
commit f98cc49264
8 changed files with 66 additions and 28 deletions

View File

@@ -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}