micro-wrapper-breaker-hystrix/hystrix.go
Vasiliy Tolstov fb1b7a620f use own fork
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-02 13:11:07 +03:00

26 lines
598 B
Go

package hystrix
import (
"context"
"github.com/afex/hystrix-go/hystrix"
"github.com/unistack-org/micro/v3/client"
)
type clientWrapper struct {
client.Client
}
func (c *clientWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
return hystrix.Do(req.Service()+"."+req.Endpoint(), func() error {
return c.Client.Call(ctx, req, rsp, opts...)
}, nil)
}
// NewClientWrapper returns a hystrix client Wrapper.
func NewClientWrapper() client.Wrapper {
return func(c client.Client) client.Client {
return &clientWrapper{Client: c}
}
}