Message Queue Consumer Worker (services/consumer_worker.go)

outpost · internal/services/consumer_worker.go · go · Apache-2.0
infra, tag:consumer, tag:mq, tag:concurrency, tag:error-handling

Wraps a message‑queue consumer with subscription management, concurrency control and graceful error handling for reliable background processing.

// Source: https://github.com/hookdeck/outpost | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package services

import (
	"context"
	"errors"

	"github.com/hookdeck/outpost/internal/consumer"
	"github.com/hookdeck/outpost/internal/logging"
	"github.com/hookdeck/outpost/internal/mqs"
	"github.com/hookdeck/outpost/internal/worker"
	"go.uber.org/zap"
)

// ConsumerWorker is a generic worker that wraps a message queue consumer.
// It handles subscription at runtime and consistent error handling for graceful shutdowns.
type ConsumerWorker struct {
	name        string
	subscribe   func(ctx context.Context, opts ...mqs.SubscribeOption) (mqs.Subscription, error)
	handler     consumer.Mes

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key