Documentation ¶
Index ¶
- func NewGrpcConn(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func TraceUnaryInt(ctx context.Context, method string, req, reply interface{}, ...) error
- func WithTrace() grpc.DialOption
- type GrpcConn
- type GrpcConnManager
- type GrpcConnecter
- type HttpClient
- func (c *HttpClient) GetJSON(url string, data any) (err error)
- func (c *HttpClient) GetJSONAuth(url, un, pa string, data any) (err error)
- func (c *HttpClient) PostFormJSON(url string, vals url.Values, data any) (err error)
- func (c *HttpClient) PostFormJSONAuth(url, un, pa string, vals url.Values, data any) (err error)
- func (c *HttpClient) PostJSON(url string, src, data any) (err error)
- func (c *HttpClient) PostJSONAuth(url, un, pa string, src, data any) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGrpcConn ¶
func NewGrpcConn(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
NewGrpcConn 创建grpc.ClientConn,with insecure and block
func TraceUnaryInt ¶
func TraceUnaryInt(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
TraceUnaryInt 计算客户端请求耗时
Types ¶
type GrpcConn ¶
type GrpcConn struct {
// contains filtered or unexported fields
}
GrpcConn grpc连接执行
type GrpcConnManager ¶
type GrpcConnManager struct {
// contains filtered or unexported fields
}
GrpcConnManager grpc连接管理器
func (*GrpcConnManager) AddConn ¶
func (gm *GrpcConnManager) AddConn(name, addr string, connecter GrpcConnecter, opts ...grpc.DialOption)
AddConn 添加grpc连接
func (*GrpcConnManager) Reconnect ¶
func (gm *GrpcConnManager) Reconnect(name string)
Reconnect 重新grpc连接
type GrpcConnecter ¶
type GrpcConnecter interface {
OnConnected(*grpc.ClientConn)
}
GrpcConnecter grpc连接接口
type HttpClient ¶
HttpClient 嵌入http.Client,添加一些方法
func (*HttpClient) GetJSON ¶
func (c *HttpClient) GetJSON(url string, data any) (err error)
GetJSON GET请求,解析JSON
func (*HttpClient) GetJSONAuth ¶
func (c *HttpClient) GetJSONAuth(url, un, pa string, data any) (err error)
GetJSONAuth GET请求带BasicAuth认证,解析JSON
func (*HttpClient) PostFormJSON ¶
PostFormJSON POST请求,参数Form表单,解析JSON
func (*HttpClient) PostFormJSONAuth ¶
PostFormJSONAuth POST请求带BasicAuth认证,参数Form表单,解析JSON
func (*HttpClient) PostJSON ¶
func (c *HttpClient) PostJSON(url string, src, data any) (err error)
PostJSON POST JSON请求,解析JSON
func (*HttpClient) PostJSONAuth ¶
func (c *HttpClient) PostJSONAuth(url, un, pa string, src, data any) (err error)
PostJSONAuth POST JSON请求带BasicAuth认证,解析JSON
Click to show internal directories.
Click to hide internal directories.