2024-06-27 15:11:05 +08:00
|
|
|
package options
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/milvus-io/milvus/pkg/streaming/util/message"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2024-07-09 07:58:14 +08:00
|
|
|
DeliverPolicyTypeAll deliverPolicyType = 1
|
|
|
|
DeliverPolicyTypeLatest deliverPolicyType = 2
|
|
|
|
DeliverPolicyTypeStartFrom deliverPolicyType = 3
|
|
|
|
DeliverPolicyTypeStartAfter deliverPolicyType = 4
|
|
|
|
|
|
|
|
DeliverFilterTypeTimeTickGT deliverFilterType = 1
|
|
|
|
DeliverFilterTypeTimeTickGTE deliverFilterType = 2
|
|
|
|
DeliverFilterTypeVChannel deliverFilterType = 3
|
2024-06-27 15:11:05 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2024-07-09 07:58:14 +08:00
|
|
|
deliverPolicyType int
|
|
|
|
deliverFilterType int
|
2024-06-27 15:11:05 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// DeliverPolicy is the policy of delivering messages.
|
|
|
|
type DeliverPolicy interface {
|
2024-07-09 07:58:14 +08:00
|
|
|
Policy() deliverPolicyType
|
2024-06-27 15:11:05 +08:00
|
|
|
|
|
|
|
MessageID() message.MessageID
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeliverPolicyAll delivers all messages.
|
|
|
|
func DeliverPolicyAll() DeliverPolicy {
|
|
|
|
return &deliverPolicyWithoutMessageID{
|
|
|
|
policy: DeliverPolicyTypeAll,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeliverLatest delivers the latest message.
|
|
|
|
func DeliverPolicyLatest() DeliverPolicy {
|
|
|
|
return &deliverPolicyWithoutMessageID{
|
|
|
|
policy: DeliverPolicyTypeLatest,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeliverEarliest delivers the earliest message.
|
|
|
|
func DeliverPolicyStartFrom(messageID message.MessageID) DeliverPolicy {
|
|
|
|
return &deliverPolicyWithMessageID{
|
|
|
|
policy: DeliverPolicyTypeStartFrom,
|
|
|
|
messageID: messageID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeliverPolicyStartAfter delivers the message after the specified message.
|
|
|
|
func DeliverPolicyStartAfter(messageID message.MessageID) DeliverPolicy {
|
|
|
|
return &deliverPolicyWithMessageID{
|
|
|
|
policy: DeliverPolicyTypeStartAfter,
|
|
|
|
messageID: messageID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-09 07:58:14 +08:00
|
|
|
// DeliverFilter is the filter of delivering messages.
|
|
|
|
type DeliverFilter interface {
|
|
|
|
Type() deliverFilterType
|
|
|
|
|
|
|
|
Filter(message.ImmutableMessage) bool
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// DeliverFilters
|
|
|
|
//
|
|
|
|
|
|
|
|
// DeliverFilterTimeTickGT delivers messages by time tick greater than the specified time tick.
|
|
|
|
func DeliverFilterTimeTickGT(timeTick uint64) DeliverFilter {
|
|
|
|
return &deliverFilterTimeTickGT{
|
|
|
|
timeTick: timeTick,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeliverFilterTimeTickGTE delivers messages by time tick greater than or equal to the specified time tick.
|
|
|
|
func DeliverFilterTimeTickGTE(timeTick uint64) DeliverFilter {
|
|
|
|
return &deliverFilterTimeTickGTE{
|
|
|
|
timeTick: timeTick,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeliverFilterVChannel delivers messages filtered by vchannel.
|
|
|
|
func DeliverFilterVChannel(vchannel string) DeliverFilter {
|
|
|
|
return &deliverFilterVChannel{
|
|
|
|
vchannel: vchannel,
|
|
|
|
}
|
2024-06-27 15:11:05 +08:00
|
|
|
}
|