Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ProviderSet = wire.NewSet( NewDefaultClient, )
ProviderSet 是客户端的依赖注入提供者集合
Functions ¶
func GetConnValue ¶ added in v0.2.0
func GetConnValue[T any](ctx context.Context, c Client, connType ConnType, serviceName string) (T, error)
GetConnValue 按连接类型创建连接并提取底层值。
func RegisterPlugins ¶ added in v0.2.0
func RegisterPlugins(r *runtime.Registry, plugins ...runtime.ClientPlugin) error
RegisterPlugins 批量注册 client plugin。
Types ¶
type Client ¶
type Client interface {
// CreateConn 创建指定类型的连接
CreateConn(ctx context.Context, connType ConnType, serviceName string) (Connection, error)
}
Client 客户端接口
type Connection ¶
type Connection interface {
// Value 返回原始连接对象
Value() any
// Close 关闭连接
Close() error
// IsHealthy 检查连接健康状态
IsHealthy() bool
// GetType 返回连接类型
GetType() ConnType
}
Connection 顶层连接接口
type Option ¶ added in v0.2.0
type Option func(*options)
func WithPlugins ¶ added in v0.2.0
func WithPlugins(plugins ...runtime.ClientPlugin) Option
WithPlugins 追加外部 client plugins。
func WithRegistry ¶ added in v0.2.0
WithRegistry 注入已有 runtime registry。
func WithoutBuiltinPlugins ¶ added in v0.2.0
func WithoutBuiltinPlugins() Option
WithoutBuiltinPlugins 关闭内建 client plugins 自动注册。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.