kitex

package module
v0.0.0-...-f4c2c59 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalleeAddressExtract

func CalleeAddressExtract(ctx context.Context) string

func DefaultBlockFallback

func DefaultBlockFallback(ctx context.Context, req, resp interface{}, blockErr error) error

func DefaultEnableOutlier

func DefaultEnableOutlier(ctx context.Context) bool

func DefaultResourceExtract

func DefaultResourceExtract(ctx context.Context, req, resp interface{}) string

func OutlierClientResolver

func OutlierClientResolver(resolver discovery.Resolver) discovery.Resolver

func SentinelClientMiddleware

func SentinelClientMiddleware(opts ...Option) func(endpoint.Endpoint) endpoint.Endpoint

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

func SentinelServerMiddleware(opts ...Option) func(endpoint.Endpoint) endpoint.Endpoint

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

func ServiceNameExtract(ctx context.Context) string

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

func WithEnableOutlier(f func(ctx context.Context) bool) Option

WithEnableOutlier sets whether to enable outlier ejection

func WithResourceExtract

func WithResourceExtract(f func(ctx context.Context, req, resp interface{}) string) Option

WithResourceExtract sets the resource extractor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL