Documentation ¶
Overview ¶
Package protocol 提供了 HTTP、HTTPS、NSHead、ProtoBuffer 协议支持
Index ¶
Constants ¶
View Source
const HttpClientAlive time.Duration = 5 * time.Minute
View Source
const UA = "GCAL/" + gversion.VERSION + " (laya gcal http client)"
Variables ¶
View Source
var DefaultHTTPClientFactory = func(serv service.Service) (cli *http.Client, err error) { var proxyURL *url.URL perHost := -1 if serv.GetReuse() { perHost = 2 } return &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyURL(proxyURL), DialContext: (&net.Dialer{ Timeout: serv.GetConnTimeout(), KeepAlive: 30 * time.Second, }).DialContext, MaxIdleConnsPerHost: perHost, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, }, Timeout: serv.GetTotalTimeout(), }, nil }
DefaultHTTPClientFactory 默认的 http client factory
Functions ¶
This section is empty.
Types ¶
type HTTPHead ¶
type HTTPHead struct { Status string StatusCode int Proto string Header map[string][]string ContentLength int64 }
HTTPHead HTTPResponse,兼容历史
type HTTPProtocol ¶
HTTPProtocol http 协议
func NewHTTPProtocol ¶
func NewHTTPProtocol(ctx *context.Context, serv service.Service, req *HTTPRequest, isHTTPS bool) (hp *HTTPProtocol, err error)
NewHTTPProtocol 创建一个 Http Protocol
type HTTPRequest ¶
type HTTPRequest struct { CustomAddr string Header map[string][]string Method string Body interface{} Path string QueryParams url.Values TraceId string Converter converter.ConverterType Ctx context.RequestContext }
HTTPRequest http requst 对象,gcal.Cal 函数必须传递这个类型的变量
type PbRPCProtocol ¶
type PbRPCProtocol struct {
// contains filtered or unexported fields
}
PbRPCProtocol pbrpc 协议
func NewPbRPCProtocol ¶
func NewPbRPCProtocol(ctx *context.Context, serv service.Service, req *PbRPCRequest) (hp *PbRPCProtocol, err error)
NewPbRPCProtocol 创建 PbRPC协议
type PbRPCRequest ¶
type PbRPCRequest struct { CustomAddr string Data *grpcx.Package TraceId string Ctx context.RequestContext }
PbRPCRequest PbRpc 请求
Click to show internal directories.
Click to hide internal directories.