sdk

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig added in v0.0.4

type AuthConfig struct {
	// 应用 ID
	AppID string
	// 应用密钥
	Secret string
}

AuthConfig 认证配置

type BreakerConfig added in v0.0.4

type BreakerConfig struct {
	// 是否启用熔断器
	Enabled bool
	// 失败率阈值 (0-1)
	FailureRatio float64
}

BreakerConfig 熔断器配置

type Client

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

Client 平台服务 SDK 客户端

func NewClient

func NewClient(config ClientConfig) (*Client, error)

NewClient 创建新的 SDK 客户端

func (*Client) Close

func (c *Client) Close() error

Close 关闭客户端连接

func (*Client) DictData

func (c *Client) DictData() tp.DictDataClient

DictData 返回字典数据客户端

func (*Client) DictType

func (c *Client) DictType() tp.DictTypeClient

DictType 返回字典类型客户端

func (*Client) GetConn

func (c *Client) GetConn() *grpc.ClientConn

GetConn 返回原始的 gRPC 连接(高级用法)

func (*Client) GetStats added in v0.0.4

func (c *Client) GetStats() map[string]interface{}

GetStats 获取客户端统计信息

func (*Client) IsHealthy added in v0.0.4

func (c *Client) IsHealthy() bool

IsHealthy 检查客户端是否健康

func (*Client) Platform

func (c *Client) Platform() tp.PlatformClient

Platform 返回平台客户端

func (*Client) PlatformAuth

func (c *Client) PlatformAuth() tp.PlatformAuthClient

PlatformAuth 返回平台权限客户端

func (*Client) RpcService

func (c *Client) RpcService() tp.RpcServiceClient

RpcService 返回微服务客户端

func (*Client) RpcServiceGroup

func (c *Client) RpcServiceGroup() tp.RpcServiceGroupClient

RpcServiceGroup 返回微服务分组客户端

func (*Client) RpcServiceMethod

func (c *Client) RpcServiceMethod() tp.RpcServiceMethodClient

RpcServiceMethod 返回微服务方法客户端

func (*Client) RpcServiceMethodLog

func (c *Client) RpcServiceMethodLog() tp.RpcServiceMethodLogClient

RpcServiceMethodLog 返回微服务调用日志客户端

func (*Client) WaitForReady added in v0.0.4

func (c *Client) WaitForReady(timeout time.Duration) error

WaitForReady 等待连接就纭 (timeout时间内)

type ClientConfig

type ClientConfig struct {
	// 直连模式:服务器地址,格式: localhost:8080 或 127.0.0.1:8080
	Address string

	// etcd 服务发现配置
	Etcd *EtcdConfig

	// 认证配置
	Auth *AuthConfig

	// 连接超时时间,默认 5 秒
	Timeout time.Duration

	// 是否使用 TLS,默认不使用
	UseTLS bool

	// TLS 证书路径(仅在 UseTLS=true 时有效)
	CertFile string

	// 最大接收消息大小,默认 4MB
	MaxRecvMsgSize int

	// 最大发送消息大小,默认 4MB
	MaxSendMsgSize int

	// 最大重试次数,默认 3
	MaxRetryAttempts int

	// 熔断器配置
	Breaker *BreakerConfig
}

ClientConfig SDK 客户端配置

type ClientStats added in v0.0.4

type ClientStats struct {
	TotalCalls      int64     `json:"total_calls"`
	SuccessCalls    int64     `json:"success_calls"`
	FailedCalls     int64     `json:"failed_calls"`
	AvgLatency      float64   `json:"avg_latency_ms"`
	TotalLatency    int64     `json:"total_latency_ms"` // 用于计算平均值
	LastCallTime    time.Time `json:"last_call_time"`
	LastErrorMsg    string    `json:"last_error_msg,omitempty"`
	ConnectionState string    `json:"connection_state"`
	// contains filtered or unexported fields
}

ClientStats SDK 客户端统计信息

type EtcdConfig added in v0.0.4

type EtcdConfig struct {
	// etcd 服务器地址列表
	Hosts []string
	// 服务注册键
	Key string
}

EtcdConfig etcd 服务发现配置

Directories

Path Synopsis
services
dict/client
Code generated by SDK generator.
Code generated by SDK generator.
platform/client
Code generated by SDK generator.
Code generated by SDK generator.
platform_auth/client
Code generated by SDK generator.
Code generated by SDK generator.
rpc_service/client
Code generated by SDK generator.
Code generated by SDK generator.

Jump to

Keyboard shortcuts

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