Skip to content

Commit

Permalink
enhance: init the hook when creating the proxy object
Browse files Browse the repository at this point in the history
Signed-off-by: SimFG <bang.fu@zilliz.com>
  • Loading branch information
SimFG committed Jul 23, 2024
1 parent a5deaa1 commit e8fb7b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 2 additions & 4 deletions internal/proxy/hook_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ func UnaryServerHookInterceptor() grpc.UnaryServerInterceptor {

func HookInterceptor(ctx context.Context, req any, userName, fullMethod string, handler grpc.UnaryHandler) (interface{}, error) {
if hoo == nil {
if hookError := initHook(); hookError != nil {
logger.Error("hook error", zap.String("path", Params.ProxyCfg.SoPath.GetValue()), zap.Error(hookError))
hoo = defaultHook{}
}
log.Warn("hook is not initialized")
return nil, errors.New("hook is not initialized")
}
var (
newCtx context.Context
Expand Down
4 changes: 4 additions & 0 deletions internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func NewProxy(ctx context.Context, factory dependency.Factory) (*Proxy, error) {
}
node.UpdateStateCode(commonpb.StateCode_Abnormal)
expr.Register("proxy", node)
if hookError := initHook(); hookError != nil {
log.Warn("hook error", zap.String("path", Params.ProxyCfg.SoPath.GetValue()), zap.Error(hookError))
hoo = defaultHook{}
}
logutil.Logger(ctx).Debug("create a new Proxy instance", zap.Any("state", node.stateCode.Load()))
return node, nil
}
Expand Down
3 changes: 2 additions & 1 deletion internal/querycoordv2/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"
"fmt"

"go.uber.org/zap"

"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/querycoordv2/meta"
"github.com/milvus-io/milvus/internal/querycoordv2/session"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/util/merr"
"go.uber.org/zap"
)

// In a replica, a shard is available, if and only if:
Expand Down

0 comments on commit e8fb7b0

Please sign in to comment.