Documentation ¶
Overview ¶
Package filter is some default filter implements.
Index ¶
- Constants
- Variables
- func DefaultTraceRecordingFunc(span ot.Span, data *CallData)
- func GetRateLimitSwitcherName(url *core.URL) string
- func RegistDefaultFilters(extFactory motan.ExtensionFactory)
- type AccessLogFilter
- func (t *AccessLogFilter) Filter(caller motan.Caller, request motan.Request) motan.Response
- func (t *AccessLogFilter) GetIndex() int
- func (t *AccessLogFilter) GetName() string
- func (t *AccessLogFilter) GetNext() motan.EndPointFilter
- func (t *AccessLogFilter) GetType() int32
- func (t *AccessLogFilter) HasNext() bool
- func (t *AccessLogFilter) NewFilter(url *motan.URL) motan.Filter
- func (t *AccessLogFilter) SetNext(nextFilter motan.EndPointFilter)
- type AttachmentReader
- type AttachmentWriter
- type CallData
- type CircuitBreakerFilter
- func (c *CircuitBreakerFilter) Filter(caller motan.Caller, request motan.Request) motan.Response
- func (c *CircuitBreakerFilter) GetIndex() int
- func (c *CircuitBreakerFilter) GetName() string
- func (c *CircuitBreakerFilter) GetNext() motan.EndPointFilter
- func (c *CircuitBreakerFilter) GetType() int32
- func (c *CircuitBreakerFilter) HasNext() bool
- func (c *CircuitBreakerFilter) NewFilter(url *motan.URL) motan.Filter
- func (c *CircuitBreakerFilter) SetNext(nextFilter motan.EndPointFilter)
- type ClusterAccessLogFilter
- func (t *ClusterAccessLogFilter) Filter(haStrategy motan.HaStrategy, loadBalance motan.LoadBalance, ...) motan.Response
- func (t *ClusterAccessLogFilter) GetIndex() int
- func (t *ClusterAccessLogFilter) GetName() string
- func (t *ClusterAccessLogFilter) GetNext() motan.ClusterFilter
- func (t *ClusterAccessLogFilter) GetType() int32
- func (t *ClusterAccessLogFilter) HasNext() bool
- func (t *ClusterAccessLogFilter) NewFilter(url *motan.URL) motan.Filter
- func (t *ClusterAccessLogFilter) SetNext(nextFilter motan.ClusterFilter)
- type ClusterCircuitBreakerFilter
- func (c *ClusterCircuitBreakerFilter) Filter(ha motan.HaStrategy, lb motan.LoadBalance, request motan.Request) motan.Response
- func (c *ClusterCircuitBreakerFilter) GetIndex() int
- func (c *ClusterCircuitBreakerFilter) GetName() string
- func (c *ClusterCircuitBreakerFilter) GetNext() motan.ClusterFilter
- func (c *ClusterCircuitBreakerFilter) GetType() int32
- func (c *ClusterCircuitBreakerFilter) HasNext() bool
- func (c *ClusterCircuitBreakerFilter) NewFilter(url *motan.URL) motan.Filter
- func (c *ClusterCircuitBreakerFilter) SetNext(cf motan.ClusterFilter)
- type ClusterMetricsFilter
- func (c *ClusterMetricsFilter) Filter(haStrategy motan.HaStrategy, loadBalance motan.LoadBalance, ...) motan.Response
- func (c *ClusterMetricsFilter) GetIndex() int
- func (c *ClusterMetricsFilter) GetName() string
- func (c *ClusterMetricsFilter) GetNext() motan.ClusterFilter
- func (c *ClusterMetricsFilter) GetType() int32
- func (c *ClusterMetricsFilter) HasNext() bool
- func (c *ClusterMetricsFilter) NewFilter(url *motan.URL) motan.Filter
- func (c *ClusterMetricsFilter) SetNext(cf motan.ClusterFilter)
- type FailfastFilter
- func (e *FailfastFilter) Filter(caller motan.Caller, request motan.Request) motan.Response
- func (e *FailfastFilter) GetIndex() int
- func (e *FailfastFilter) GetName() string
- func (e *FailfastFilter) GetNext() motan.EndPointFilter
- func (e *FailfastFilter) GetType() int32
- func (e *FailfastFilter) HasNext() bool
- func (e *FailfastFilter) IsAvailable() bool
- func (e *FailfastFilter) NewFilter(url *motan.URL) motan.Filter
- func (e *FailfastFilter) SetNext(nextFilter motan.EndPointFilter)
- type MetricsFilter
- func (m *MetricsFilter) Filter(caller motan.Caller, request motan.Request) motan.Response
- func (m *MetricsFilter) GetIndex() int
- func (m *MetricsFilter) GetName() string
- func (m *MetricsFilter) GetNext() motan.EndPointFilter
- func (m *MetricsFilter) GetType() int32
- func (m *MetricsFilter) HasNext() bool
- func (m *MetricsFilter) NewFilter(url *motan.URL) motan.Filter
- func (m *MetricsFilter) SetContext(context *motan.Context)
- func (m *MetricsFilter) SetNext(e motan.EndPointFilter)
- type RateLimitFilter
- func (r *RateLimitFilter) Filter(caller core.Caller, request core.Request) core.Response
- func (r *RateLimitFilter) GetIndex() int
- func (r *RateLimitFilter) GetName() string
- func (r *RateLimitFilter) GetNext() core.EndPointFilter
- func (r *RateLimitFilter) GetType() int32
- func (r *RateLimitFilter) HasNext() bool
- func (r *RateLimitFilter) NewFilter(url *core.URL) core.Filter
- func (r *RateLimitFilter) SetNext(nextFilter core.EndPointFilter)
- type TracingFilter
- func (t *TracingFilter) Filter(caller core.Caller, request core.Request) core.Response
- func (*TracingFilter) GetIndex() int
- func (*TracingFilter) GetName() string
- func (t *TracingFilter) GetNext() core.EndPointFilter
- func (*TracingFilter) GetType() int32
- func (t *TracingFilter) HasNext() bool
- func (t *TracingFilter) NewFilter(url *core.URL) core.Filter
- func (t *TracingFilter) SetNext(nextFilter core.EndPointFilter)
Constants ¶
const ( RequestVolumeThresholdField = "circuitBreaker.requestThreshold" SleepWindowField = "circuitBreaker.sleepWindow" //ms ErrorPercentThreshold = "circuitBreaker.errorPercent" //% IncludeBizException = "circuitBreaker.bizException" )
const ( // endpoint filter AccessLog = "accessLog" Metrics = "metrics" CircuitBreaker = "circuitBreaker" FailFast = "failfast" Trace = "trace" RateLimit = "rateLimit" // cluster filter ClusterAccessLog = "clusterAccessLog" ClusterMetrics = "clusterMetrics" ClusterCircuitBreaker = "clusterCircuitBreaker" )
ext name
const ( MetricsTotalCountSuffix = ".total_count" MetricsTotalCountSuffixLen = len(MetricsTotalCountSuffix) MetricsBizErrorCountSuffix = ".biz_error_count" MetricsOtherErrorCountSuffix = ".other_error_count" MetricsSlowCountSuffix = ".slow_count" )
const ( InBoundCall = iota OutBoundCall )
Variables ¶
var TraceRecordingFunc func(span ot.Span, data *CallData)
TraceRecordingFunc record tracing data, default is DefaultTraceRecordingFunc, Users can rewrite it, and can embed the DefaultTraceRecordingFunc in the Custom Recording Function.
Functions ¶
func DefaultTraceRecordingFunc ¶
DefaultTraceRecordingFunc is the default TraceRecordingFunc.
func RegistDefaultFilters ¶
func RegistDefaultFilters(extFactory motan.ExtensionFactory)
Types ¶
type AccessLogFilter ¶
type AccessLogFilter struct {
// contains filtered or unexported fields
}
func (*AccessLogFilter) GetIndex ¶
func (t *AccessLogFilter) GetIndex() int
func (*AccessLogFilter) GetName ¶
func (t *AccessLogFilter) GetName() string
func (*AccessLogFilter) GetNext ¶
func (t *AccessLogFilter) GetNext() motan.EndPointFilter
func (*AccessLogFilter) GetType ¶
func (t *AccessLogFilter) GetType() int32
func (*AccessLogFilter) HasNext ¶
func (t *AccessLogFilter) HasNext() bool
func (*AccessLogFilter) NewFilter ¶
func (t *AccessLogFilter) NewFilter(url *motan.URL) motan.Filter
func (*AccessLogFilter) SetNext ¶
func (t *AccessLogFilter) SetNext(nextFilter motan.EndPointFilter)
type AttachmentReader ¶
type AttachmentReader struct {
// contains filtered or unexported fields
}
AttachmentReader is used to read the Attachment. use value type, to decrease the number of escaped variables
func (AttachmentReader) ForeachKey ¶
func (a AttachmentReader) ForeachKey(handler func(key, val string) error) error
type AttachmentWriter ¶
type AttachmentWriter struct {
// contains filtered or unexported fields
}
func (AttachmentWriter) Set ¶
func (a AttachmentWriter) Set(key, val string)
type CircuitBreakerFilter ¶
type CircuitBreakerFilter struct {
// contains filtered or unexported fields
}
func (*CircuitBreakerFilter) GetIndex ¶
func (c *CircuitBreakerFilter) GetIndex() int
func (*CircuitBreakerFilter) GetName ¶
func (c *CircuitBreakerFilter) GetName() string
func (*CircuitBreakerFilter) GetNext ¶
func (c *CircuitBreakerFilter) GetNext() motan.EndPointFilter
func (*CircuitBreakerFilter) GetType ¶
func (c *CircuitBreakerFilter) GetType() int32
func (*CircuitBreakerFilter) HasNext ¶
func (c *CircuitBreakerFilter) HasNext() bool
func (*CircuitBreakerFilter) NewFilter ¶
func (c *CircuitBreakerFilter) NewFilter(url *motan.URL) motan.Filter
func (*CircuitBreakerFilter) SetNext ¶
func (c *CircuitBreakerFilter) SetNext(nextFilter motan.EndPointFilter)
type ClusterAccessLogFilter ¶
type ClusterAccessLogFilter struct {
// contains filtered or unexported fields
}
func (*ClusterAccessLogFilter) Filter ¶
func (t *ClusterAccessLogFilter) Filter(haStrategy motan.HaStrategy, loadBalance motan.LoadBalance, request motan.Request) motan.Response
func (*ClusterAccessLogFilter) GetIndex ¶
func (t *ClusterAccessLogFilter) GetIndex() int
func (*ClusterAccessLogFilter) GetName ¶
func (t *ClusterAccessLogFilter) GetName() string
func (*ClusterAccessLogFilter) GetNext ¶
func (t *ClusterAccessLogFilter) GetNext() motan.ClusterFilter
func (*ClusterAccessLogFilter) GetType ¶
func (t *ClusterAccessLogFilter) GetType() int32
func (*ClusterAccessLogFilter) HasNext ¶
func (t *ClusterAccessLogFilter) HasNext() bool
func (*ClusterAccessLogFilter) NewFilter ¶
func (t *ClusterAccessLogFilter) NewFilter(url *motan.URL) motan.Filter
func (*ClusterAccessLogFilter) SetNext ¶
func (t *ClusterAccessLogFilter) SetNext(nextFilter motan.ClusterFilter)
type ClusterCircuitBreakerFilter ¶
type ClusterCircuitBreakerFilter struct {
// contains filtered or unexported fields
}
func (*ClusterCircuitBreakerFilter) Filter ¶
func (c *ClusterCircuitBreakerFilter) Filter(ha motan.HaStrategy, lb motan.LoadBalance, request motan.Request) motan.Response
func (*ClusterCircuitBreakerFilter) GetIndex ¶
func (c *ClusterCircuitBreakerFilter) GetIndex() int
func (*ClusterCircuitBreakerFilter) GetName ¶
func (c *ClusterCircuitBreakerFilter) GetName() string
func (*ClusterCircuitBreakerFilter) GetNext ¶
func (c *ClusterCircuitBreakerFilter) GetNext() motan.ClusterFilter
func (*ClusterCircuitBreakerFilter) GetType ¶
func (c *ClusterCircuitBreakerFilter) GetType() int32
func (*ClusterCircuitBreakerFilter) HasNext ¶
func (c *ClusterCircuitBreakerFilter) HasNext() bool
func (*ClusterCircuitBreakerFilter) NewFilter ¶
func (c *ClusterCircuitBreakerFilter) NewFilter(url *motan.URL) motan.Filter
func (*ClusterCircuitBreakerFilter) SetNext ¶
func (c *ClusterCircuitBreakerFilter) SetNext(cf motan.ClusterFilter)
type ClusterMetricsFilter ¶
type ClusterMetricsFilter struct {
// contains filtered or unexported fields
}
func (*ClusterMetricsFilter) Filter ¶
func (c *ClusterMetricsFilter) Filter(haStrategy motan.HaStrategy, loadBalance motan.LoadBalance, request motan.Request) motan.Response
func (*ClusterMetricsFilter) GetIndex ¶
func (c *ClusterMetricsFilter) GetIndex() int
func (*ClusterMetricsFilter) GetName ¶
func (c *ClusterMetricsFilter) GetName() string
func (*ClusterMetricsFilter) GetNext ¶
func (c *ClusterMetricsFilter) GetNext() motan.ClusterFilter
func (*ClusterMetricsFilter) GetType ¶
func (c *ClusterMetricsFilter) GetType() int32
func (*ClusterMetricsFilter) HasNext ¶
func (c *ClusterMetricsFilter) HasNext() bool
func (*ClusterMetricsFilter) NewFilter ¶
func (c *ClusterMetricsFilter) NewFilter(url *motan.URL) motan.Filter
func (*ClusterMetricsFilter) SetNext ¶
func (c *ClusterMetricsFilter) SetNext(cf motan.ClusterFilter)
type FailfastFilter ¶
func (*FailfastFilter) GetIndex ¶
func (e *FailfastFilter) GetIndex() int
func (*FailfastFilter) GetName ¶
func (e *FailfastFilter) GetName() string
func (*FailfastFilter) GetNext ¶
func (e *FailfastFilter) GetNext() motan.EndPointFilter
func (*FailfastFilter) GetType ¶
func (e *FailfastFilter) GetType() int32
func (*FailfastFilter) HasNext ¶
func (e *FailfastFilter) HasNext() bool
func (*FailfastFilter) IsAvailable ¶
func (e *FailfastFilter) IsAvailable() bool
func (*FailfastFilter) SetNext ¶
func (e *FailfastFilter) SetNext(nextFilter motan.EndPointFilter)
type MetricsFilter ¶
type MetricsFilter struct {
// contains filtered or unexported fields
}
func (*MetricsFilter) GetIndex ¶
func (m *MetricsFilter) GetIndex() int
func (*MetricsFilter) GetName ¶
func (m *MetricsFilter) GetName() string
func (*MetricsFilter) GetNext ¶
func (m *MetricsFilter) GetNext() motan.EndPointFilter
func (*MetricsFilter) GetType ¶
func (m *MetricsFilter) GetType() int32
func (*MetricsFilter) HasNext ¶
func (m *MetricsFilter) HasNext() bool
func (*MetricsFilter) SetContext ¶
func (m *MetricsFilter) SetContext(context *motan.Context)
func (*MetricsFilter) SetNext ¶
func (m *MetricsFilter) SetNext(e motan.EndPointFilter)
type RateLimitFilter ¶
type RateLimitFilter struct {
// contains filtered or unexported fields
}
func (*RateLimitFilter) GetIndex ¶
func (r *RateLimitFilter) GetIndex() int
func (*RateLimitFilter) GetName ¶
func (r *RateLimitFilter) GetName() string
func (*RateLimitFilter) GetNext ¶
func (r *RateLimitFilter) GetNext() core.EndPointFilter
func (*RateLimitFilter) GetType ¶
func (r *RateLimitFilter) GetType() int32
func (*RateLimitFilter) HasNext ¶
func (r *RateLimitFilter) HasNext() bool
func (*RateLimitFilter) SetNext ¶
func (r *RateLimitFilter) SetNext(nextFilter core.EndPointFilter)
type TracingFilter ¶
type TracingFilter struct {
// contains filtered or unexported fields
}
TracingFilter is designed to support OpenTracing, so that we can make use of tracing capability many tracing systems (such as zipkin, etc.)
As described by OpenTracing, for a single call from client to server, both sides will start a span, with the server side span to be child of the client side. Described as following
call caller ---------------> callee [span1] [span2]
here [span1] is parent of [span2].
When this filter is applied, it will filter both the incoming and outgoing requests to record trace information. The following diagram is a demonstration.
filter +---------+ | | [span1] [span2] *-----+-- in <--+--------------------- | user | | | | V | | | ------- | | pass-thru | service | | [span2] V ------- | | | | | | | | [span3] [span2] *-----+-> out --+--------------------> | dep | | | +---------+
When the filter receives an incoming request, it will:
- extract span context from request (will get [span1])
- start a child span of the extracted span ([span2], child of [span1])
- forward the request with [span2] to the service
Then the service may make an outgoing request to some dependent services, it should pass-through the span information ([span2]). The filter will receive the outgoing request with [span2], then it will.
- extract span context from the outgoing request (it should the [span2])
- start a child span of the extracted span ([span3], child of [span2])
- forward the request with [span3] to the dependent service
So here
(parent) (parent) [span1] <------ [span2] <------ [span3]
NOTE:
The tracing capability should not be duplicated, because duplicated tracing will start more than one subsequent span, then there will be some unwanted spans in the result.
So the TracingFilter should not be applied more than once. and if an existing trace work has been done by the service itself, the TracingFilter should not be used.
func (*TracingFilter) GetIndex ¶
func (*TracingFilter) GetIndex() int
func (*TracingFilter) GetName ¶
func (*TracingFilter) GetName() string
func (*TracingFilter) GetNext ¶
func (t *TracingFilter) GetNext() core.EndPointFilter
func (*TracingFilter) GetType ¶
func (*TracingFilter) GetType() int32
func (*TracingFilter) HasNext ¶
func (t *TracingFilter) HasNext() bool
func (*TracingFilter) SetNext ¶
func (t *TracingFilter) SetNext(nextFilter core.EndPointFilter)