in pulsar/message.go [195:224]
func messageIDCompare(lhs MessageID, rhs MessageID) int {
if lhs.LedgerID() < rhs.LedgerID() {
return -1
} else if lhs.LedgerID() > rhs.LedgerID() {
return 1
}
if lhs.EntryID() < rhs.EntryID() {
return -1
} else if lhs.EntryID() > rhs.EntryID() {
return 1
}
// When performing batch index ACK on a batched message whose batch size is N,
// the ACK order should be:
// (ledger, entry, 0) -> (ledger, entry, 1) -> ... -> (ledger, entry, N-1) -> (ledger, entry)
// So we have to treat any MessageID with the batch index precedes the MessageID without the batch index
// if they are in the same entry.
if lhs.BatchIdx() < 0 && rhs.BatchIdx() < 0 {
return 0
} else if lhs.BatchIdx() >= 0 && rhs.BatchIdx() < 0 {
return -1
} else if lhs.BatchIdx() < 0 && rhs.BatchIdx() >= 0 {
return 1
}
if lhs.BatchIdx() < rhs.BatchIdx() {
return -1
} else if lhs.BatchIdx() > rhs.BatchIdx() {
return 1
}
return 0
}