Documentation
¶
Index ¶
- Constants
- Variables
- func ExtractServiceSchemaOperationMetrics(raw string) (target, schemaID, operation, metrics string)
- func FallbackErr(inv *invocation.Invocation, finish chan *invocation.Response) func(error) error
- func FallbackNil(inv *invocation.Invocation, finish chan *invocation.Response) func(error) error
- func GetEventType(cmdName string) string
- func GetMetricsName(cmd string) (source string)
- func Init()
- func ParseCircuitCMD(cmd string) (source string, target string, schema string, op string)
- func RegisterFallback(name string, f Fallback)
- type Fallback
Constants ¶
const ( //ReturnNil is build in fallback name ReturnNil = "returnnull" //ReturnErr is build in fallback name ReturnErr = "throwexception" )
Variables ¶
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
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
GetEventType get metrics suffix
func GetMetricsName ¶ added in v1.6.0
GetMetricsName get only metrics name from cmd name
func ParseCircuitCMD ¶ added in v1.6.0
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 ¶
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".