Add support for multiple differs
Updates the differ service to support calling and configuring multiple differs. The differs are configured as an ordered list of differs which will each be attempting until a supported differ is called. Additionally a not supported error type was added to allow differs to be selective of whether the differ arguments are supported by the differ. This error type corresponds to the GRPC unimplemented error. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -26,6 +26,7 @@ var (
|
||||
ErrAlreadyExists = errors.New("already exists")
|
||||
ErrFailedPrecondition = errors.New("failed precondition")
|
||||
ErrUnavailable = errors.New("unavailable")
|
||||
ErrNotSupported = errors.New("not supported") // represents not supported and unimplemented
|
||||
)
|
||||
|
||||
func IsInvalidArgument(err error) bool {
|
||||
@@ -52,3 +53,7 @@ func IsFailedPrecondition(err error) bool {
|
||||
func IsUnavailable(err error) bool {
|
||||
return errors.Cause(err) == ErrUnavailable
|
||||
}
|
||||
|
||||
func IsNotSupported(err error) bool {
|
||||
return errors.Cause(err) == ErrNotSupported
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ func ToGRPC(err error) error {
|
||||
return grpc.Errorf(codes.FailedPrecondition, err.Error())
|
||||
case IsUnavailable(err):
|
||||
return grpc.Errorf(codes.Unavailable, err.Error())
|
||||
case IsNotSupported(err):
|
||||
return grpc.Errorf(codes.Unimplemented, err.Error())
|
||||
}
|
||||
|
||||
return err
|
||||
@@ -69,6 +71,8 @@ func FromGRPC(err error) error {
|
||||
cls = ErrUnavailable
|
||||
case codes.FailedPrecondition:
|
||||
cls = ErrFailedPrecondition
|
||||
case codes.Unimplemented:
|
||||
cls = ErrNotSupported
|
||||
default:
|
||||
cls = ErrUnknown
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user