Skip to content
This repository was archived by the owner on May 18, 2022. It is now read-only.

Commit f7f5853

Browse files
committed
Removed clock dependency
1 parent d8cfb7f commit f7f5853

7 files changed

+10
-14
lines changed

channel_writer.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package rabbitmq
22

33
import (
44
"sync"
5+
"time"
56

6-
"github.com/smartystreets/clock"
77
"github.com/smartystreets/messaging/v2"
88
)
99

@@ -23,7 +23,7 @@ func (this *ChannelWriter) Write(message messaging.Dispatch) error {
2323
return messaging.ErrWriterClosed
2424
}
2525

26-
dispatch := toAMQPDispatch(message, clock.UTCNow())
26+
dispatch := toAMQPDispatch(message, utcNow())
2727
err := this.channel.PublishMessage(message.Destination, message.Partition, dispatch)
2828
if err == nil {
2929
return nil
@@ -33,7 +33,9 @@ func (this *ChannelWriter) Write(message messaging.Dispatch) error {
3333
this.channel = nil
3434
return err
3535
}
36-
36+
func utcNow() time.Time {
37+
return time.Now().UTC()
38+
}
3739
func (this *ChannelWriter) Commit() error {
3840
return nil
3941
}

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.13
44

55
require (
66
github.com/smartystreets/assertions v1.1.0
7-
github.com/smartystreets/clock v1.0.3
87
github.com/smartystreets/gunit v1.3.4
98
github.com/smartystreets/logging v1.1.1
109
github.com/smartystreets/messaging/v2 v2.1.1

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
github.com/smartystreets/assertions v1.1.0 h1:MkTeG1DMwsrdH7QtLXy5W+fUxWq+vmb6cLmyJ7aRtF0=
22
github.com/smartystreets/assertions v1.1.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
3-
github.com/smartystreets/clock v1.0.3 h1:rZ2gtRux+yALko49BywVFcrWcfRg8V86Q+wwYP+SCWs=
4-
github.com/smartystreets/clock v1.0.3/go.mod h1:SeXxrsL1+0aE4256nYPPBWwuA9BGfiXu5+bxfXFsPGA=
53
github.com/smartystreets/gunit v1.3.4 h1:iHc8Rfhb/uCOc9a3KGuD3ut22L+hLIVaqR1o5fS6zC4=
64
github.com/smartystreets/gunit v1.3.4/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=
75
github.com/smartystreets/logging v1.1.1 h1:4UlnyYWB7LDd216NTuP3zTVvMQZREtPrDnJbsz0zftI=

mq_adapter_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"time"
66

77
"github.com/smartystreets/assertions/should"
8-
"github.com/smartystreets/clock"
98
"github.com/smartystreets/gunit"
109
"github.com/smartystreets/messaging/v2"
1110
"github.com/streadway/amqp"
@@ -21,7 +20,7 @@ type RabbitAdapterFixture struct {
2120
}
2221

2322
func (this *RabbitAdapterFixture) Setup() {
24-
this.now = clock.UTCNow()
23+
this.now = utcNow()
2524
}
2625

2726
/////////////////////////////////////////////////////////////////////////////////

subscription.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package rabbitmq
22

33
import (
44
"strconv"
5+
"time"
56

6-
"github.com/smartystreets/clock"
77
"github.com/smartystreets/logging"
88
"github.com/smartystreets/messaging/v2"
99
"github.com/streadway/amqp"
@@ -29,7 +29,7 @@ func newSubscription(
2929
return &Subscription{
3030
channel: channel,
3131
queue: queue,
32-
consumer: strconv.FormatInt(clock.UTCNow().UnixNano(), 10),
32+
consumer: strconv.FormatInt(time.Now().UTC().UnixNano(), 10),
3333
bindings: bindings,
3434
control: control,
3535
output: output,

subscription_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/smartystreets/assertions/should"
9-
"github.com/smartystreets/clock"
109
"github.com/smartystreets/gunit"
1110
"github.com/smartystreets/logging"
1211
"github.com/smartystreets/messaging/v2"
@@ -167,7 +166,7 @@ func (this *FakeSubscriptionChannel) DeclareQueue(name string) error {
167166
return nil
168167
}
169168
func (this *FakeSubscriptionChannel) DeclareTransientQueue() (string, error) {
170-
return strconv.FormatInt(clock.UTCNow().UnixNano(), 10), nil
169+
return strconv.FormatInt(time.Now().UTC().UnixNano(), 10), nil
171170
}
172171
func (this *FakeSubscriptionChannel) BindExchangeToQueue(queue string, exchange string) error {
173172
this.boundQueue = append(this.boundQueue, queue)

transaction_writer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package rabbitmq
33
import (
44
"sync"
55

6-
"github.com/smartystreets/clock"
76
"github.com/smartystreets/logging"
87
"github.com/smartystreets/messaging/v2"
98
)
@@ -32,7 +31,7 @@ func (this *TransactionWriter) Write(message messaging.Dispatch) error {
3231
// FUTURE: if error on publish, don't publish anything else
3332
// until we reset the channel during commit
3433
// opening a new channel is what marks it as able to continue
35-
dispatch := toAMQPDispatch(message, clock.UTCNow())
34+
dispatch := toAMQPDispatch(message, utcNow())
3635
return this.channel.PublishMessage(message.Destination, message.Partition, dispatch)
3736
}
3837

0 commit comments

Comments
 (0)