Documentation ¶
Index ¶
- Constants
- func BindMetadataForContext(ctx context.Context, data map[string]string) context.Context
- func NewClient(ctx context.Context, uri string, pbNewXxxClient interface{}, ...) (interface{}, error)
- type ClientOptional
- func WithDialOptions(options ...grpc.DialOption) ClientOptional
- func WithLoadBalance(loadBalance string) ClientOptional
- func WithLogger(logger *zap.Logger) ClientOptional
- func WithMetrics(metrics bool) ClientOptional
- func WithResolver(r resolver.Builder) ClientOptional
- func WithSecure(secure bool) ClientOptional
- func WithTimeout(t time.Duration) ClientOptional
- func WithTracer(tracer opentracing.Tracer) ClientOptional
- type ClientOptions
- type HttpClient
- func (c *HttpClient) Get(ctx context.Context, path string, header http.Header, reqData url.Values, ...) (err error)
- func (c *HttpClient) GetRaw(ctx context.Context, path string, header http.Header, reqData url.Values) (rsp string, err error)
- func (c *HttpClient) Post(ctx context.Context, path string, header http.Header, reqData interface{}, ...) (err error)
- func (c *HttpClient) PostRaw(ctx context.Context, path string, header http.Header, reqData interface{}) (rsp string, err error)
- func (c *HttpClient) Request(ctx context.Context, method, path string, header http.Header, ...) (err error)
- type HttpClientOptional
- type HttpClientOptions
- type Resolver
Constants ¶
View Source
const ( // DefaultTimeout DefaultTimeout = time.Second * 10 // DefaultRetryTimes 如果请求失败,最多重试3次 DefaultRetryTimes = 3 // DefaultRetryDelay 在重试前,延迟等待100毫秒 DefaultRetryDelay = time.Millisecond * 100 RequestIDHeader = "X-Request-Id" )
View Source
const ( KiB MiB GiB TiB // DialTimeout the timeout of create connection DialTimeout = 5 * time.Second // BackoffMaxDelay provided maximum delay when backing off after failed connection attempts. BackoffMaxDelay = 3 * time.Second // MaxSendMsgSize set max gRPC request message size sent to server. // If any request message size is larger than current value, an error will be reported from gRPC. MaxSendMsgSize = 4 << 30 // MaxRecvMsgSize set max gRPC receive message size received from server. // If any message size is larger than current value, an error will be reported from gRPC. MaxRecvMsgSize = 4 << 30 // InitialWindowSize we set it 1GB is to provide system's throughput. InitialWindowSize = 1 << 30 // InitialConnWindowSize we set it 1GB is to provide system's throughput. InitialConnWindowSize = 1 << 30 )
Variables ¶
This section is empty.
Functions ¶
func BindMetadataForContext ¶
BindMetadataForContext
Types ¶
type ClientOptional ¶
type ClientOptional func(o *ClientOptions)
ClientOptional
func WithDialOptions ¶ added in v0.2.30
func WithDialOptions(options ...grpc.DialOption) ClientOptional
WithDialOptions
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
ClientOptions
type HttpClient ¶ added in v0.2.30
type HttpClient struct {
// contains filtered or unexported fields
}
HttpClient
func NewHttpClient ¶ added in v0.2.30
func NewHttpClient(ctx context.Context, uri string, opts ...HttpClientOptional) (*HttpClient, error)
NewHttpClient
func (*HttpClient) Get ¶ added in v0.3.0
func (c *HttpClient) Get(ctx context.Context, path string, header http.Header, reqData url.Values, rspPtr interface{}) (err error)
Get
func (*HttpClient) GetRaw ¶ added in v0.3.0
func (c *HttpClient) GetRaw(ctx context.Context, path string, header http.Header, reqData url.Values) (rsp string, err error)
GetRaw
func (*HttpClient) Post ¶ added in v0.3.0
func (c *HttpClient) Post(ctx context.Context, path string, header http.Header, reqData interface{}, rspPtr interface{}) (err error)
Post
type HttpClientOptional ¶ added in v0.2.30
type HttpClientOptional func(o *HttpClientOptions)
ClientOptional
func WithHttpLogger ¶ added in v0.2.30
func WithHttpLogger(logger *zap.Logger) HttpClientOptional
WithHttpLogger
func WithHttpResolver ¶ added in v0.2.30
func WithHttpResolver(resolver Resolver) HttpClientOptional
WithHttpResolver
func WithHttpTracer ¶ added in v0.2.30
func WithHttpTracer(tracer opentracing.Tracer) HttpClientOptional
WithHttpTracer
func WithReqestTimeout ¶ added in v0.2.11
func WithReqestTimeout(t time.Duration) HttpClientOptional
WithReqestTimeout
type HttpClientOptions ¶ added in v0.2.30
type HttpClientOptions struct {
// contains filtered or unexported fields
}
HttpClientOptions
Click to show internal directories.
Click to hide internal directories.