mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-03 01:12:25 +08:00
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>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package timetick
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors"
|
|
"github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/timetick/ack"
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
|
)
|
|
|
|
var _ interceptors.InterceptorBuilder = (*interceptorBuilder)(nil)
|
|
|
|
// NewInterceptorBuilder creates a new interceptor builder.
|
|
// 1. Add timetick to all message before append to wal.
|
|
// 2. Collect timetick info, and generate sync-timetick message to wal.
|
|
func NewInterceptorBuilder() interceptors.InterceptorBuilder {
|
|
return &interceptorBuilder{}
|
|
}
|
|
|
|
// interceptorBuilder is a builder to build timeTickAppendInterceptor.
|
|
type interceptorBuilder struct{}
|
|
|
|
// Build implements Builder.
|
|
func (b *interceptorBuilder) Build(param interceptors.InterceptorBuildParam) interceptors.BasicInterceptor {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
interceptor := &timeTickAppendInterceptor{
|
|
ctx: ctx,
|
|
cancel: cancel,
|
|
ready: make(chan struct{}),
|
|
ackManager: ack.NewAckManager(),
|
|
ackDetails: &ackDetails{},
|
|
sourceID: paramtable.GetNodeID(),
|
|
}
|
|
go interceptor.executeSyncTimeTick(
|
|
// TODO: move the configuration to streamingnode.
|
|
paramtable.Get().ProxyCfg.TimeTickInterval.GetAsDuration(time.Millisecond),
|
|
param,
|
|
)
|
|
return interceptor
|
|
}
|