Skip to content

Commit

Permalink
Refactor handling of streamConnected
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdiep committed Nov 19, 2020
1 parent 0e35dc3 commit 2638184
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pubsublite/internal/wire/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,16 @@ func (pp *singlePartitionPublisher) onStreamStatusChange(status streamStatus) {

case streamConnected:
pp.unsafeUpdateStatus(serviceActive, nil)
pp.enableSendToStream = true

// To ensure messages are sent in order, we should resend in-flight batches
// to the stream immediately after reconnecting, before any new batches.
batches := pp.batcher.InFlightBatches()
for _, batch := range batches {
if !pp.stream.Send(batch.ToPublishRequest()) {
pp.enableSendToStream = false
break
return
}
}
pp.enableSendToStream = true

case streamTerminated:
pp.unsafeInitiateShutdown(serviceTerminated, pp.stream.Error())
Expand Down

0 comments on commit 2638184

Please sign in to comment.