handler

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: Apache-2.0 Imports: 32 Imported by: 12

Documentation

Index

Constants

View Source
const (
	//consumer chain
	Transport           = "transport"
	Loadbalance         = "loadbalance"
	BizkeeperConsumer   = "bizkeeper-consumer"
	TracingConsumer     = "tracing-consumer"
	RateLimiterConsumer = "ratelimiter-consumer"
	Router              = "router"
	FaultInject         = "fault-inject"
	SkyWalkingConsumer  = "skywalking-consumer"

	//provider chain
	RateLimiterProvider = "ratelimiter-provider"
	TracingProvider     = "tracing-provider"
	BizKeeperProvider   = "bizkeeper-provider"
	SkyWalkingProvider  = "skywalking-provider"
)

constant keys for handlers

View Source
const (
	FaultHandlerName = "fault-inject"
)

constant for fault handler name

View Source
const (
	Name = "bizkeeper-consumer"
)

constant for bizkeeper-consumer

Variables

View Source
var ChainMap = make(map[string]*Chain)

ChainMap just concurrent read

View Source
var ErrDuplicatedHandler = errors.New("duplicated handler registration")

ErrDuplicatedHandler means you registered more than 1 handler with same name

View Source
var HandlerFuncMap = make(map[string]func() Handler)

HandlerFuncMap handler function map

Functions

func CreateChains

func CreateChains(chainType string, handlerNameMap map[string]string) error

CreateChains create the chains based on type and handler map

func GetFallbackFun

func GetFallbackFun(cmd, t string, i *invocation.Invocation, finish chan *invocation.Response, isForce bool) (func(error) error, error)

GetFallbackFun get fallback function

func GetFaultConfig

func GetFaultConfig(protocol, microServiceName, schemaID, operationID string) model.Fault

GetFaultConfig get faultconfig

func ProcessSpecialProtocol

func ProcessSpecialProtocol(inv *invocation.Invocation)

ProcessSpecialProtocol handles special logic for protocol

func ProcessSuccessiveFailure

func ProcessSuccessiveFailure(i *invocation.Invocation)

ProcessSuccessiveFailure handles special logic for protocol

func RegisterHandler

func RegisterHandler(name string, f func() Handler) error

RegisterHandler Let developer custom handler

func WriteBackErr added in v1.8.0

func WriteBackErr(err error, status int, cb invocation.ResponseCallBack)

WriteBackErr write err and callback

Types

type BizKeeperConsumerHandler

type BizKeeperConsumerHandler struct{}

BizKeeperConsumerHandler bizkeeper consumer handler

func (*BizKeeperConsumerHandler) Handle

Handle function is for to handle the chain

func (*BizKeeperConsumerHandler) Name

func (bk *BizKeeperConsumerHandler) Name() string

Name is for to represent the name of bizkeeper handler

type BizKeeperProviderHandler

type BizKeeperProviderHandler struct{}

BizKeeperProviderHandler bizkeeper provider handler

func (*BizKeeperProviderHandler) Handle

Handle handler for bizkeeper provider

func (*BizKeeperProviderHandler) Name

func (bk *BizKeeperProviderHandler) Name() string

Name returns bizkeeper-provider string

type Chain

type Chain struct {
	ServiceType string
	Name        string
	Handlers    []Handler
}

Chain struct for service and handlers

func CreateChain

func CreateChain(serviceType string, chainName string, handlerNames ...string) (*Chain, error)

CreateChain create consumer or provider's chain,the handlers is different

func GetChain

func GetChain(serviceType string, name string) (*Chain, error)

GetChain is to get chain

func (*Chain) AddHandler

func (c *Chain) AddHandler(h Handler)

AddHandler chain can add a handler

func (*Chain) Next

Next is for to handle next handler in the chain

type ChainOption

type ChainOption func(*ChainOptions)

ChainOption is a function name

func WithChainName

func WithChainName(name string) ChainOption

WithChainName returns the name of the chain option

type ChainOptions

type ChainOptions struct {
	Name string
}

ChainOptions chain options

type ConsumerRateLimiterHandler

type ConsumerRateLimiterHandler struct{}

ConsumerRateLimiterHandler consumer rate limiter handler

func (*ConsumerRateLimiterHandler) Handle

Handle is handles the consumer rate limiter APIs

func (*ConsumerRateLimiterHandler) Name

Name returns name

type FaultHandler

type FaultHandler struct{}

FaultHandler handler

func (*FaultHandler) Handle

func (rl *FaultHandler) Handle(chain *Chain, inv *invocation.Invocation, cb invocation.ResponseCallBack)

Handle is to handle the API

func (*FaultHandler) Name

func (rl *FaultHandler) Name() string

Name function returns fault-inject string

type Handler

type Handler interface {
	// handle invocation transportation,and tr response
	Handle(*Chain, *invocation.Invocation, invocation.ResponseCallBack)
	Name() string
}

Handler interface for handlers

func CreateHandler

func CreateHandler(name string) (Handler, error)

CreateHandler create a new handler by name your registered

type LBHandler

type LBHandler struct{}

LBHandler loadbalancer handler struct

func (*LBHandler) Handle

func (lb *LBHandler) Handle(chain *Chain, i *invocation.Invocation, cb invocation.ResponseCallBack)

Handle to handle the load balancing

func (*LBHandler) Name

func (lb *LBHandler) Name() string

Name returns loadbalancer string

type ProviderRateLimiterHandler

type ProviderRateLimiterHandler struct{}

ProviderRateLimiterHandler provider rate limiter handler

func (*ProviderRateLimiterHandler) Handle

Handle is to handle provider rateLimiter things

func (*ProviderRateLimiterHandler) Name

Name returns the name providerratelimiter

type RouterHandler

type RouterHandler struct{}

RouterHandler router handler

func (*RouterHandler) Handle

Handle is to handle the router related things

func (*RouterHandler) Name

func (ph *RouterHandler) Name() string

Name returns the router string

type TracingConsumerHandler

type TracingConsumerHandler struct{}

TracingConsumerHandler tracing consumer handler

func (*TracingConsumerHandler) Handle

Handle is handle consumer tracing related things

func (*TracingConsumerHandler) Name

func (t *TracingConsumerHandler) Name() string

Name returns tracing-consumer string

type TracingProviderHandler

type TracingProviderHandler struct{}

TracingProviderHandler tracing provider handler

func (*TracingProviderHandler) Handle

Handle is to handle the provider tracing related things

func (*TracingProviderHandler) Name

func (t *TracingProviderHandler) Name() string

Name returns tracing-provider string

type TransportHandler

type TransportHandler struct{}

TransportHandler transport handler

func (*TransportHandler) Handle

Handle is to handle transport related things

func (*TransportHandler) Name

func (th *TransportHandler) Name() string

Name returns transport string

Jump to

Keyboard shortcuts

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