filter_impl

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2020 License: Apache-2.0 Imports: 29 Imported by: 162

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	// GENERIC_SERVICE ...
	GENERIC_SERVICE = "generic_service"
	// GENERIC_SERIALIZATION_DEFAULT ...
	GENERIC_SERIALIZATION_DEFAULT = "true"
)
View Source
const (
	// HYSTRIX_CONSUMER ...
	HYSTRIX_CONSUMER = "hystrix_consumer"
	// HYSTRIX_PROVIDER ...
	HYSTRIX_PROVIDER = "hystrix_provider"
	// HYSTRIX ...
	HYSTRIX = "hystrix"
)
View Source
const (
	// ECHO echo module name
	ECHO = "echo"
)
View Source
const (
	// GENERIC
	//generic module name
	GENERIC = "generic"
)
View Source
const (
	// TOKEN ...
	TOKEN = "token"
)
View Source
const (
	// TpsLimitFilterKey key
	TpsLimitFilterKey = "tps"
)

Variables

This section is empty.

Functions

func GetAccessLogFilter

func GetAccessLogFilter() filter.Filter

GetAccessLogFilter ...

func GetActiveFilter

func GetActiveFilter() filter.Filter

GetActiveFilter ...

func GetExecuteLimitFilter

func GetExecuteLimitFilter() filter.Filter

GetExecuteLimitFilter ...

func GetFilter

func GetFilter() filter.Filter

GetFilter ...

func GetGenericFilter

func GetGenericFilter() filter.Filter

GetGenericFilter ...

func GetGenericServiceFilter

func GetGenericServiceFilter() filter.Filter

GetGenericServiceFilter ...

func GetHystrixFilterConsumer

func GetHystrixFilterConsumer() filter.Filter

GetHystrixFilterConsumer ...

func GetHystrixFilterProvider

func GetHystrixFilterProvider() filter.Filter

GetHystrixFilterProvider ...

func GetTokenFilter

func GetTokenFilter() filter.Filter

GetTokenFilter ...

func GetTpsLimitFilter

func GetTpsLimitFilter() filter.Filter

GetTpsLimitFilter ...

func NewHystrixFilterError

func NewHystrixFilterError(err error, failByHystrix bool) error

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

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

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

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

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

OnResponse ...

Directories

Path Synopsis
Package filter is a generated GoMock package.
Package filter is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL