publish and send to follower

This commit is contained in:
chrislu
2024-03-27 23:10:24 -07:00
parent f249f831b1
commit dab5454332
2 changed files with 23 additions and 19 deletions

View File

@@ -143,21 +143,8 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis
}
// send to the local partition
localTopicPartition.Publish(dataMessage)
receivedSequence = dataMessage.TsNs
// maybe send to the follower
if localTopicPartition.FollowerStream != nil {
println("recv", string(dataMessage.Key), dataMessage.TsNs)
if followErr := localTopicPartition.FollowerStream.Send(&mq_pb.PublishFollowMeRequest{
Message: &mq_pb.PublishFollowMeRequest_Data{
Data: dataMessage,
},
}); followErr != nil {
return followErr
}
} else {
atomic.StoreInt64(&localTopicPartition.AckTsNs, receivedSequence)
if err = localTopicPartition.Publish(dataMessage); err != nil {
return fmt.Errorf("topic %v partition %v publish error: %v", initMessage.Topic, initMessage.Partition, err)
}
}