Documentation ¶
Overview ¶
This package provides Sentinel integration for go-micro.
For server side, users may append a Sentinel handler wrapper to go-micro service, like:
import ( sentinelPlugin "github.com/sentinel-go/pkg/adapters/micro" ) // Append a Sentinel handler wrapper. micro.NewService(micro.WrapHandler(sentinelPlugin.NewHandlerWrapper()))
The plugin extracts service method as the resource name by default. Users may provide customized resource name extractor when creating new Sentinel handler wrapper (via 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 WithXxxBlockFallback(handler) options.
Index ¶
- func NewClientWrapper(opts ...Option) client.Wrapper
- func NewHandlerWrapper(sentinelOpts ...Option) server.HandlerWrapper
- func NewStreamWrapper(sentinelOpts ...Option) server.StreamWrapper
- func WithCallWrapper(entry *base.SentinelEntry) client.CallOption
- func WithSelectOption(entry *base.SentinelEntry) client.CallOption
- type Option
- func WithClientBlockFallback(fn func(context.Context, client.Request, *base.BlockError) error) Option
- func WithClientResourceExtractor(fn func(context.Context, client.Request) string) Option
- func WithEnableOutlier(fn func(ctx context.Context) bool) Option
- func WithServerBlockFallback(fn func(context.Context, server.Request, *base.BlockError) error) Option
- func WithServerResourceExtractor(fn func(context.Context, server.Request) string) Option
- func WithStreamClientBlockFallback(...) Option
- func WithStreamClientResourceExtractor(fn func(context.Context, client.Request) string) Option
- func WithStreamServerBlockFallback(fn func(server.Stream, *base.BlockError) server.Stream) Option
- func WithStreamServerResourceExtractor(fn func(server.Stream) string) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientWrapper ¶
NewClientWrapper returns a sentinel client Wrapper.
func NewHandlerWrapper ¶
func NewHandlerWrapper(sentinelOpts ...Option) server.HandlerWrapper
NewHandlerWrapper returns a Handler Wrapper with Alibaba Sentinel breaker
func NewStreamWrapper ¶
func NewStreamWrapper(sentinelOpts ...Option) server.StreamWrapper
func WithCallWrapper ¶
func WithCallWrapper(entry *base.SentinelEntry) client.CallOption
func WithSelectOption ¶
func WithSelectOption(entry *base.SentinelEntry) client.CallOption
Types ¶
type Option ¶
type Option func(*options)
func WithClientBlockFallback ¶
func WithClientBlockFallback(fn func(context.Context, client.Request, *base.BlockError) error) Option
WithClientBlockFallback sets the block fallback handler of unary client request. The second string parameter is the full method name of current invocation.
func WithClientResourceExtractor ¶
WithClientResourceExtractor sets the resource extractor of unary client request. The second string parameter is the full method name of current invocation.
func WithEnableOutlier ¶
WithEnableOutlier sets whether to enable outlier ejection
func WithServerBlockFallback ¶
func WithServerBlockFallback(fn func(context.Context, server.Request, *base.BlockError) error) Option
WithServerBlockFallback sets the block fallback handler of unary server request.
func WithServerResourceExtractor ¶
WithServerResourceExtractor sets the resource extractor of unary server request.
func WithStreamClientBlockFallback ¶
func WithStreamClientBlockFallback(fn func(context.Context, client.Request, *base.BlockError) (client.Stream, error)) Option
WithStreamClientBlockFallback sets the block fallback handler of stream client request.
func WithStreamClientResourceExtractor ¶
WithStreamClientResourceExtractor sets the resource extractor of stream client request.
func WithStreamServerBlockFallback ¶
WithStreamServerBlockFallback sets the block fallback handler of stream server request.