MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / ProcessHookTask

Method ProcessHookTask

internal/hooks/worker.go:39–55  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

37// Returns:
38// - error: An error if hook execution fails.
39func (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}

Callers

nothing calls this directly

Calls 2

executeHookMethod · 0.95
InfoMethod · 0.45

Tested by

no test coverage detected