498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
//go:build test
|
|
// +build test
|
|
|
|
package walimplstest
|
|
|
|
import (
|
|
"github.com/milvus-io/milvus/pkg/v3/streaming/util/message"
|
|
"github.com/milvus-io/milvus/pkg/v3/streaming/walimpls"
|
|
"github.com/milvus-io/milvus/pkg/v3/streaming/walimpls/helper"
|
|
)
|
|
|
|
var _ walimpls.ScannerImpls = &scannerImpls{}
|
|
|
|
func newScannerImpls(opts walimpls.ReadOption, data *messageLog, offset int) *scannerImpls {
|
|
s := &scannerImpls{
|
|
ScannerHelper: helper.NewScannerHelper(opts.Name),
|
|
datas: data,
|
|
ch: make(chan message.ImmutableMessage),
|
|
offset: offset,
|
|
}
|
|
go s.executeConsume()
|
|
return s
|
|
}
|
|
|
|
type scannerImpls struct {
|
|
*helper.ScannerHelper
|
|
datas *messageLog
|
|
ch chan message.ImmutableMessage
|
|
offset int
|
|
}
|
|
|
|
func (s *scannerImpls) executeConsume() {
|
|
defer func() {
|
|
close(s.ch)
|
|
s.Finish(nil)
|
|
}()
|
|
for {
|
|
msg, err := s.datas.ReadAt(s.Context(), s.offset)
|
|
if err != nil {
|
|
return
|
|
}
|
|
select {
|
|
case <-s.Context().Done():
|
|
return
|
|
case s.ch <- msg:
|
|
}
|
|
s.offset++
|
|
}
|
|
}
|
|
|
|
func (s *scannerImpls) Chan() <-chan message.ImmutableMessage {
|
|
return s.ch
|
|
}
|
|
|
|
func (s *scannerImpls) Close() error {
|
|
return s.ScannerHelper.Close()
|
|
}
|