Skip to content

Commit c7a737b

Browse files
author
Jon Mullen
authored
Merge pull request #119 from pinpt/NAN-543/smartshovel
NAN-543: smartshovel addition to rabbitmq common code
2 parents f529a75 + b1a2f4a commit c7a737b

File tree

3 files changed

+391
-0
lines changed

3 files changed

+391
-0
lines changed

event/event.go

+9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ var EventDebug = os.Getenv("PP_EVENT_DEBUG") == "1"
3232

3333
const jsonContentType = "application/json"
3434

35+
// IngestQueueName is the name of the eventapi ingest queue
36+
const IngestQueueName = "event-api-ingest"
37+
3538
// PublishEvent is the container for a model event
3639
type PublishEvent struct {
3740
Object datamodel.Model
@@ -841,6 +844,10 @@ type Subscription struct {
841844

842845
//GenerateQueueName takes in a Subscription, extracts the headers and topics and returns a consistent but unique queue name
843846
func GenerateQueueName(subscription Subscription) string {
847+
// if the queue name is IngestQueueName, short circuit and just return the groupid = queue name, since we need this to be static
848+
if subscription.GroupID == IngestQueueName {
849+
return IngestQueueName
850+
}
844851
hashkeys := []string{}
845852
for k, v := range subscription.Headers {
846853
hashkeys = append(hashkeys, k, v)
@@ -853,6 +860,8 @@ func GenerateQueueName(subscription Subscription) string {
853860
sort.Strings(hashkeys)
854861
queueName := subscription.GroupID + "-" + hash.Values(hashkeys) // has the matching headers and topics so we create a consistent but unique queue
855862

863+
864+
856865
return queueName
857866
}
858867

event/event_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -707,4 +707,13 @@ func TestGenerateQueueName(t *testing.T) {
707707

708708
//Test that changing how the headers are ordered generates the same name
709709
assert.Equal(queueName4, queueName5)
710+
711+
sub6 := Subscription{
712+
GroupID: IngestQueueName,
713+
Topics: []string{"atopic",},
714+
}
715+
queueName6 := GenerateQueueName(sub6)
716+
717+
//Test that using the ingestqueuename results in the same name
718+
assert.Equal(IngestQueueName, queueName6)
710719
}

0 commit comments

Comments
 (0)