handler

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: Apache-2.0 Imports: 33 Imported by: 14

Documentation

Index

Constants

View Source
const (
	Transport           = "transport"
	Loadbalance         = "loadbalance"
	BizkeeperConsumer   = "bizkeeper-consumer"
	BizkeeperProvider   = "bizkeeper-provider"
	TracingConsumer     = "tracing-consumer"
	TracingProvider     = "tracing-provider"
	RatelimiterConsumer = "ratelimiter-consumer"
	RatelimiterProvider = "ratelimiter-provider"
	Router              = "router"
	FaultInject         = "fault-inject"
)

constant keys for handlers

View Source
const (
	ProviderQPSLimit       = "cse.flowcontrol.Provider.qps.limit"
	ProviderLimitKeyGlobal = "cse.flowcontrol.Provider.qps.global.limit"
)

constant for provider qps limiter keys

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 HandlerFuncMap = make(map[string]func() Handler)

HandlerFuncMap handler function map

Functions

func CreateChains

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

CreateChains is for to create the chains

func GetFallbackFun

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

GetFallbackFun get fallback function

func GetFaultConfig

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

GetFaultConfig get faultconfig

func GetHystrixConfig

func GetHystrixConfig(service, protype string) (string, hystrix.CommandConfig)

GetHystrixConfig get hystrix config

func ProcessSpecialProtocol

func ProcessSpecialProtocol(inv *invocation.Invocation, req *client.Request)

ProcessSpecialProtocol handles special logic for protocol

func ProcessSuccessiveFailure

func ProcessSuccessiveFailure(i *invocation.Invocation, req *client.Request)

ProcessSuccessiveFailure handles special logic for protocol

func RegisterHandler

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

RegisterHandler Let developer custom handler

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
	HandlerIndex int
}

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 final handler 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

func (*Chain) Reset

func (c *Chain) Reset()

Reset for to reset the handler index

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) GetOrCreate

GetOrCreate is for getting or creating qps limiter meta data

func (*ConsumerRateLimiterHandler) Handle

Handle is handles the consumer rate limiter APIs

func (*ConsumerRateLimiterHandler) Name

Name returns consumerratelimiter string

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

func FaultHandle

func FaultHandle() Handler

FaultHandle fault handle gives the object of FaultHandler

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