chyezh 3563136c2a
enhance: timetick interceptor implementation (#34238)
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>
2024-07-02 14:42:08 +08:00

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
}