in pkg/adapters/micro/client.go [18:59]
func (c *clientWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
options := evaluateOptions(c.Opts)
if options.enableOutlier == nil || !options.enableOutlier(ctx) {
resourceName := req.Method()
if options.clientResourceExtract != nil {
resourceName = options.clientResourceExtract(ctx, req)
}
entry, blockErr := sentinel.Entry(
resourceName,
sentinel.WithResourceType(base.ResTypeRPC),
sentinel.WithTrafficType(base.Outbound),
)
if blockErr != nil {
if options.clientBlockFallback != nil {
return options.clientBlockFallback(ctx, req, blockErr)
}
return blockErr
}
defer entry.Exit()
err := c.Client.Call(ctx, req, rsp, opts...)
if err != nil {
sentinel.TraceError(entry, err)
}
return err
} else { // returns new client middleware specifically for outlier ejection.
slotChain := sentinel.BuildDefaultSlotChain()
slotChain.AddRuleCheckSlot(outlier.DefaultSlot)
slotChain.AddStatSlot(outlier.DefaultMetricStatSlot)
entry, _ := sentinel.Entry(
req.Service(),
sentinel.WithResourceType(base.ResTypeRPC),
sentinel.WithTrafficType(base.Outbound),
sentinel.WithSlotChain(slotChain),
)
defer entry.Exit()
opts = append(opts, WithSelectOption(entry))
opts = append(opts, WithCallWrapper(entry))
return c.Client.Call(ctx, req, rsp, opts...)
}
}