Documentation
¶
Overview ¶
* This package provides Sentinel integration for Kitex.
For server side, users may append a Sentinel middleware to Kitex service, like:
import ( sentinelPlugin "github.com/alibaba/sentinel-golang/pkg/adapters/kitex" ) srv := hello.NewServer(new(HelloImpl),server.WithMiddleware(SentinelServerMiddleware()))
The plugin extracts service name and service method as the resource name by default. Users may provide customized resource name extractor when creating new Sentinel middleware (via WithResourceExtract options).
Fallback logic: the plugin will return the BlockError by default if current request is blocked by Sentinel rules. Users may also provide customized fallback logic via WithBlockFallback(handler) options.
Index ¶
- func CalleeAddressExtract(ctx context.Context) string
- func DefaultBlockFallback(ctx context.Context, req, resp interface{}, blockErr error) error
- func DefaultEnableOutlier(ctx context.Context) bool
- func DefaultResourceExtract(ctx context.Context, req, resp interface{}) string
- func OutlierClientResolver(resolver discovery.Resolver) discovery.Resolver
- func SentinelClientMiddleware(opts ...Option) func(endpoint.Endpoint) endpoint.Endpoint
- func SentinelServerMiddleware(opts ...Option) func(endpoint.Endpoint) endpoint.Endpoint
- func ServiceNameExtract(ctx context.Context) string
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalleeAddressExtract ¶
func DefaultBlockFallback ¶
func DefaultEnableOutlier ¶
func DefaultResourceExtract ¶
func OutlierClientResolver ¶
func SentinelClientMiddleware ¶
SentinelClientMiddleware returns new client.Middleware Default resource name is {service's name}:{method} Default block fallback is returning blockError Define your own behavior by setting serverOptions
func SentinelServerMiddleware ¶
SentinelServerMiddleware returns new server.Middleware Default resource name is {service's name}:{method} Default block fallback is returning blockError Define your own behavior by setting serverOptions
func ServiceNameExtract ¶
Types ¶
type Option ¶
type Option struct {
F func(o *options)
}
func WithBlockFallback ¶
func WithBlockFallback(f func(ctx context.Context, req, resp interface{}, blockErr error) error) Option
WithBlockFallback sets the fallback handler
func WithEnableOutlier ¶
WithEnableOutlier sets whether to enable outlier ejection