yucli

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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 计算客户端请求耗时

func WithTrace

func WithTrace() grpc.DialOption

WithTrace 返回TraceUnaryInt的DialOption

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 NewGrpcConnManager

func NewGrpcConnManager() *GrpcConnManager

NewGrpcConnManager 创建grpc连接管理器

func (*GrpcConnManager) AddConn

func (gm *GrpcConnManager) AddConn(name, addr string, connecter GrpcConnecter, opts ...grpc.DialOption)

AddConn 添加grpc连接

func (*GrpcConnManager) CloseConns

func (gm *GrpcConnManager) CloseConns()

CloseConns 关闭所有连接

func (*GrpcConnManager) Reconnect

func (gm *GrpcConnManager) Reconnect(name string)

Reconnect 重新grpc连接

type GrpcConnecter

type GrpcConnecter interface {
	OnConnected(*grpc.ClientConn)
}

GrpcConnecter grpc连接接口

type HttpClient

type HttpClient struct {
	*http.Client
}

HttpClient 嵌入http.Client,添加一些方法

func NewHttpClient

func NewHttpClient() *HttpClient

NewHttpClient 创建HttpClient

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

func (c *HttpClient) PostFormJSON(url string, vals url.Values, data any) (err error)

PostFormJSON POST请求,参数Form表单,解析JSON

func (*HttpClient) PostFormJSONAuth

func (c *HttpClient) PostFormJSONAuth(url, un, pa string, vals url.Values, data any) (err error)

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

Jump to

Keyboard shortcuts

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