Skip to content

Commit

Permalink
publish should not have been a public function
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebakken committed Mar 19, 2023
1 parent 772bfd6 commit 65674cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ func (ch *Channel) PublishWithDeferredConfirmWithContext(ctx context.Context, ex

var dc *DeferredConfirmation
if ch.confirming {
dc = ch.confirms.Publish()
dc = ch.confirms.publish()
}

if err := ch.send(&basicPublish{
Expand Down
2 changes: 1 addition & 1 deletion confirms.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c *confirms) Listen(l chan Confirmation) {
}

// Publish increments the publishing counter
func (c *confirms) Publish() *DeferredConfirmation {
func (c *confirms) publish() *DeferredConfirmation {
c.publishedMut.Lock()
defer c.publishedMut.Unlock()

Expand Down
12 changes: 6 additions & 6 deletions confirms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestConfirmOneResequences(t *testing.T) {
c.Listen(l)

for i := range fixtures {
if want, got := uint64(i+1), c.Publish(); want != got.DeliveryTag {
if want, got := uint64(i+1), c.publish(); want != got.DeliveryTag {
t.Fatalf("expected publish to return the 1 based delivery tag published, want: %d, got: %d", want, got.DeliveryTag)
}
}
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestConfirmAndPublishDoNotDeadlock(t *testing.T) {
}()

for i := 0; i < iterations; i++ {
c.Publish()
c.publish()
<-l
}
}
Expand All @@ -82,7 +82,7 @@ func TestConfirmMixedResequences(t *testing.T) {
c.Listen(l)

for range fixtures {
c.Publish()
c.publish()
}

c.One(fixtures[0])
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestConfirmMultipleResequences(t *testing.T) {
c.Listen(l)

for range fixtures {
c.Publish()
c.publish()
}

c.Multiple(fixtures[len(fixtures)-1])
Expand All @@ -141,7 +141,7 @@ func BenchmarkSequentialBufferedConfirms(t *testing.B) {
if i > cap(l)-1 {
<-l
}
c.One(Confirmation{c.Publish().DeliveryTag, true})
c.One(Confirmation{c.publish().DeliveryTag, true})
}
}

Expand All @@ -159,7 +159,7 @@ func TestConfirmsIsThreadSafe(t *testing.T) {
c.Listen(l)

for i := 0; i < count; i++ {
go func() { pub <- Confirmation{c.Publish().DeliveryTag, true} }()
go func() { pub <- Confirmation{c.publish().DeliveryTag, true} }()
}

for i := 0; i < count; i++ {
Expand Down

0 comments on commit 65674cf

Please sign in to comment.