Documentation ¶
Overview ¶
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
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 ( //used in URL. FileDateFormat = "2006-01-02" MessageDateLayout = "2006-01-02 15:04:05" LogMaxBuffer = 5000 LogFileMode = 0600 // those fields are the data collected by this filter Types = "types" Arguments = "arguments" )
const ( GENERIC_SERVICE = "generic_service" GENERIC_SERIALIZATION_DEFAULT = "true" )
const ( HYSTRIX_CONSUMER = "hystrix_consumer" HYSTRIX_PROVIDER = "hystrix_provider" HYSTRIX = "hystrix" )
const (
ECHO = "echo"
)
const (
GENERIC = "generic"
)
const (
TOKEN = "token"
)
const (
TpsLimitFilterKey = "tps"
)
Variables ¶
This section is empty.
Functions ¶
func GetAccessLogFilter ¶
func GetActiveFilter ¶
func GetExecuteLimitFilter ¶
func GetGenericFilter ¶
func GetGenericServiceFilter ¶
func GetTokenFilter ¶
func GetTpsLimitFilter ¶
func NewHystrixFilterError ¶
Types ¶
type AccessLogData ¶
type AccessLogData struct {
// contains filtered or unexported fields
}
type AccessLogFilter ¶
type AccessLogFilter struct {
// contains filtered or unexported fields
}
* 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(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (*AccessLogFilter) OnResponse ¶
func (ef *AccessLogFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
type ActiveFilter ¶
type ActiveFilter struct { }
func (*ActiveFilter) Invoke ¶
func (ef *ActiveFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (*ActiveFilter) OnResponse ¶
func (ef *ActiveFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
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"` }
type EchoFilter ¶
type EchoFilter struct{}
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(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (*EchoFilter) OnResponse ¶
func (ef *EchoFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
type ExecuteLimitFilter ¶
type ExecuteLimitFilter struct {
// contains filtered or unexported fields
}
*
- 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(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (*ExecuteLimitFilter) OnResponse ¶
func (ef *ExecuteLimitFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
type ExecuteState ¶
type ExecuteState struct {
// contains filtered or unexported fields
}
type GenericFilter ¶
type GenericFilter struct{}
func (*GenericFilter) Invoke ¶
func (ef *GenericFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (*GenericFilter) OnResponse ¶
func (ef *GenericFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
type GenericServiceFilter ¶
type GenericServiceFilter struct{}
func (*GenericServiceFilter) Invoke ¶
func (ef *GenericServiceFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (*GenericServiceFilter) OnResponse ¶
func (ef *GenericServiceFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
type HystrixFilter ¶
type HystrixFilter struct { COrP bool //true for consumer // contains filtered or unexported fields }
func (*HystrixFilter) Invoke ¶
func (hf *HystrixFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (*HystrixFilter) OnResponse ¶
func (hf *HystrixFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
type HystrixFilterConfig ¶
type HystrixFilterConfig struct { Configs map[string]*CommandConfigWithError Default string Services map[string]ServiceHystrixConfig }
type HystrixFilterError ¶
type HystrixFilterError struct {
// contains filtered or unexported fields
}
func (*HystrixFilterError) Error ¶
func (hfError *HystrixFilterError) Error() string
func (*HystrixFilterError) FailByHystrix ¶
func (hfError *HystrixFilterError) FailByHystrix() bool
type ServiceHystrixConfig ¶
type TokenFilter ¶
type TokenFilter struct{}
func (*TokenFilter) Invoke ¶
func (tf *TokenFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (*TokenFilter) OnResponse ¶
func (tf *TokenFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
type TpsLimitFilter ¶
type TpsLimitFilter struct { }
*
- 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(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result
func (TpsLimitFilter) OnResponse ¶
func (t TpsLimitFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result