Documentation ¶
Index ¶
- Variables
- type EtcdConnOptions
- type GrpcClient
- func (gc *GrpcClient) Build() (*GrpcClient, error)
- func (gc *GrpcClient) GetConn(serverAppName string) *grpc.ClientConn
- func (gc *GrpcClient) WithContext(ctx context.Context) *GrpcClient
- func (gc *GrpcClient) WithDialOptions(options ...grpc.DialOption) *GrpcClient
- func (gc *GrpcClient) WithLogger(logger *zap.Logger) *GrpcClient
- type IConnFactory
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrClientInit = errors.New("grpcClient init error")
View Source
var ErrConfig = errors.New("config error")
View Source
var ErrConfigNotFound = errors.New("config not found error")
View Source
var ErrCreateConn = errors.New("create clientConn error")
View Source
var Factories map[string]IConnFactory
Factories 定义了已经注册的工厂(IConnFactory), 其中map的key是schema,目前实现了etcd的discovery方式
Functions ¶
This section is empty.
Types ¶
type EtcdConnOptions ¶
type EtcdConnOptions struct { EtcdConfig *clientv3.Config // EtcdConfig 指定etcd 配置 // contains filtered or unexported fields }
EtcdConnOptions 用于etcd注册中心服务发现配置
type GrpcClient ¶
type GrpcClient struct {
// contains filtered or unexported fields
}
GrpcClient 此对象应该全局单例,封装了grpc客户端以及客户端服务发现
func New ¶
func New(cfg *config.ClientConfig) *GrpcClient
func (*GrpcClient) Build ¶
func (gc *GrpcClient) Build() (*GrpcClient, error)
func (*GrpcClient) GetConn ¶
func (gc *GrpcClient) GetConn(serverAppName string) *grpc.ClientConn
func (*GrpcClient) WithContext ¶
func (gc *GrpcClient) WithContext(ctx context.Context) *GrpcClient
func (*GrpcClient) WithDialOptions ¶
func (gc *GrpcClient) WithDialOptions(options ...grpc.DialOption) *GrpcClient
func (*GrpcClient) WithLogger ¶
func (gc *GrpcClient) WithLogger(logger *zap.Logger) *GrpcClient
type IConnFactory ¶
type IConnFactory interface { BuildOptions(ctx context.Context, serverCfg *config.RpcServerConfig) error CreateConn(serverCfg *config.RpcServerConfig, options ...grpc.DialOption) (*grpc.ClientConn, error) }
IConnFactory 接口定义了用于创建grpc.ClientConn的工厂, 解析、构建配置并创建grpc.ClientConn
Click to show internal directories.
Click to hide internal directories.