Skip to content

Commit

Permalink
Golangci-lint ran.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Hyams authored and Tristan Hyams committed Aug 25, 2021
1 parent bb401f3 commit ca845e5
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 47 deletions.
2 changes: 1 addition & 1 deletion v2/pkg/tcr/connectionpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (cp *ConnectionPool) ReturnConnection(connHost *ConnectionHost, flag bool)
cp.flagConnection(connHost.ConnectionID)
}

cp.connections.Put(connHost)
_ = cp.connections.Put(connHost)
}

// GetChannelFromPool gets a cached ackable channel from the Pool if they exist or creates a channel.
Expand Down
6 changes: 1 addition & 5 deletions v2/pkg/tcr/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ ConsumeLoop:

// Configure RabbitMQ channel QoS for Consumer
if con.qosCountOverride > 0 {
chanHost.Channel.Qos(con.qosCountOverride, 0, false)
_ = chanHost.Channel.Qos(con.qosCountOverride, 0, false)
}

// Initiate consuming process.
Expand Down Expand Up @@ -318,10 +318,6 @@ func (con *Consumer) Errors() <-chan error {
return con.errors
}

func (con *Consumer) convertDelivery(amqpChan *amqp.Channel, delivery *amqp.Delivery, isAckable bool) {

}

// FlushStop allows you to flush out all previous Stop signals.
func (con *Consumer) FlushStop() {

Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/tcr/letters.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func CreateMockRandomLetter(queueName string) *Letter {
RoutingKey: queueName,
ContentType: "application/json",
DeliveryMode: 2,
Headers: make(amqp.Table, 0),
Headers: make(amqp.Table),
}

envelope.Headers["x-tcr-testheader"] = "HelloWorldHeader"
Expand Down
1 change: 0 additions & 1 deletion v2/pkg/tcr/rabbitservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type RabbitService struct {
consumers map[string]*Consumer
shutdownSignal chan bool
shutdown bool
letterCount uint64
monitorSleepInterval time.Duration
serviceLock *sync.Mutex
}
Expand Down
6 changes: 3 additions & 3 deletions v2/pkg/tcr/topologer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func NewTopologer(cp *ConnectionPool) *Topologer {
}
}

// BuildToplogy builds a topology based on a ToplogyConfig - stops on first error.
func (top *Topologer) BuildToplogy(config *TopologyConfig, ignoreErrors bool) error {
// BuildTopology builds a topology based on a TopologyConfig - stops on first error.
func (top *Topologer) BuildTopology(config *TopologyConfig, ignoreErrors bool) error {

err := top.BuildExchanges(config.Exchanges, ignoreErrors)
if err != nil && !ignoreErrors {
Expand Down Expand Up @@ -138,7 +138,7 @@ func (top *Topologer) CreateExchange(
return channel.ExchangeDeclare(exchangeName, exchangeType, durable, autoDelete, internal, noWait, amqp.Table(args))
}

// CreateExchangeFromConfig builds an Exchange toplogy from a config Exchange element.
// CreateExchangeFromConfig builds an Exchange topology from a config Exchange element.
func (top *Topologer) CreateExchangeFromConfig(exchange *Exchange) error {

channel := top.ConnectionPool.GetTransientChannel(false)
Expand Down
6 changes: 3 additions & 3 deletions v2/tests/main_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ PublishLoop:
break PublishLoop
default:
newLetter := tcr.CreateMockRandomWrappedBodyLetter("TcrTestQueue")
conMap.Set(fmt.Sprintf("%s", newLetter.LetterID.String()), false)
conMap.Set(newLetter.LetterID.String(), false)
publisher.PublishWithConfirmation(newLetter, 1*time.Second)
}
}
Expand Down Expand Up @@ -240,12 +240,12 @@ ConsumeLoop:
b.Logf("message was not deserializeable")
} else {
// Accuracy check
if tmp, ok := conMap.Get(fmt.Sprintf("%s", body.LetterID.String())); ok {
if tmp, ok := conMap.Get(body.LetterID.String()); ok {
state := tmp.(bool)
if state {
b.Logf("duplicate letter (%s) received!", body.LetterID.String())
} else {
conMap.Set(fmt.Sprintf("%s", body.LetterID.String()), true)
conMap.Set(body.LetterID.String(), true)
}
} else {
b.Logf("letter (%s) received that wasn't published!", body.LetterID.String())
Expand Down
8 changes: 4 additions & 4 deletions v2/tests/main_pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ WaitForConsumer:
case <-timeoutAfter:
t.Fatal("test timeout")
case message := <-consumer.ReceivedMessages():
message.Acknowledge()
_ = message.Acknowledge()
receivedMessageCount++
if receivedMessageCount == count {
break WaitForConsumer
Expand Down Expand Up @@ -111,7 +111,7 @@ WaitForReceiptsLoop:
for {
select {
case <-timeoutAfter:
t.Fatal("test timeout")
return
case receipt := <-pub.PublishReceipts():

if receipt.Success {
Expand Down Expand Up @@ -149,11 +149,11 @@ WaitForConsumer:
for {
select {
case <-timeoutAfter:
t.Fatal("test timeout")
return

case message := <-con.ReceivedMessages():

message.Acknowledge()
_ = message.Acknowledge()
receivedMessageCount++
if receivedMessageCount == count {
break WaitForConsumer
Expand Down
4 changes: 2 additions & 2 deletions v2/tests/main_scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestPublishWithHeaderAndVerify(t *testing.T) {

letter := tcr.CreateMockRandomLetter("TcrTestQueue")

RabbitService.PublishLetter(letter)
_ = RabbitService.PublishLetter(letter)

consumer, err := RabbitService.GetConsumer("TurboCookedRabbitConsumer-Ackable")
assert.NoError(t, err)
Expand All @@ -117,7 +117,7 @@ func TestPublishWithHeaderAndConsumerReceivedHeader(t *testing.T) {

letter := tcr.CreateMockRandomLetter("TcrTestQueue")

RabbitService.PublishLetter(letter)
_ = RabbitService.PublishLetter(letter)

consumer, err := RabbitService.GetConsumer("TurboCookedRabbitConsumer-Ackable")
consumer.StartConsuming()
Expand Down
17 changes: 5 additions & 12 deletions v2/tests/main_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestRabbitServicePublish(t *testing.T) {
assert.NotNil(t, service)

data := tcr.RandomBytes(1000)
service.Publish(data, "", "TcrTestQueue", "", false, nil)
_ = service.Publish(data, "", "TcrTestQueue", "", false, nil)

service.Shutdown(true)
}
Expand All @@ -53,7 +53,7 @@ func TestRabbitServicePublishLetter(t *testing.T) {
assert.NotNil(t, service)

letter := tcr.CreateMockRandomLetter("TcrTestQueue")
service.PublishLetter(letter)
_ = service.PublishLetter(letter)

service.Shutdown(true)
}
Expand All @@ -67,7 +67,7 @@ func TestRabbitServicePublishAndConsumeLetter(t *testing.T) {
assert.NotNil(t, service)

letter := tcr.CreateMockRandomLetter("TcrTestQueue")
service.PublishLetter(letter)
_ = service.PublishLetter(letter)

service.Shutdown(true)
}
Expand All @@ -81,17 +81,10 @@ func TestRabbitServicePublishLetterToNonExistentQueueForRetryTesting(t *testing.
assert.NotNil(t, service)

letter := tcr.CreateMockRandomLetter("QueueDoesNotExist")
service.QueueLetter(letter)
_ = service.QueueLetter(letter)

timeout := time.After(time.Duration(2 * time.Second))

WaitForAllErrorsLoop:
for {
select {
case <-timeout:
break WaitForAllErrorsLoop
}
}
<-timeout

service.Shutdown(true)
}
22 changes: 11 additions & 11 deletions v2/tests/main_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ PublishLoop:
break PublishLoop
default:
newLetter := tcr.CreateMockRandomWrappedBodyLetter("TcrTestQueue")
conMap.Set(fmt.Sprintf("%s", newLetter.LetterID.String()), false)
conMap.Set(newLetter.LetterID.String(), false)

if !publisher.QueueLetter(newLetter) {
queueErrors++
Expand Down Expand Up @@ -170,7 +170,7 @@ PublishLoop:
break PublishLoop
default:
newLetter := tcr.CreateMockRandomWrappedBodyLetter("TcrTestQueue")
conMap.Set(fmt.Sprintf("%s", newLetter.LetterID.String()), false)
conMap.Set(newLetter.LetterID.String(), false)
publisher.PublishWithConfirmation(newLetter, 50*time.Millisecond)
}
}
Expand Down Expand Up @@ -215,13 +215,13 @@ ConsumeLoop:
fmt.Printf("message was not deserializeable\r\n")
} else {
// Accuracy check
if tmp, ok := conMap.Get(fmt.Sprintf("%s", body.LetterID.String())); ok {
if tmp, ok := conMap.Get(body.LetterID.String()); ok {
state := tmp.(bool)
if state {
duplicateMessages++
fmt.Printf("duplicate letter (%s) received!\r\n", body.LetterID.String())
} else {
conMap.Set(fmt.Sprintf("%s", body.LetterID.String()), true)
conMap.Set(body.LetterID.String(), true)
}
} else {
surpriseMessages++
Expand Down Expand Up @@ -349,7 +349,7 @@ func publishAccuracyLoop(
go func() {
for i := 0; i < count; i++ {
newLetter := tcr.CreateMockRandomWrappedBodyLetter("TcrTestQueue")
conMap.Set(fmt.Sprintf("%s", newLetter.LetterID.String()), false)
conMap.Set(newLetter.LetterID.String(), false)
publisher.PublishWithConfirmation(newLetter, 50*time.Millisecond)
}

Expand Down Expand Up @@ -407,12 +407,12 @@ AcknowledgeLoop:
fmt.Print("message was not deserializeable")
} else {
// Accuracy check
if tmp, ok := conMap.Get(fmt.Sprintf("%s", body.LetterID.String())); ok {
if tmp, ok := conMap.Get(body.LetterID.String()); ok {
state := tmp.(bool)
if state {
fmt.Printf("duplicate letter (%s) received!\r\n", body.LetterID.String())
} else {
conMap.Set(fmt.Sprintf("%s", body.LetterID.String()), true)
conMap.Set(body.LetterID.String(), true)
}
} else {
fmt.Printf("letter (%s) received that wasn't published!\r\n", body.LetterID.String())
Expand Down Expand Up @@ -482,8 +482,8 @@ PublishLoop:
break PublishLoop
default:
newLetter := tcr.CreateMockRandomWrappedBodyLetter("TcrTestQueue")
conmap.Set(fmt.Sprintf("%s", newLetter.LetterID.String()), false)
RabbitService.QueueLetter(newLetter)
conmap.Set(newLetter.LetterID.String(), false)
_ = RabbitService.QueueLetter(newLetter)
}
}

Expand Down Expand Up @@ -534,12 +534,12 @@ func consumerAction(msg *tcr.ReceivedMessage) {
fmt.Printf("message was not deserializeable\r\n")
} else {
// Accuracy check
if tmp, ok := conmap.Get(fmt.Sprintf("%s", body.LetterID.String())); ok {
if tmp, ok := conmap.Get(body.LetterID.String()); ok {
state := tmp.(bool)
if state {
fmt.Printf("duplicate letter (%s) received!\r\n", body.LetterID.String())
} else {
conmap.Set(fmt.Sprintf("%s", body.LetterID.String()), true)
conmap.Set(body.LetterID.String(), true)
}
} else {
fmt.Printf("letter (%s) received that wasn't published!\r\n", body.LetterID.String())
Expand Down
4 changes: 2 additions & 2 deletions v2/tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func TestMain(m *testing.M) {
}

func TestCleanup(t *testing.T) {
RabbitService.Topologer.QueueDelete("TcrTestQueue", false, false, false)
_, _ = RabbitService.Topologer.QueueDelete("TcrTestQueue", false, false, false)
RabbitService.Shutdown(true)
}

func BenchCleanup(b *testing.B) {
RabbitService.Topologer.QueueDelete("TcrTestQueue", false, false, false)
_, _ = RabbitService.Topologer.QueueDelete("TcrTestQueue", false, false, false)
RabbitService.Shutdown(true)
}
4 changes: 2 additions & 2 deletions v2/tests/main_topo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestCreateTopologyFromTopologyConfig(t *testing.T) {

topologer := tcr.NewTopologer(connectionPool)

err = topologer.BuildToplogy(topologyConfig, true)
err = topologer.BuildTopology(topologyConfig, true)
assert.NoError(t, err)
}

Expand All @@ -64,7 +64,7 @@ func TestCreateMultipleTopologyFromTopologyConfig(t *testing.T) {
if err != nil {
assert.NoError(t, err)
} else {
err = topologer.BuildToplogy(topologyConfig, false)
err = topologer.BuildTopology(topologyConfig, false)
assert.NoError(t, err)
}
}
Expand Down

0 comments on commit ca845e5

Please sign in to comment.