forked from Azure/go-amqp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
link_options.go
216 lines (183 loc) · 6.45 KB
/
link_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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
package amqp
import (
"time"
"github.com/pdaures/go-amqp/internal/encoding"
)
type SenderOptions struct {
// Capabilities is the list of extension capabilities the sender supports/desires.
Capabilities []string
// Durability indicates what state of the sender will be retained durably.
//
// Default: DurabilityNone.
Durability Durability
// DynamicAddress indicates a dynamic address is to be used.
// Any specified address will be ignored.
//
// Default: false.
DynamicAddress bool
// ExpiryPolicy determines when the expiry timer of the sender starts counting
// down from the timeout value. If the link is subsequently re-attached before
// the timeout is reached, the count down is aborted.
//
// Default: ExpirySessionEnd.
ExpiryPolicy ExpiryPolicy
// ExpiryTimeout is the duration in seconds that the sender will be retained.
//
// Default: 0.
ExpiryTimeout uint32
// IgnoreDispositionErrors controls automatic detach on disposition errors.
//
// Default: false.
IgnoreDispositionErrors bool
// Name sets the name of the link.
//
// Link names must be unique per-connection and direction.
//
// Default: randomly generated.
Name string
// Properties sets an entry in the link properties map sent to the server.
Properties map[string]interface{}
// RequestedReceiverSettleMode sets the requested receiver settlement mode.
//
// If a settlement mode is explicitly set and the server does not
// honor it an error will be returned during link attachment.
//
// Default: Accept the settlement mode set by the server, commonly ModeFirst.
RequestedReceiverSettleMode *ReceiverSettleMode
// SettlementMode sets the settlement mode in use by this sender.
//
// Default: ModeMixed.
SettlementMode *SenderSettleMode
// SourceAddress specifies the source address for this sender.
SourceAddress string
}
type ReceiverOptions struct {
// LinkBatching toggles batching of message disposition.
//
// When enabled, accepting a message does not send the disposition
// to the server until the batch is equal to link credit or the
// batch max age expires.
//
// Default: false.
Batching bool
// BatchMaxAge sets the maximum time between the start
// of a disposition batch and sending the batch to the server.
//
// Has no effect when Batching is false.
//
// Default: 5 seconds.
BatchMaxAge time.Duration
// Capabilities is the list of extension capabilities the receiver supports/desires.
Capabilities []string
// Credit specifies the maximum number of unacknowledged messages
// the sender can transmit.
//
// Default: 1.
Credit uint32
// Durability indicates what state of the receiver will be retained durably.
//
// Default: DurabilityNone.
Durability Durability
// DynamicAddress indicates a dynamic address is to be used.
// Any specified address will be ignored.
//
// Default: false.
DynamicAddress bool
// ExpiryPolicy determines when the expiry timer of the sender starts counting
// down from the timeout value. If the link is subsequently re-attached before
// the timeout is reached, the count down is aborted.
//
// Default: ExpirySessionEnd.
ExpiryPolicy ExpiryPolicy
// ExpiryTimeout is the duration in seconds that the sender will be retained.
//
// Default: 0.
ExpiryTimeout uint32
// Filters contains the desired filters for this receiver.
// If the peer cannot fulfill the filters the link will be detached.
Filters []LinkFilter
// ManualCredits enables manual credit management for this link.
// Credits can be added with IssueCredit(), and links can also be
// drained with DrainCredit().
ManualCredits bool
// MaxMessageSize sets the maximum message size that can
// be received on the link.
//
// A size of zero indicates no limit.
//
// Default: 0.
MaxMessageSize uint64
// Name sets the name of the link.
//
// Link names must be unique per-connection and direction.
//
// Default: randomly generated.
Name string
// Properties sets an entry in the link properties map sent to the server.
Properties map[string]interface{}
// RequestedSenderSettleMode sets the requested sender settlement mode.
//
// If a settlement mode is explicitly set and the server does not
// honor it an error will be returned during link attachment.
//
// Default: Accept the settlement mode set by the server, commonly ModeMixed.
RequestedSenderSettleMode *SenderSettleMode
// SettlementMode sets the settlement mode in use by this receiver.
//
// Default: ModeFirst.
SettlementMode *ReceiverSettleMode
// TargetAddress specifies the target address for this receiver.
TargetAddress string
}
// LinkFilter is an advanced API for setting non-standard source filters.
// Please file an issue or open a PR if a standard filter is missing from this
// library.
//
// The name is the key for the filter map. It will be encoded as an AMQP symbol type.
//
// The code is the descriptor of the described type value. The domain-id and descriptor-id
// should be concatenated together. If 0 is passed as the code, the name will be used as
// the descriptor.
//
// The value is the value of the descriped types. Acceptable types for value are specific
// to the filter.
//
// Example:
//
// The standard selector-filter is defined as:
//
// <descriptor name="apache.org:selector-filter:string" code="0x0000468C:0x00000004"/>
//
// In this case the name is "apache.org:selector-filter:string" and the code is
// 0x0000468C00000004.
//
// LinkSourceFilter("apache.org:selector-filter:string", 0x0000468C00000004, exampleValue)
//
// References:
//
// http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-filter-set
// http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#section-descriptor-values
type LinkFilter func(encoding.Filter)
// LinkFilterSource creates or updates the named filter for this LinkFilter.
func LinkFilterSource(name string, code uint64, value interface{}) LinkFilter {
return func(f encoding.Filter) {
var descriptor interface{}
if code != 0 {
descriptor = code
} else {
descriptor = encoding.Symbol(name)
}
f[encoding.Symbol(name)] = &encoding.DescribedType{
Descriptor: descriptor,
Value: value,
}
}
}
// LinkFilterSelector creates or updates the selector filter (apache.org:selector-filter:string) for this LinkFilter.
func LinkFilterSelector(filter string) LinkFilter {
return LinkFilterSource(selectorFilter, selectorFilterCode, filter)
}
const (
selectorFilter = "apache.org:selector-filter:string"
selectorFilterCode = uint64(0x0000468C00000004)
)