-
Notifications
You must be signed in to change notification settings - Fork 0
/
topology_options.go
47 lines (43 loc) · 2.1 KB
/
topology_options.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
package grabbit
import (
amqp "github.com/rabbitmq/amqp091-go"
)
// TopologyBind defines the possible binding relation between exchanges or queues and exchanges.
type TopologyBind struct {
Enabled bool // want this re-routing
Peer string // other end of routing
Key string // routing key / filter
NoWait bool // re-routing confirmation required
Args amqp.Table // core properties
}
// TopologyOptions defines the infrastructure topology, i.e. exchange and queues definition
// when wanting handling automatically on recovery or one time creation
type TopologyOptions struct {
Name string // tag of exchange or queue
IsDestination bool // end target, i.e. if messages should be routed to it
IsExchange bool // indicates if this an exchange or queue
Bind TopologyBind // complex routing
Kind string // empty string for default exchange or: direct, topic, fanout, headers.
Durable bool // maps the durable amqp attribute
AutoDelete bool // maps the auto-delete amqp attribute
Exclusive bool // if queue is exclusive
Internal bool //
NoWait bool // // maps the noWait amqp attribute
Passive bool // if false, it will be created on the server when missing
Args amqp.Table // wraps the amqp Table parameters
Declare bool // gets created on start and also during recovery if Durable is false
}
// GetRouting returns the source and destination strings for the TopologyOptions struct.
//
// The source and destination strings are determined based on whether IsDestination is true or false.
// - if IsDestination is true, the source string is set to t.Bind.Peer and the destination string is set to t.Name.
// - if IsDestination is false, the source string is set to t.Name and the destination string is set to t.Bind.Peer.
//
// Returns the source and destination strings.
func (t *TopologyOptions) GetRouting() (source, destination string) {
if t.IsDestination {
return t.Bind.Peer, t.Name
} else {
return t.Name, t.Bind.Peer
}
}