-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.go
More file actions
25 lines (18 loc) · 876 Bytes
/
interface.go
File metadata and controls
25 lines (18 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package goqueue
import "context"
// Backend defines the interface that all queue backends must implement.
// This allows easy swapping between different queue implementations
// (e.g., Redis, RabbitMQ, in-memory, etc.)
type Backend interface {
// Publish sends a message envelope to the specified queue
Publish(ctx context.Context, queue string, envelope *Envelope) error
// Subscribe creates a subscription to the specified queue and returns
// a channel that will receive message envelopes
Subscribe(ctx context.Context, queue string) (<-chan *Envelope, error)
// Ack acknowledges successful processing of a message
Ack(ctx context.Context, messageID string) error
// Nack indicates that a message failed to process and should be retried
Nack(ctx context.Context, messageID string) error
// Close releases any resources held by the backend
Close() error
}