circuit

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ReturnNil is build in fallback name
	ReturnNil = "returnnull"
	//ReturnErr is build in fallback name
	ReturnErr = "throwexception"
)

Variables

View Source
var ErrFallbackNotExists = errors.New("fallback func does not exist")

ErrFallbackNotExists happens if fallback implementation does not exist

Functions

func ExtractServiceSchemaOperationMetrics added in v1.6.0

func ExtractServiceSchemaOperationMetrics(raw string) (target, schemaID, operation, metrics string)

ExtractServiceSchemaOperationMetrics parse service,schema and operation key example Microservice.SchemaID.OperationId.metrics

func FallbackErr

func FallbackErr(inv *invocation.Invocation, finish chan *invocation.Response) func(error) error

FallbackErr set err in response

func FallbackNil

func FallbackNil(inv *invocation.Invocation, finish chan *invocation.Response) func(error) error

FallbackNil return empty response

func GetEventType added in v1.6.0

func GetEventType(cmdName string) string

GetEventType get metrics suffix

func GetMetricsName added in v1.6.0

func GetMetricsName(cmd string) (source string)

GetMetricsName get only metrics name from cmd name

func Init

func Init()

Init init functions

func ParseCircuitCMD added in v1.6.0

func ParseCircuitCMD(cmd string) (source string, target string, schema string, op string)

ParseCircuitCMD return metrics related infos example Consumer.ErrServer.rest./sayhimessage.rejects the first and last string consist of metrics name second is ErrServer 3th and 4th is schema and operation

func RegisterFallback

func RegisterFallback(name string, f Fallback)

RegisterFallback register custom logic

Types

type Fallback

type Fallback func(inv *invocation.Invocation, finish chan *invocation.Response) func(error) error

Fallback defines how to return response if remote call fails. a implementation should return a closure to handle the error. in this closure, if you fallback logic should handle the original error, you can return a fallback error to replace the original error you can assemble invocation.Response on demand in summary the closure defines, "if err happens, how to handle it".

func GetFallback

func GetFallback(name string) (Fallback, error)

GetFallback return function

Jump to

Keyboard shortcuts

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