circuit

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: Apache-2.0 Imports: 8 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 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 Init

func Init()

Init init functions

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