Repository navigation
Repository filter README
alanxtl edited this page Sep 20, 2026
·
1 revision
主仓库文档快照;main 的说明不自动适用于所有已发布版本。 来源:原文 · 提交
832124aaacf0· 返回目录
Dubbo-go filters are interceptor-style extensions around RPC invocation. They are typically used to add cross-cutting behavior such as authentication, rate limiting, logging, tracing, metrics, generic invocation adaptation, and graceful shutdown handling.
The recommended approach is to import only the filters your application needs.
package demo
import _ "dubbo.apache.org/dubbo-go/v3/filter/echo"
import _ "dubbo.apache.org/dubbo-go/v3/filter/generic"If you prefer the legacy all-in-one import, you can still use:
package demo
import _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"Dubbo-go distinguishes between two filter chains:
-
service.filter: provider-side filters -
reference.filter: consumer-side filters
The built-in defaults are defined in common/constant/default.go.
-
echo: echo health check support -
generic: consumer-side generic invocation filter -
generic_service: provider-side generic service filter -
graceful_shutdown: graceful shutdown behavior for provider and consumer paths
-
active: active request counting -
exec_limit: provider-side execute concurrency limiting -
tps: TPS limiting -
adaptivesvc: adaptive service filter -
polaris/limit: Polaris rate limiting -
sentinel: Sentinel integration for provider and consumer traffic protection
-
token: token-based request validation -
auth: request signing and authentication -
seata: Seata distributed transaction propagation
-
accesslog: invocation access logging -
metrics: metrics collection -
tracing: tracing integration -
otel/trace: OpenTelemetry tracing integration
-
hystrix: moved to dubbo-go-extensions
In practice, filters are usually enabled through application config instead of being called directly from business code. Typical examples:
- enable a provider filter through
service.filter - enable a consumer filter through
reference.filter - import the filter package so it registers itself via
extension.SetFilter(...)
- Importing a filter package registers it; the filter still needs to be enabled by the corresponding consumer/provider configuration path when applicable.
- Some filter names differ slightly from their package directory because the
runtime key is defined in
common/constant/key.go. - Filters under subdirectories such as
otel/traceandpolaris/limitare still ordinary Dubbo-go filters; the subdirectory just reflects feature grouping.