Browse Source

shutdown follower if no clients, not only publishers

to avoid overhead when a publisher repeatedly send one message and close
mq-subscribe
chrislu 9 months ago
parent
commit
237e68059d
  1. 4
      weed/mq/topic/local_partition.go

4
weed/mq/topic/local_partition.go

@ -190,7 +190,7 @@ func (p *LocalPartition) MaybeConnectToFollowers(initMessage *mq_pb.PublishMessa
func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) { func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
if p.Publishers.Size() == 0 {
if p.Publishers.Size() == 0 && p.Subscribers.Size() == 0 {
if p.followerStream != nil { if p.followerStream != nil {
// send close to the follower // send close to the follower
if followErr := p.followerStream.Send(&mq_pb.PublishFollowMeRequest{ if followErr := p.followerStream.Send(&mq_pb.PublishFollowMeRequest{
@ -205,9 +205,7 @@ func (p *LocalPartition) MaybeShutdownLocalPartition() (hasShutdown bool) {
p.followerStream = nil p.followerStream = nil
p.follower = "" p.follower = ""
} }
}
if p.Publishers.Size() == 0 && p.Subscribers.Size() == 0 {
p.LogBuffer.ShutdownLogBuffer() p.LogBuffer.ShutdownLogBuffer()
hasShutdown = true hasShutdown = true
} }

Loading…
Cancel
Save