impl

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

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

View Source
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"
)
View Source
const (
	HYSTRIX_CONSUMER = "hystrix_consumer"
	HYSTRIX_PROVIDER = "hystrix_provider"
	HYSTRIX          = "hystrix"
)
View Source
const (
	ECHO = "echo"
)
View Source
const (
	GENERIC = "generic"
)
View Source
const (
	TOKEN = "token"
)
View Source
const (
	TpsLimitFilterKey = "tps"
)

Variables

This section is empty.

Functions

func GetAccessLogFilter added in v1.2.0

func GetAccessLogFilter() filter.Filter

func GetActiveFilter

func GetActiveFilter() filter.Filter

func GetExecuteLimitFilter added in v1.2.0

func GetExecuteLimitFilter() filter.Filter

func GetFilter

func GetFilter() filter.Filter

func GetGenericFilter added in v1.2.0

func GetGenericFilter() filter.Filter

func GetHystrixFilterConsumer added in v1.2.0

func GetHystrixFilterConsumer() filter.Filter

func GetHystrixFilterProvider added in v1.2.0

func GetHystrixFilterProvider() filter.Filter

func GetTokenFilter added in v1.2.0

func GetTokenFilter() filter.Filter

func GetTpsLimitFilter added in v1.2.0

func GetTpsLimitFilter() filter.Filter

func NewHystrixFilterError added in v1.2.0

func NewHystrixFilterError(err error, failByHystrix bool) error

Types

type AccessLogData added in v1.2.0

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

type AccessLogFilter added in v1.2.0

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 added in v1.2.0

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

func (*AccessLogFilter) OnResponse added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

func (ef *ExecuteLimitFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

func (*ExecuteLimitFilter) OnResponse added in v1.2.0

func (ef *ExecuteLimitFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

type ExecuteState added in v1.2.0

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

type GenericFilter added in v1.2.0

type GenericFilter struct{}

func (*GenericFilter) Invoke added in v1.2.0

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

func (*GenericFilter) OnResponse added in v1.2.0

func (ef *GenericFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

type HystrixFilter added in v1.2.0

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

func (*HystrixFilter) Invoke added in v1.2.0

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

func (*HystrixFilter) OnResponse added in v1.2.0

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

type HystrixFilterConfig added in v1.2.0

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

type HystrixFilterError added in v1.2.0

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

func (*HystrixFilterError) Error added in v1.2.0

func (hfError *HystrixFilterError) Error() string

func (*HystrixFilterError) FailByHystrix added in v1.2.0

func (hfError *HystrixFilterError) FailByHystrix() bool

type ServiceHystrixConfig added in v1.2.0

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

type TokenFilter added in v1.2.0

type TokenFilter struct{}

func (*TokenFilter) Invoke added in v1.2.0

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

func (*TokenFilter) OnResponse added in v1.2.0

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

type TpsLimitFilter added in v1.2.0

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 added in v1.2.0

func (t TpsLimitFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

func (TpsLimitFilter) OnResponse added in v1.2.0

func (t TpsLimitFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result

Directories

Path Synopsis
tps
impl
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