Files
micro-client-http/options.go
Evstigneev Denis 334a10e26d
Some checks failed
lint / lint (pull_request) Failing after 1m20s
test / test (pull_request) Successful in 1m59s
prepare options
2025-02-21 20:13:34 +03:00

99 lines
2.5 KiB
Go

package http
import (
"net"
"net/http"
"go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/options"
)
var (
// DefaultPoolMaxStreams maximum streams on a connectioin
// (20)
DefaultPoolMaxStreams = 20
// DefaultPoolMaxIdle maximum idle conns of a pool
// (50)
DefaultPoolMaxIdle = 50
// DefaultMaxRecvMsgSize maximum message that client can receive
// (4 MB).
DefaultMaxRecvMsgSize = 1024 * 1024 * 4
// DefaultMaxSendMsgSize maximum message that client can send
// (4 MB).
DefaultMaxSendMsgSize = 1024 * 1024 * 4
)
// PoolMaxStreams maximum streams on a connectioin
func PoolMaxStreams(n int) options.Option {
return options.NewOption("PoolMaxStreams")(n)
}
// PoolMaxIdle maximum idle conns of a pool
func PoolMaxIdle(n int) options.Option {
return options.NewOption("PoolMaxIdle")(n)
}
// MaxRecvMsgSize set the maximum size of message that client can receive.
func MaxRecvMsgSize(n int) options.Option {
return options.NewOption("MaxRecvMsgSize")(n)
}
// MaxSendMsgSize set the maximum size of message that client can send.
func MaxSendMsgSize(n int) options.Option {
return options.NewOption("MaxSendMsgSize")(n)
}
// nolint: golint
// HTTPClient pass http.Client option to client Call
func HTTPClient(c *http.Client) options.Option {
return options.NewOption("HTTPClient")(c)
}
// nolint: golint
// HTTPDialer pass net.Dialer option to client
func HTTPDialer(d *net.Dialer) options.Option {
return options.NewOption("HTTPDialer")(d)
}
// Method pass method option to client Call
func Method(m string) options.Option {
return options.NewOption("Method")(m)
}
// Path spcecifies path option to client Call
func Path(p string) options.Option {
return options.NewOption("Path")(p)
}
// Body specifies body option to client Call
func Body(b string) options.Option {
return options.NewOption("Body")(b)
}
func ErrorMap(m map[string]interface{}) options.Option {
return options.NewOption("ErrorMap")(m)
}
// StructTags pass tags slice option to client Call
func StructTags(tags []string) options.Option {
return options.NewOption("StructTags")(tags)
}
// Metadata pass metadata to client Call
func Metadata(md metadata.Metadata) options.Option {
return options.NewOption("Metadata")(md)
}
// Cookie pass cookie to client Call
func Cookie(cookies ...string) options.Option {
return options.NewOption("Cookie")(cookies)
}
// Header pass cookie to client Call
func Header(headers ...string) options.Option {
return options.NewOption("Header")(headers)
}