2020-10-29 20:42:47 +08:00
|
|
|
package msgstream
|
|
|
|
|
|
|
|
import (
|
2021-02-04 14:37:12 +08:00
|
|
|
"context"
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
|
2020-11-03 14:53:36 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
|
|
|
|
)
|
2020-10-29 20:42:47 +08:00
|
|
|
|
2020-11-04 17:58:43 +08:00
|
|
|
type UniqueID = typeutil.UniqueID
|
|
|
|
type Timestamp = typeutil.Timestamp
|
|
|
|
type IntPrimaryKey = typeutil.IntPrimaryKey
|
2021-03-12 14:22:09 +08:00
|
|
|
type MsgPosition = internalpb.MsgPosition
|
2020-11-04 17:58:43 +08:00
|
|
|
|
2020-10-29 20:42:47 +08:00
|
|
|
type MsgPack struct {
|
2021-01-20 17:34:50 +08:00
|
|
|
BeginTs Timestamp
|
|
|
|
EndTs Timestamp
|
|
|
|
Msgs []TsMsg
|
|
|
|
StartPositions []*MsgPosition
|
2021-03-16 17:55:42 +08:00
|
|
|
EndPositions []*MsgPosition
|
2020-10-29 20:42:47 +08:00
|
|
|
}
|
|
|
|
|
2020-11-17 14:10:07 +08:00
|
|
|
type RepackFunc func(msgs []TsMsg, hashKeys [][]int32) (map[int32]*MsgPack, error)
|
2020-10-29 20:42:47 +08:00
|
|
|
|
|
|
|
type MsgStream interface {
|
2020-11-02 16:01:04 +08:00
|
|
|
Start()
|
|
|
|
Close()
|
2021-02-03 17:30:10 +08:00
|
|
|
Chan() <-chan *MsgPack
|
2021-02-04 14:37:12 +08:00
|
|
|
AsProducer(channels []string)
|
|
|
|
AsConsumer(channels []string, subName string)
|
|
|
|
SetRepackFunc(repackFunc RepackFunc)
|
2020-11-02 16:01:04 +08:00
|
|
|
|
2021-02-24 09:48:17 +08:00
|
|
|
Produce(context.Context, *MsgPack) error
|
|
|
|
Broadcast(context.Context, *MsgPack) error
|
2021-02-25 17:35:36 +08:00
|
|
|
Consume() (*MsgPack, context.Context)
|
2021-01-20 17:34:50 +08:00
|
|
|
Seek(offset *MsgPosition) error
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
2021-02-04 14:37:12 +08:00
|
|
|
|
|
|
|
type Factory interface {
|
2021-02-08 14:30:54 +08:00
|
|
|
SetParams(params map[string]interface{}) error
|
2021-02-04 14:37:12 +08:00
|
|
|
NewMsgStream(ctx context.Context) (MsgStream, error)
|
|
|
|
NewTtMsgStream(ctx context.Context) (MsgStream, error)
|
|
|
|
}
|