filter_impl

package
v1.5.7-rc1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: Apache-2.0 Imports: 32 Imported by: 162

Documentation

Index

Constants

View Source
const (

	// nolint
	FileDateFormat = "2006-01-02"
	// nolint
	MessageDateLayout = "2006-01-02 15:04:05"
	// nolint
	LogMaxBuffer = 5000
	// nolint
	LogFileMode = 0600

	// nolint
	Types = "types"
	// nolint
	Arguments = "arguments"
)
View Source
const (
	// GENERIC_SERVICE defines the filter name
	GENERIC_SERVICE = "generic_service"
	// nolint
	GENERIC_SERIALIZATION_DEFAULT = "true"
)
View Source
const (
	// nolint
	HYSTRIX_CONSUMER = "hystrix_consumer"
	// nolint
	HYSTRIX_PROVIDER = "hystrix_provider"
	// nolint
	HYSTRIX = "hystrix"
)
View Source
const (
	SEATA     = constant.DubboCtxKey("seata")
	SEATA_XID = constant.DubboCtxKey("SEATA_XID")
)
View Source
const (
	SentinelProviderFilterName = "sentinel-provider"
	SentinelConsumerFilterName = "sentinel-consumer"

	DefaultProviderPrefix = "dubbo:provider:"
	DefaultConsumerPrefix = "dubbo:consumer:"

	MethodEntryKey    = constant.DubboCtxKey("$$sentinelMethodEntry")
	InterfaceEntryKey = constant.DubboCtxKey("$$sentinelInterfaceEntry")
)
View Source
const (
	// ECHO echo module name
	ECHO = "echo"
)
View Source
const (
	// GENERIC
	//generic module name
	GENERIC = "generic"
)
View Source
const (
	// nolint
	TOKEN = "token"
)
View Source
const (
	// TpsLimitFilterKey key
	TpsLimitFilterKey = "tps"
)

Variables

This section is empty.

Functions

func GetAccessLogFilter

func GetAccessLogFilter() filter.Filter

GetAccessLogFilter return the instance of AccessLogFilter

func GetActiveFilter

func GetActiveFilter() filter.Filter

GetActiveFilter creates ActiveFilter instance

func GetExecuteLimitFilter

func GetExecuteLimitFilter() filter.Filter

GetExecuteLimitFilter returns the singleton ExecuteLimitFilter instance

func GetFilter

func GetFilter() filter.Filter

GetFilter gets the Filter

func GetGenericFilter

func GetGenericFilter() filter.Filter

GetGenericFilter returns GenericFilter instance

func GetGenericServiceFilter

func GetGenericServiceFilter() filter.Filter

nolint

func GetHystrixFilterConsumer

func GetHystrixFilterConsumer() filter.Filter

GetHystrixFilterConsumer returns HystrixFilter instance for consumer

func GetHystrixFilterProvider

func GetHystrixFilterProvider() filter.Filter

GetHystrixFilterProvider returns HystrixFilter instance for provider

func GetSentinelConsumerFilter added in v1.5.3

func GetSentinelConsumerFilter() filter.Filter

func GetSentinelProviderFilter added in v1.5.3

func GetSentinelProviderFilter() filter.Filter

func GetTokenFilter

func GetTokenFilter() filter.Filter

nolint

func GetTpsLimitFilter

func GetTpsLimitFilter() filter.Filter

GetTpsLimitFilter returns an TpsLimitFilter instance.

func NewHystrixFilterError

func NewHystrixFilterError(err error, failByHystrix bool) error

NewHystrixFilterError return a HystrixFilterError instance

func SetDubboConsumerFallback added in v1.5.3

func SetDubboConsumerFallback(f DubboFallback)

func SetDubboProviderFallback added in v1.5.3

func SetDubboProviderFallback(f DubboFallback)

Types

type AccessLogData

type AccessLogData struct {
	// contains filtered or unexported fields
}

AccessLogData defines the data that will be log into file

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 * AccessLogFilter is designed to be singleton

func (*AccessLogFilter) Invoke

func (ef *AccessLogFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

Invoke will check whether user wants to use this filter. If we find the value of key constant.ACCESS_LOG_KEY, we will log the invocation info

func (*AccessLogFilter) OnResponse

OnResponse do nothing

type ActiveFilter

type ActiveFilter struct {
}

ActiveFilter tracks the requests status

func (*ActiveFilter) Invoke

func (ef *ActiveFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

Invoke starts to record the requests status

func (*ActiveFilter) OnResponse

func (ef *ActiveFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

OnResponse update the active count base on the request 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"`
}

nolint

type DubboFallback added in v1.5.3

type DubboLoggerWrapper added in v1.5.3

type DubboLoggerWrapper struct {
	logger.Logger
}

func (DubboLoggerWrapper) Debug added in v1.5.6

func (d DubboLoggerWrapper) Debug(msg string, keysAndValues ...interface{})

func (DubboLoggerWrapper) DebugEnabled added in v1.5.6

func (d DubboLoggerWrapper) DebugEnabled() bool

func (DubboLoggerWrapper) Error added in v1.5.6

func (d DubboLoggerWrapper) Error(err error, msg string, keysAndValues ...interface{})

func (DubboLoggerWrapper) ErrorEnabled added in v1.5.6

func (d DubboLoggerWrapper) ErrorEnabled() bool

func (DubboLoggerWrapper) Info added in v1.5.6

func (d DubboLoggerWrapper) Info(msg string, keysAndValues ...interface{})

func (DubboLoggerWrapper) InfoEnabled added in v1.5.6

func (d DubboLoggerWrapper) InfoEnabled() bool

func (DubboLoggerWrapper) Warn added in v1.5.6

func (d DubboLoggerWrapper) Warn(msg string, keysAndValues ...interface{})

func (DubboLoggerWrapper) WarnEnabled added in v1.5.6

func (d DubboLoggerWrapper) WarnEnabled() bool

type EchoFilter

type EchoFilter struct{}

EchoFilter health check 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 response to the callers with its first argument.

func (*EchoFilter) OnResponse

OnResponse dummy process, returns the result directly

type ExecuteLimitFilter

type ExecuteLimitFilter struct {
	// contains filtered or unexported fields
}

ExecuteLimitFilter 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 judges whether the current processing requests over the threshold

func (*ExecuteLimitFilter) OnResponse

OnResponse dummy process, returns the result directly

type ExecuteState

type ExecuteState struct {
	// contains filtered or unexported fields
}

ExecuteState defines the concurrent count

type GenericFilter

type GenericFilter struct{}

nolint

func (*GenericFilter) Invoke

func (ef *GenericFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

Invoke turns the parameters to map for generic method

func (*GenericFilter) OnResponse

OnResponse dummy process, returns the result directly

type GenericServiceFilter

type GenericServiceFilter struct{}

nolint

func (*GenericServiceFilter) Invoke

func (ef *GenericServiceFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

Invoke is used to call service method by invocation

func (*GenericServiceFilter) OnResponse

func (ef *GenericServiceFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

nolint

type HystrixFilter

type HystrixFilter struct {
	COrP bool //true for consumer
	// contains filtered or unexported fields
}

*

  • HystrixFilter
  • You should add hystrix related configuration in provider or consumer config or both, according to which side you are to apply HystrixFilter.
  • For example:
  • filter_conf:
  • hystrix:
  • configs:
  • # =========== Define config here ============
  • "Default":
  • timeout : 1000
  • max_concurrent_requests : 25
  • sleep_window : 5000
  • error_percent_threshold : 50
  • request_volume_threshold: 20
  • "userp":
  • timeout: 2000
  • max_concurrent_requests: 512
  • sleep_window: 4000
  • error_percent_threshold: 35
  • request_volume_threshold: 6
  • "userp_m":
  • timeout : 1200
  • max_concurrent_requests : 512
  • sleep_window : 6000
  • error_percent_threshold : 60
  • request_volume_threshold: 16
  • # =========== Define error whitelist which will be ignored by Hystrix counter ============
  • error_whitelist: [".*exception.*"] *
  • # =========== Apply default config here ===========
  • default: "Default" *
  • services:
  • "com.ikurento.user.UserProvider":
  • # =========== Apply service level config ===========
  • service_config: "userp"
  • # =========== Apply method level config ===========
  • methods:
  • "GetUser": "userp_m"
  • "GetUser1": "userp_m"

func (*HystrixFilter) Invoke

func (hf *HystrixFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

Invoke is an implementation of filter, provides Hystrix pattern latency and fault tolerance

func (*HystrixFilter) OnResponse

func (hf *HystrixFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

OnResponse dummy process, returns the result directly

type HystrixFilterConfig

type HystrixFilterConfig struct {
	Configs  map[string]*CommandConfigWithError
	Default  string
	Services map[string]ServiceHystrixConfig
}

nolint

type HystrixFilterError

type HystrixFilterError struct {
	// contains filtered or unexported fields
}

HystrixFilterError implements error interface

func (*HystrixFilterError) Error

func (hfError *HystrixFilterError) Error() string

func (*HystrixFilterError) FailByHystrix

func (hfError *HystrixFilterError) FailByHystrix() bool

FailByHystrix returns whether the fails causing by Hystrix

type SeataFilter added in v1.5.1

type SeataFilter struct{}

SeataFilter when use seata-golang, use this filter to transfer xid

func (*SeataFilter) Invoke added in v1.5.1

func (sf *SeataFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

When use Seata, transfer xid by attachments Invoke Get Xid by attachment key `SEATA_XID`

func (*SeataFilter) OnResponse added in v1.5.1

func (sf *SeataFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

OnResponse dummy process, returns the result directly

type SentinelConsumerFilter added in v1.5.3

type SentinelConsumerFilter struct{}

func (*SentinelConsumerFilter) Invoke added in v1.5.3

func (*SentinelConsumerFilter) OnResponse added in v1.5.3

type SentinelProviderFilter added in v1.5.3

type SentinelProviderFilter struct{}

func (*SentinelProviderFilter) Invoke added in v1.5.3

func (*SentinelProviderFilter) OnResponse added in v1.5.3

type ServiceHystrixConfig

type ServiceHystrixConfig struct {
	ServiceConfig string `yaml:"service_config"`
	Methods       map[string]string
}

nolint

type TokenFilter

type TokenFilter struct{}

TokenFilter will verify if the token is valid

func (*TokenFilter) Invoke

func (tf *TokenFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

Invoke verifies the incoming token with the service configured token

func (*TokenFilter) OnResponse

func (tf *TokenFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

OnResponse dummy process, returns the result directly

type TpsLimitFilter

type TpsLimitFilter struct {
}

TpsLimitFilter filters the requests by TPS *

  • 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 gets the configured limter to impose TPS limiting

func (TpsLimitFilter) OnResponse

OnResponse dummy process, returns the result directly

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