Documentation ¶
Index ¶
- Constants
- Variables
- func BodyMaxBytes(n int64) func(inner http.Handler) http.Handler
- func BulkHead(workers int, maxWaitTime time.Duration) func(inner http.Handler) http.Handler
- func CallbackOnChange(listener *httpConfigListener) func(event *configmgr.NacosChangeEvent)
- func GetTranslator() ut.Translator
- func GetValidate() *validator.Validate
- func InitialiseRemoteConfigListener()
- func NewClient() *resty.Client
- func NewHttpConfigListener() *httpConfigListener
- func Proxy(proxyConfig ProxyConfig) func(inner http.Handler) http.Handler
- func SetTranslator(trans ut.Translator)
- func ValidateStruct(value interface{}) error
- func ValidateVar(value interface{}, tag, param string) error
- type BizError
- type BizErrorOption
- type DdClient
- type DdClientOption
- type DefaultHttpSrv
- type HttpRouterSrv
- type MemberlistServiceProvider
- func (m *MemberlistServiceProvider) AddNode(node *memberlist.Node)
- func (m *MemberlistServiceProvider) GetServer(nodeName string) *server
- func (m *MemberlistServiceProvider) RemoveNode(node *memberlist.Node)
- func (m *MemberlistServiceProvider) SelectServer() string
- func (m *MemberlistServiceProvider) UpdateWeight(node *memberlist.Node)
- type NacosProviderOption
- type NacosRRServiceProvider
- type NacosWRRServiceProvider
- type ProxyConfig
- type ProxyTarget
- type ServiceProvider
- type SmoothWeightedRoundRobinProvider
- func (m *SmoothWeightedRoundRobinProvider) AddNode(node *memberlist.Node)
- func (m *SmoothWeightedRoundRobinProvider) GetServer(nodeName string) *server
- func (m *SmoothWeightedRoundRobinProvider) RemoveNode(node *memberlist.Node)
- func (m *SmoothWeightedRoundRobinProvider) SelectServer() string
- func (m *SmoothWeightedRoundRobinProvider) UpdateWeight(node *memberlist.Node)
Constants ¶
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderAllow = "Allow" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderIfModifiedSince = "If-Modified-Since" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXUrlScheme = "X-Url-Scheme" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXRealIP = "X-Real-IP" HeaderXRequestID = "X-Request-ID" HeaderXRequestedWith = "X-Requested-With" HeaderServer = "Server" HeaderOrigin = "Origin" // Access control HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" // Security HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderXFrameOptions = "X-Frame-Options" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only" HeaderXCSRFToken = "X-CSRF-Token" HeaderReferrerPolicy = "Referrer-Policy" )
Headers borrowed from labstack/echo
Variables ¶
var RunnerChain = goresilience.RunnerChain
Functions ¶
func BodyMaxBytes ¶ added in v1.1.2
func BulkHead ¶
BulkHead add bulk head pattern middleware based on https://github.com/slok/goresilience workers is the number of workers in the execution pool. maxWaitTime is the max time an incoming request will wait to execute before being dropped its execution and return 429 response.
func CallbackOnChange ¶ added in v1.0.6
func CallbackOnChange(listener *httpConfigListener) func(event *configmgr.NacosChangeEvent)
func GetTranslator ¶ added in v1.1.9
func GetTranslator() ut.Translator
func GetValidate ¶ added in v1.1.9
func GetValidate() *validator.Validate
func InitialiseRemoteConfigListener ¶ added in v1.0.6
func InitialiseRemoteConfigListener()
func NewHttpConfigListener ¶ added in v1.0.6
func NewHttpConfigListener() *httpConfigListener
func Proxy ¶ added in v1.1.1
func Proxy(proxyConfig ProxyConfig) func(inner http.Handler) http.Handler
func SetTranslator ¶ added in v1.1.9
func SetTranslator(trans ut.Translator)
func ValidateStruct ¶ added in v1.1.9
func ValidateStruct(value interface{}) error
func ValidateVar ¶ added in v1.1.9
Types ¶
type BizError ¶
BizError is used for business error implemented error interface StatusCode will be set to http response status code ErrCode is used for business error code ErrMsg is custom error message
func NewBizError ¶
func NewBizError(err error, opts ...BizErrorOption) BizError
NewBizError is factory function for creating an instance of BizError struct
type BizErrorOption ¶
type BizErrorOption func(bizError *BizError)
func WithCause ¶ added in v1.2.5
func WithCause(cause error) BizErrorOption
func WithErrCode ¶
func WithErrCode(errCode int) BizErrorOption
func WithStatusCode ¶
func WithStatusCode(statusCode int) BizErrorOption
type DdClient ¶
type DdClient interface { SetProvider(provider registry.IServiceProvider) SetClient(client *resty.Client) SetRootPath(rootPath string) }
DdClient defines service client interface
type DdClientOption ¶
type DdClientOption func(DdClient)
DdClientOption defines configure function type
func WithProvider ¶
func WithProvider(provider registry.IServiceProvider) DdClientOption
WithProvider sets service provider
func WithRootPath ¶ added in v1.0.1
func WithRootPath(rootPath string) DdClientOption
WithRootPath sets root path for sending http requests
type DefaultHttpSrv ¶
DefaultHttpSrv wraps gorilla mux router
func NewDefaultHttpSrv ¶
func NewDefaultHttpSrv() *DefaultHttpSrv
NewDefaultHttpSrv create a DefaultHttpSrv instance
func (*DefaultHttpSrv) AddMiddleware ¶
func (srv *DefaultHttpSrv) AddMiddleware(mwf ...func(http.Handler) http.Handler)
AddMiddleware adds middlewares to the end of chain
func (*DefaultHttpSrv) AddRoute ¶
func (srv *DefaultHttpSrv) AddRoute(route ...model.Route)
AddRoute adds routes to router
func (*DefaultHttpSrv) PreMiddleware ¶
func (srv *DefaultHttpSrv) PreMiddleware(mwf ...func(http.Handler) http.Handler)
PreMiddleware adds middlewares to the head of chain
type HttpRouterSrv ¶ added in v1.2.7
type HttpRouterSrv struct { Router *httprouter.RouteGroup // contains filtered or unexported fields }
HttpRouterSrv wraps httpRouter router
func NewHttpRouterSrv ¶ added in v1.2.7
func NewHttpRouterSrv() *HttpRouterSrv
NewHttpRouterSrv create a HttpRouterSrv instance
func (*HttpRouterSrv) AddMiddleware ¶ added in v1.2.7
func (srv *HttpRouterSrv) AddMiddleware(mwf ...func(http.Handler) http.Handler)
AddMiddleware adds middlewares to the end of chain
func (*HttpRouterSrv) AddRoute ¶ added in v1.2.7
func (srv *HttpRouterSrv) AddRoute(route ...model.Route)
AddRoute adds routes to router
func (*HttpRouterSrv) PreMiddleware ¶ added in v1.2.7
func (srv *HttpRouterSrv) PreMiddleware(mwf ...func(http.Handler) http.Handler)
PreMiddleware adds middlewares to the head of chain
type MemberlistServiceProvider ¶
type MemberlistServiceProvider struct {
// contains filtered or unexported fields
}
MemberlistServiceProvider defines an implementation for IServiceProvider
func NewMemberlistServiceProvider ¶
func NewMemberlistServiceProvider(name string) *MemberlistServiceProvider
NewMemberlistServiceProvider create an NewMemberlistServiceProvider instance
func (*MemberlistServiceProvider) AddNode ¶
func (m *MemberlistServiceProvider) AddNode(node *memberlist.Node)
AddNode add or update node providing the service
func (*MemberlistServiceProvider) GetServer ¶ added in v1.0.6
func (m *MemberlistServiceProvider) GetServer(nodeName string) *server
func (*MemberlistServiceProvider) RemoveNode ¶
func (m *MemberlistServiceProvider) RemoveNode(node *memberlist.Node)
func (*MemberlistServiceProvider) SelectServer ¶
func (m *MemberlistServiceProvider) SelectServer() string
SelectServer selects a node which is supplying service specified by name property from cluster
func (*MemberlistServiceProvider) UpdateWeight ¶
func (m *MemberlistServiceProvider) UpdateWeight(node *memberlist.Node)
type NacosProviderOption ¶ added in v1.0.1
type NacosProviderOption func(registry.INacosServiceProvider)
func WithNacosClusters ¶ added in v1.0.1
func WithNacosClusters(clusters []string) NacosProviderOption
func WithNacosGroupName ¶ added in v1.0.1
func WithNacosGroupName(groupName string) NacosProviderOption
func WithNacosNamingClient ¶ added in v1.0.1
func WithNacosNamingClient(namingClient naming_client.INamingClient) NacosProviderOption
type NacosRRServiceProvider ¶ added in v1.0.1
type NacosRRServiceProvider struct {
// contains filtered or unexported fields
}
NacosRRServiceProvider is a simple round-robin load balance implementation for IServiceProvider
func NewNacosRRServiceProvider ¶ added in v1.0.1
func NewNacosRRServiceProvider(serviceName string, opts ...NacosProviderOption) *NacosRRServiceProvider
NewNacosRRServiceProvider creates new ServiceProvider instance
func (*NacosRRServiceProvider) SelectServer ¶ added in v1.0.1
func (n *NacosRRServiceProvider) SelectServer() string
SelectServer return service address from environment variable
func (*NacosRRServiceProvider) SetClusters ¶ added in v1.0.1
func (b *NacosRRServiceProvider) SetClusters(clusters []string)
func (*NacosRRServiceProvider) SetGroupName ¶ added in v1.0.1
func (b *NacosRRServiceProvider) SetGroupName(groupName string)
func (*NacosRRServiceProvider) SetNamingClient ¶ added in v1.0.1
func (b *NacosRRServiceProvider) SetNamingClient(namingClient naming_client.INamingClient)
type NacosWRRServiceProvider ¶ added in v1.0.1
type NacosWRRServiceProvider struct {
// contains filtered or unexported fields
}
NacosWRRServiceProvider is a WRR load balance implementation for IServiceProvider
func NewNacosWRRServiceProvider ¶ added in v1.0.1
func NewNacosWRRServiceProvider(serviceName string, opts ...NacosProviderOption) *NacosWRRServiceProvider
NewNacosWRRServiceProvider creates new ServiceProvider instance
func (*NacosWRRServiceProvider) SelectServer ¶ added in v1.0.1
func (n *NacosWRRServiceProvider) SelectServer() string
SelectServer return service address from environment variable
func (*NacosWRRServiceProvider) SetClusters ¶ added in v1.0.1
func (b *NacosWRRServiceProvider) SetClusters(clusters []string)
func (*NacosWRRServiceProvider) SetGroupName ¶ added in v1.0.1
func (b *NacosWRRServiceProvider) SetGroupName(groupName string)
func (*NacosWRRServiceProvider) SetNamingClient ¶ added in v1.0.1
func (b *NacosWRRServiceProvider) SetNamingClient(namingClient naming_client.INamingClient)
type ProxyConfig ¶ added in v1.1.1
type ProxyTarget ¶ added in v1.1.1
type ServiceProvider ¶
type ServiceProvider struct {
// contains filtered or unexported fields
}
ServiceProvider defines an implementation for IServiceProvider
func NewServiceProvider ¶
func NewServiceProvider(env string) *ServiceProvider
NewServiceProvider creates new ServiceProvider instance
func (*ServiceProvider) SelectServer ¶
func (s *ServiceProvider) SelectServer() string
SelectServer return service address from environment variable
type SmoothWeightedRoundRobinProvider ¶
type SmoothWeightedRoundRobinProvider struct {
// contains filtered or unexported fields
}
SmoothWeightedRoundRobinProvider is a smooth weighted round-robin algo implementation for IServiceProvider https://github.com/nginx/nginx/commit/52327e0627f49dbda1e8db695e63a4b0af4448b1
func NewSmoothWeightedRoundRobinProvider ¶
func NewSmoothWeightedRoundRobinProvider(name string) *SmoothWeightedRoundRobinProvider
NewSmoothWeightedRoundRobinProvider create an SmoothWeightedRoundRobinProvider instance
func (*SmoothWeightedRoundRobinProvider) AddNode ¶
func (m *SmoothWeightedRoundRobinProvider) AddNode(node *memberlist.Node)
AddNode add or update node providing the service
func (*SmoothWeightedRoundRobinProvider) GetServer ¶ added in v1.0.6
func (m *SmoothWeightedRoundRobinProvider) GetServer(nodeName string) *server
func (*SmoothWeightedRoundRobinProvider) RemoveNode ¶
func (m *SmoothWeightedRoundRobinProvider) RemoveNode(node *memberlist.Node)
func (*SmoothWeightedRoundRobinProvider) SelectServer ¶
func (m *SmoothWeightedRoundRobinProvider) SelectServer() string
SelectServer selects a node which is supplying service specified by name property from cluster
func (*SmoothWeightedRoundRobinProvider) UpdateWeight ¶
func (m *SmoothWeightedRoundRobinProvider) UpdateWeight(node *memberlist.Node)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package httprouter is a trie based high performance HTTP request router.
|
Package httprouter is a trie based high performance HTTP request router. |
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |