Skip to content

Commit c82637d

Browse files
committed
Refactor and remove QueueType
It is just a wrapper around TQueueType
1 parent c8d3639 commit c82637d

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

pkg/rabbitmqamqp/amqp_queue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ func (a *AmqpQueue) Arguments(arguments map[string]any) {
9292
a.arguments = arguments
9393
}
9494

95-
func (a *AmqpQueue) QueueType(queueType QueueType) {
96-
if len(queueType.String()) != 0 {
97-
a.arguments["x-queue-type"] = queueType.String()
95+
func (a *AmqpQueue) QueueType(queueType TQueueType) {
96+
if len(string(queueType)) != 0 {
97+
a.arguments["x-queue-type"] = string(queueType)
9898
}
9999
}
100100

pkg/rabbitmqamqp/entities.go

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,14 @@ const (
1212
Stream TQueueType = "stream"
1313
)
1414

15-
type QueueType struct {
16-
Type TQueueType
17-
}
18-
19-
func (e QueueType) String() string {
20-
return string(e.Type)
21-
}
22-
2315
/*
2416
IQueueSpecification represents the specification of a queue
2517
*/
2618
type IQueueSpecification interface {
2719
name() string
2820
isAutoDelete() bool
2921
isExclusive() bool
30-
queueType() QueueType
22+
queueType() TQueueType
3123
buildArguments() map[string]any
3224
}
3325

@@ -107,8 +99,8 @@ func (q *QuorumQueueSpecification) isExclusive() bool {
10799
return false
108100
}
109101

110-
func (q *QuorumQueueSpecification) queueType() QueueType {
111-
return QueueType{Type: Quorum}
102+
func (q *QuorumQueueSpecification) queueType() TQueueType {
103+
return Quorum
112104
}
113105

114106
func (q *QuorumQueueSpecification) buildArguments() map[string]any {
@@ -165,7 +157,7 @@ func (q *QuorumQueueSpecification) buildArguments() map[string]any {
165157
result["x-quorum-initial-group-size"] = q.QuorumInitialGroupSize
166158
}
167159

168-
result["x-queue-type"] = q.queueType().String()
160+
result["x-queue-type"] = string(q.queueType())
169161
return result
170162
}
171163

@@ -201,8 +193,8 @@ func (q *ClassicQueueSpecification) isExclusive() bool {
201193
return q.IsExclusive
202194
}
203195

204-
func (q *ClassicQueueSpecification) queueType() QueueType {
205-
return QueueType{Type: Classic}
196+
func (q *ClassicQueueSpecification) queueType() TQueueType {
197+
return Classic
206198
}
207199

208200
func (q *ClassicQueueSpecification) buildArguments() map[string]any {
@@ -251,7 +243,7 @@ func (q *ClassicQueueSpecification) buildArguments() map[string]any {
251243
result["x-queue-leader-locator"] = q.LeaderLocator.leaderLocator()
252244
}
253245

254-
result["x-queue-type"] = q.queueType().String()
246+
result["x-queue-type"] = string(q.queueType())
255247

256248
return result
257249
}
@@ -281,8 +273,8 @@ func (a *AutoGeneratedQueueSpecification) isExclusive() bool {
281273
return a.IsExclusive
282274
}
283275

284-
func (a *AutoGeneratedQueueSpecification) queueType() QueueType {
285-
return QueueType{Classic}
276+
func (a *AutoGeneratedQueueSpecification) queueType() TQueueType {
277+
return Classic
286278
}
287279

288280
func (a *AutoGeneratedQueueSpecification) buildArguments() map[string]any {
@@ -299,7 +291,7 @@ func (a *AutoGeneratedQueueSpecification) buildArguments() map[string]any {
299291
result["x-max-length"] = a.MaxLength
300292
}
301293

302-
result["x-queue-type"] = a.queueType().String()
294+
result["x-queue-type"] = string(a.queueType())
303295

304296
return result
305297
}
@@ -323,8 +315,8 @@ func (s *StreamQueueSpecification) isExclusive() bool {
323315
return false
324316
}
325317

326-
func (s *StreamQueueSpecification) queueType() QueueType {
327-
return QueueType{Type: Stream}
318+
func (s *StreamQueueSpecification) queueType() TQueueType {
319+
return Stream
328320
}
329321

330322
func (s *StreamQueueSpecification) buildArguments() map[string]any {
@@ -341,7 +333,7 @@ func (s *StreamQueueSpecification) buildArguments() map[string]any {
341333
result["x-stream-initial-cluster-size"] = s.InitialClusterSize
342334
}
343335

344-
result["x-queue-type"] = s.queueType().String()
336+
result["x-queue-type"] = string(s.queueType())
345337

346338
return result
347339
}

0 commit comments

Comments
 (0)