Files
upstream-watermill/tools/pq/cli/backend.go
2026-09-15 21:27:46 +05:00

33 lines
663 B
Go

package cli
import (
"context"
"github.com/pkg/errors"
)
type BackendConfig struct {
Topic string
RawTopic string
}
func (c BackendConfig) Validate() error {
if c.Topic == "" && c.RawTopic == "" {
return errors.New("topic or raw topic must be provided")
}
if c.Topic != "" && c.RawTopic != "" {
return errors.New("only one of topic or raw topic must be provided")
}
return nil
}
type BackendConstructor func(ctx context.Context, cfg BackendConfig) (Backend, error)
type Backend interface {
AllMessages(ctx context.Context) ([]Message, error)
Requeue(ctx context.Context, msg Message) error
Ack(ctx context.Context, msg Message) error
}