mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 09:08:43 +08:00
issue: #43897 - Return LastConfirmedMessageID when wal append operation. - Add resource-key-based locker for broadcast-ack operation to protect the coord state when executing ddl. - Resource-key-based locker is held until the broadcast operation is acked. - ResourceKey support shared and exclusive lock. - Add FastAck execute ack right away after the broadcast done to speed up ddl. - Ack callback will support broadcast message result now. - Add tombstone for broadcaster to avoid to repeatedly commit DDL and ABA issue. --------- Signed-off-by: chyezh <chyezh@outlook.com>
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package broadcast
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/milvus-io/milvus/internal/streamingcoord/server/broadcaster"
|
|
"github.com/milvus-io/milvus/pkg/v2/streaming/util/message"
|
|
"github.com/milvus-io/milvus/pkg/v2/util/syncutil"
|
|
)
|
|
|
|
var singleton = syncutil.NewFuture[broadcaster.Broadcaster]()
|
|
|
|
// Register registers the broadcaster.
|
|
func Register(broadcaster broadcaster.Broadcaster) {
|
|
singleton.Set(broadcaster)
|
|
}
|
|
|
|
// GetWithContext gets the broadcaster with context.
|
|
func GetWithContext(ctx context.Context) (broadcaster.Broadcaster, error) {
|
|
return singleton.GetWithContext(ctx)
|
|
}
|
|
|
|
// StartBroadcastWithResourceKeys starts a broadcast with resource keys.
|
|
func StartBroadcastWithResourceKeys(ctx context.Context, resourceKeys ...message.ResourceKey) (broadcaster.BroadcastAPI, error) {
|
|
broadcaster, err := singleton.GetWithContext(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return broadcaster.WithResourceKeys(ctx, resourceKeys...)
|
|
}
|
|
|
|
// Release releases the broadcaster.
|
|
func Release() {
|
|
if !singleton.Ready() {
|
|
return
|
|
}
|
|
singleton.Get().Close()
|
|
}
|