This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
amqp.go
85 lines (73 loc) · 2.2 KB
/
amqp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Package wabbit provides an interface for AMQP client specification and a mock
// implementation of that interface.
package wabbit
import "time"
type (
// Option is a map of AMQP configurations
Option map[string]interface{}
// Conn is the amqp connection interface
Conn interface {
Channel() (Channel, error)
AutoRedial(errChan chan Error, done chan bool)
Close() error
NotifyClose(chan Error) chan Error
}
// Channel is an AMQP channel interface
Channel interface {
Ack(tag uint64, multiple bool) error
Nack(tag uint64, multiple bool, requeue bool) error
Reject(tag uint64, requeue bool) error
Confirm(noWait bool) error
NotifyPublish(confirm chan Confirmation) chan Confirmation
Cancel(consumer string, noWait bool) error
ExchangeDeclare(name, kind string, opt Option) error
ExchangeDeclarePassive(name, kind string, opt Option) error
QueueInspect(name string) (Queue, error)
QueueDeclare(name string, args Option) (Queue, error)
QueueDeclarePassive(name string, args Option) (Queue, error)
QueueDelete(name string, args Option) (int, error)
QueueBind(name, key, exchange string, opt Option) error
QueueUnbind(name, route, exchange string, args Option) error
Consume(queue, consumer string, opt Option) (<-chan Delivery, error)
Qos(prefetchCount, prefetchSize int, global bool) error
Close() error
NotifyClose(chan Error) chan Error
Publisher
}
// Queue is a AMQP queue interface
Queue interface {
Name() string
Messages() int
Consumers() int
}
// Publisher is an interface to something able to publish messages
Publisher interface {
Publish(exc, route string, msg []byte, opt Option) error
}
// Delivery is an interface to delivered messages
Delivery interface {
Ack(multiple bool) error
Nack(multiple, requeue bool) error
Reject(requeue bool) error
Body() []byte
Headers() Option
DeliveryTag() uint64
ConsumerTag() string
MessageId() string
ContentType() string
Timestamp() time.Time
}
// Confirmation is an interface to confrimation messages
Confirmation interface {
Ack() bool
DeliveryTag() uint64
}
// Error is an interface for AMQP errors
Error interface {
Code() int
Reason() string
Server() bool
Recover() bool
error
}
)