ProcessHookTask processes a hook execution task from the queue. It unmarshals the task payload, creates a context with timeout based on hook configuration, and executes the hook. Parameters: - ctx: The context for the operation. - task: The Asynq task containing the hook execution details. Returns
(ctx context.Context, task *asynq.Task)
| 37 | // Returns: |
| 38 | // - error: An error if hook execution fails. |
| 39 | func (m *redisHookManager) ProcessHookTask(ctx context.Context, task *asynq.Task) error { |
| 40 | var taskPayload HookTaskPayload |
| 41 | if err := json.Unmarshal(task.Payload(), &taskPayload); err != nil { |
| 42 | return fmt.Errorf("failed to unmarshal hook task payload: %w", err) |
| 43 | } |
| 44 | |
| 45 | // Add timeout to context based on hook configuration |
| 46 | hookCtx, cancel := context.WithTimeout(ctx, time.Duration(taskPayload.Hook.Timeout)*time.Second) |
| 47 | defer cancel() |
| 48 | |
| 49 | logrus.WithFields(logrus.Fields{ |
| 50 | "hook_id": taskPayload.Hook.ID, |
| 51 | "hook_type": taskPayload.Hook.Type, |
| 52 | }).Info("Processing queued hook task") |
| 53 | |
| 54 | return m.executeHook(hookCtx, taskPayload.Hook, taskPayload.Payload) |
| 55 | } |
nothing calls this directly
no test coverage detected