grpcclient

package
v0.10.3-0...-bec5499 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	None = ""
	Zstd = "zstd"
)

Variables

View Source
var ErrConnect errConnect

ErrConnect is the instance for errors.Is target usage.

Functions

func IsCrossClusterRoutingErr

func IsCrossClusterRoutingErr(err error) bool

func IsServerIDMismatchErr

func IsServerIDMismatchErr(err error) bool

func NewLocalGRPCClient

func NewLocalGRPCClient[C any, S any](desc *grpc.ServiceDesc, server S, clientCreator func(grpc.ClientConnInterface) C) C

NewLocalGRPCClient creates a grpc client that calls the server directly. !!! Warning: it didn't make any network or serialization/deserialization, so it's not promise concurrent safe. and there's no interceptor for client and server like the common grpc client/server.

Types

type ClientBase

type ClientBase[T interface {
	GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error)
}] struct {
	ClientMaxSendSize      int
	ClientMaxRecvSize      int
	CompressionEnabled     bool
	RetryServiceNameConfig string

	DialTimeout      time.Duration
	KeepAliveTime    time.Duration
	KeepAliveTimeout time.Duration

	MaxAttempts    int
	InitialBackoff float64
	MaxBackoff     float64

	NodeID atomic.Int64
	// contains filtered or unexported fields
}

ClientBase is a base of grpc client

func NewClientBase

func NewClientBase[T interface {
	GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error)
}](config *paramtable.GrpcClientConfig, serviceName string,
) *ClientBase[T]

func (*ClientBase[T]) Call

func (c *ClientBase[T]) Call(ctx context.Context, caller func(client T) (any, error)) (any, error)

Call does a grpc call

func (*ClientBase[T]) Close

func (c *ClientBase[T]) Close() error

Close close the client connection

func (*ClientBase[T]) EnableEncryption

func (c *ClientBase[T]) EnableEncryption()

func (*ClientBase[T]) GetAddr

func (c *ClientBase[T]) GetAddr() string

GetAddr returns address of client

func (*ClientBase[T]) GetGrpcClient

func (c *ClientBase[T]) GetGrpcClient(ctx context.Context) (*clientConnWrapper[T], error)

GetGrpcClient returns grpc client

func (*ClientBase[T]) GetNodeID

func (c *ClientBase[T]) GetNodeID() int64

GetNodeID returns ID of client

func (*ClientBase[T]) GetRole

func (c *ClientBase[T]) GetRole() string

GetRole returns role of client

func (*ClientBase[T]) ReCall

func (c *ClientBase[T]) ReCall(ctx context.Context, caller func(client T) (any, error)) (any, error)

ReCall does the grpc call twice

func (*ClientBase[T]) SetGetAddrFunc

func (c *ClientBase[T]) SetGetAddrFunc(f func() (string, error))

SetGetAddrFunc sets getAddrFunc of client

func (*ClientBase[T]) SetInternalTLSCertPool

func (c *ClientBase[T]) SetInternalTLSCertPool(cp *x509.CertPool)

func (*ClientBase[T]) SetNewGrpcClientFunc

func (c *ClientBase[T]) SetNewGrpcClientFunc(f func(cc *grpc.ClientConn) T)

SetNewGrpcClientFunc sets newGrpcClient of client

func (*ClientBase[T]) SetNodeID

func (c *ClientBase[T]) SetNodeID(nodeID int64)

SetNodeID set ID role of client

func (*ClientBase[T]) SetRole

func (c *ClientBase[T]) SetRole(role string)

SetRole sets role of client

func (*ClientBase[T]) SetSession

func (c *ClientBase[T]) SetSession(sess *sessionutil.Session)

SetSession set session role of client

type GrpcClient

type GrpcClient[T GrpcComponent] interface {
	SetRole(string)
	GetRole() string
	SetGetAddrFunc(func() (string, error))
	EnableEncryption()
	SetInternalTLSCertPool(cp *x509.CertPool)
	SetNewGrpcClientFunc(func(cc *grpc.ClientConn) T)
	ReCall(ctx context.Context, caller func(client T) (any, error)) (any, error)
	Call(ctx context.Context, caller func(client T) (any, error)) (any, error)
	Close() error
	SetNodeID(int64)
	GetNodeID() int64
	SetSession(sess *sessionutil.Session)
}

GrpcClient abstracts client of grpc

type GrpcComponent

type GrpcComponent interface {
	GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error)
}

type Token

type Token struct {
	Value string
}

func (*Token) GetRequestMetadata

func (t *Token) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

func (*Token) RequireTransportSecurity

func (t *Token) RequireTransportSecurity() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL