Documentation ¶
Index ¶
- Constants
- func GetAccessLogFilter() filter.Filter
- func GetActiveFilter() filter.Filter
- func GetExecuteLimitFilter() filter.Filter
- func GetFilter() filter.Filter
- func GetGenericFilter() filter.Filter
- func GetGenericServiceFilter() filter.Filter
- func GetHystrixFilterConsumer() filter.Filter
- func GetHystrixFilterProvider() filter.Filter
- func GetTokenFilter() filter.Filter
- func GetTpsLimitFilter() filter.Filter
- func NewHystrixFilterError(err error, failByHystrix bool) error
- type AccessLogData
- type AccessLogFilter
- type ActiveFilter
- type CommandConfigWithError
- type EchoFilter
- type ExecuteLimitFilter
- type ExecuteState
- type GenericFilter
- type GenericServiceFilter
- type HystrixFilter
- type HystrixFilterConfig
- type HystrixFilterError
- type ServiceHystrixConfig
- type TokenFilter
- type TpsLimitFilter
Constants ¶
const ( // FileDateFormat ... FileDateFormat = "2006-01-02" // MessageDateLayout ... MessageDateLayout = "2006-01-02 15:04:05" // LogMaxBuffer ... LogMaxBuffer = 5000 // LogFileMode ... LogFileMode = 0600 // Types ... Types = "types" // Arguments ... Arguments = "arguments" )
const ( // GENERIC_SERVICE ... GENERIC_SERVICE = "generic_service" // GENERIC_SERIALIZATION_DEFAULT ... GENERIC_SERIALIZATION_DEFAULT = "true" )
const ( // HYSTRIX_CONSUMER ... HYSTRIX_CONSUMER = "hystrix_consumer" // HYSTRIX_PROVIDER ... HYSTRIX_PROVIDER = "hystrix_provider" // HYSTRIX ... HYSTRIX = "hystrix" )
const (
// ECHO echo module name
ECHO = "echo"
)
const ( // GENERIC //generic module name GENERIC = "generic" )
const (
// TOKEN ...
TOKEN = "token"
)
const (
// TpsLimitFilterKey key
TpsLimitFilterKey = "tps"
)
Variables ¶
This section is empty.
Functions ¶
func GetGenericServiceFilter ¶
GetGenericServiceFilter ...
func GetHystrixFilterConsumer ¶
GetHystrixFilterConsumer ...
func GetHystrixFilterProvider ¶
GetHystrixFilterProvider ...
func NewHystrixFilterError ¶
NewHystrixFilterError ...
Types ¶
type AccessLogData ¶
type AccessLogData struct {
// contains filtered or unexported fields
}
AccessLogData ...
type AccessLogFilter ¶
type AccessLogFilter struct {
// contains filtered or unexported fields
}
* AccessLogFilter * Although the access log filter is a default filter, * you should config "accesslog" in service's config to tell the filter where store the access log. * for example: * "UserProvider": * registry: "hangzhouzk" * protocol : "dubbo" * interface : "com.ikurento.user.UserProvider" * ... # other configuration * accesslog: "/your/path/to/store/the/log/", # it should be the path of file. * * the value of "accesslog" can be "true" or "default" too. * If the value is one of them, the access log will be record in log file which defined in log.yml
func (*AccessLogFilter) Invoke ¶
func (ef *AccessLogFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (*AccessLogFilter) OnResponse ¶
func (ef *AccessLogFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, _ protocol.Invocation) protocol.Result
OnResponse ...
type ActiveFilter ¶
type ActiveFilter struct { }
ActiveFilter ...
func (*ActiveFilter) Invoke ¶
func (ef *ActiveFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (*ActiveFilter) OnResponse ¶
func (ef *ActiveFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
OnResponse ...
type CommandConfigWithError ¶
type CommandConfigWithError struct { Timeout int `yaml:"timeout"` MaxConcurrentRequests int `yaml:"max_concurrent_requests"` RequestVolumeThreshold int `yaml:"request_volume_threshold"` SleepWindow int `yaml:"sleep_window"` ErrorPercentThreshold int `yaml:"error_percent_threshold"` Error []string `yaml:"error_whitelist"` }
CommandConfigWithError ...
type EchoFilter ¶
type EchoFilter struct{}
EchoFilter RPCService need a Echo method in consumer, if you want to use EchoFilter eg:
Echo func(ctx context.Context, arg interface{}, rsp *Xxx) error
func (*EchoFilter) Invoke ¶
func (ef *EchoFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (*EchoFilter) OnResponse ¶
func (ef *EchoFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, _ protocol.Invocation) protocol.Result
OnResponse ...
type ExecuteLimitFilter ¶
type ExecuteLimitFilter struct {
// contains filtered or unexported fields
}
*
- ExecuteLimitFilter
- The filter will limit the number of in-progress request and it's thread-safe.
- example:
- "UserProvider":
- registry: "hangzhouzk"
- protocol : "dubbo"
- interface : "com.ikurento.user.UserProvider"
- ... # other configuration
- execute.limit: 200 # the name of MethodServiceTpsLimiterImpl. if the value < 0, invocation will be ignored.
- execute.limit.rejected.handle: "default" # the name of rejected handler
- methods:
- - name: "GetUser"
- execute.limit: 20, # in this case, this configuration in service-level will be ignored.
- - name: "UpdateUser"
- execute.limit: -1, # If the rate<0, the method will be ignored
- - name: "DeleteUser"
- execute.limit.rejected.handle: "customHandler" # Using the custom handler to do something when the request was rejected.
- - name: "AddUser"
- From the example, the configuration in service-level is 200, and the configuration of method GetUser is 20.
- it means that, the GetUser will be counted separately.
- The configuration of method UpdateUser is -1, so the invocation for it will not be counted.
- So the method DeleteUser and method AddUser will be limited by service-level configuration.
- Sometimes we want to do something, like log the request or return default value when the request is over limitation.
- Then you can implement the RejectedExecutionHandler interface and register it by invoking SetRejectedExecutionHandler.
func (*ExecuteLimitFilter) Invoke ¶
func (ef *ExecuteLimitFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (*ExecuteLimitFilter) OnResponse ¶
func (ef *ExecuteLimitFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, _ protocol.Invocation) protocol.Result
OnResponse ...
type ExecuteState ¶
type ExecuteState struct {
// contains filtered or unexported fields
}
ExecuteState ...
type GenericFilter ¶
type GenericFilter struct{}
GenericFilter ...
func (*GenericFilter) Invoke ¶
func (ef *GenericFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (*GenericFilter) OnResponse ¶
func (ef *GenericFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, _ protocol.Invocation) protocol.Result
OnResponse ...
type GenericServiceFilter ¶
type GenericServiceFilter struct{}
GenericServiceFilter ...
func (*GenericServiceFilter) Invoke ¶
func (ef *GenericServiceFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (*GenericServiceFilter) OnResponse ¶
func (ef *GenericServiceFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
OnResponse ...
type HystrixFilter ¶
type HystrixFilter struct { COrP bool //true for consumer // contains filtered or unexported fields }
HystrixFilter ...
func (*HystrixFilter) Invoke ¶
func (hf *HystrixFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (*HystrixFilter) OnResponse ¶
func (hf *HystrixFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
OnResponse ...
type HystrixFilterConfig ¶
type HystrixFilterConfig struct { Configs map[string]*CommandConfigWithError Default string Services map[string]ServiceHystrixConfig }
HystrixFilterConfig ...
type HystrixFilterError ¶
type HystrixFilterError struct {
// contains filtered or unexported fields
}
HystrixFilterError ...
func (*HystrixFilterError) Error ¶
func (hfError *HystrixFilterError) Error() string
func (*HystrixFilterError) FailByHystrix ¶
func (hfError *HystrixFilterError) FailByHystrix() bool
FailByHystrix ...
type ServiceHystrixConfig ¶
type ServiceHystrixConfig struct { ServiceConfig string `yaml:"service_config"` Methods map[string]string }
ServiceHystrixConfig ...
type TokenFilter ¶
type TokenFilter struct{}
TokenFilter ...
func (*TokenFilter) Invoke ¶
func (tf *TokenFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (*TokenFilter) OnResponse ¶
func (tf *TokenFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
OnResponse ...
type TpsLimitFilter ¶
type TpsLimitFilter struct { }
*
- TpsLimitFilter
- if you wish to use the TpsLimiter, please add the configuration into your service provider configuration:
- for example:
- "UserProvider":
- registry: "hangzhouzk"
- protocol : "dubbo"
- interface : "com.ikurento.user.UserProvider"
- ... # other configuration
- tps.limiter: "method-service", # it should be the name of limiter. if the value is 'default',
- # the MethodServiceTpsLimiterImpl will be used.
- tps.limit.rejected.handler: "default", # optional, or the name of the implementation
- if the value of 'tps.limiter' is nil or empty string, the tps filter will do nothing
func (TpsLimitFilter) Invoke ¶
func (t TpsLimitFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
Invoke ...
func (TpsLimitFilter) OnResponse ¶
func (t TpsLimitFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, _ protocol.Invocation) protocol.Result
OnResponse ...