chyezh dfe0416a70
enhance: implement streaming node server service (#34166)
issue: #33285

- implement producing and consuming server of message
- implement management operation for streaming node server

---------

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

49 lines
1.2 KiB
Go

//go:build test
// +build test
package walimplstest
import (
"context"
"github.com/milvus-io/milvus/pkg/streaming/util/message"
"github.com/milvus-io/milvus/pkg/streaming/util/options"
"github.com/milvus-io/milvus/pkg/streaming/walimpls"
"github.com/milvus-io/milvus/pkg/streaming/walimpls/helper"
)
var _ walimpls.WALImpls = &walImpls{}
type walImpls struct {
helper.WALHelper
datas *messageLog
}
func (w *walImpls) WALName() string {
return WALName
}
func (w *walImpls) Append(ctx context.Context, msg message.MutableMessage) (message.MessageID, error) {
return w.datas.Append(ctx, msg)
}
func (w *walImpls) Read(ctx context.Context, opts walimpls.ReadOption) (walimpls.ScannerImpls, error) {
offset := int64(0)
switch opts.DeliverPolicy.Policy() {
case options.DeliverPolicyTypeAll:
offset = 0
case options.DeliverPolicyTypeLatest:
offset = w.datas.Len()
case options.DeliverPolicyTypeStartFrom:
offset = int64(opts.DeliverPolicy.MessageID().(testMessageID))
case options.DeliverPolicyTypeStartAfter:
offset = int64(opts.DeliverPolicy.MessageID().(testMessageID)) + 1
}
return newScannerImpls(
opts, w.datas, int(offset),
), nil
}
func (w *walImpls) Close() {
}