snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s
Some checks failed
master / ci (push) Failing after 0s
This commit is contained in:
32
tools/pq/cli/backend.go
Normal file
32
tools/pq/cli/backend.go
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user