client

package
v0.0.0-...-a029906 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(
	NewClient,
)

ProviderSet 是客户端的依赖注入提供者集合

Functions

This section is empty.

Types

type Client

type Client interface {
	// CreateConn 创建指定类型的连接
	CreateConn(ctx context.Context, connType ConnType, serviceName string) (Connection, error)
}

Client 客户端接口

func NewClient

func NewClient(
	dataCfg *conf.Data,
	traceCfg *conf.Trace,
	discovery registry.Discovery,
	logger log.Logger,
) (Client, error)

NewClient 创建客户端

type ConnType

type ConnType string

ConnType 连接类型枚举

const (
	GRPC ConnType = "grpc"
	// 未来扩展
	WebSocket ConnType = "websocket"
	HTTP      ConnType = "http"
)

type Connection

type Connection interface {
	// Value 返回原始连接对象
	Value() interface{}
	// Close 关闭连接
	Close() error
	// IsHealthy 检查连接健康状态
	IsHealthy() bool
	// GetType 返回连接类型
	GetType() ConnType
}

Connection 顶层连接接口

type GrpcConn

type GrpcConn struct {
	// contains filtered or unexported fields
}

GrpcConn gRPC连接实现

func NewGrpcConn

func NewGrpcConn(conn gogrpc.ClientConnInterface) *GrpcConn

NewGrpcConn 创建gRPC连接封装

func (*GrpcConn) Close

func (g *GrpcConn) Close() error

Close 减少引用计数(参考pool示例)

func (*GrpcConn) GetType

func (g *GrpcConn) GetType() ConnType

GetType 返回连接类型

func (*GrpcConn) IsHealthy

func (g *GrpcConn) IsHealthy() bool

IsHealthy 检查连接健康状态

func (*GrpcConn) Value

func (g *GrpcConn) Value() interface{}

Value 返回原始gRPC连接

Jump to

Keyboard shortcuts

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