chyezh 3563136c2a
enhance: timetick interceptor implementation (#34238)
issue: #33285

- optimize the message package
- add interceptor package to achieve append operation intercepting.
- add timetick interceptor to attach timetick properties for message.
- add timetick background task to send timetick message.

Signed-off-by: chyezh <chyezh@outlook.com>
2024-07-02 14:42:08 +08:00

44 lines
1.1 KiB
Go

package timetick
import "github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/timetick/ack"
// ackDetails records the information of AckDetail.
// Used to analyze the ack details.
// TODO: add more analysis methods. e.g. such as counter function with filter.
type ackDetails struct {
detail []*ack.AckDetail
}
// AddDetails adds details to AckDetails.
func (ad *ackDetails) AddDetails(details []*ack.AckDetail) {
if len(details) == 0 {
return
}
if len(ad.detail) == 0 {
ad.detail = details
return
}
ad.detail = append(ad.detail, details...)
}
// Empty returns true if the AckDetails is empty.
func (ad *ackDetails) Empty() bool {
return len(ad.detail) == 0
}
// Len returns the count of AckDetail.
func (ad *ackDetails) Len() int {
return len(ad.detail)
}
// LastAllAcknowledgedTimestamp returns the last timestamp which all timestamps before it have been acknowledged.
// panic if no timestamp has been acknowledged.
func (ad *ackDetails) LastAllAcknowledgedTimestamp() uint64 {
return ad.detail[len(ad.detail)-1].Timestamp
}
// Clear clears the AckDetails.
func (ad *ackDetails) Clear() {
ad.detail = nil
}