From 93822ae5569826345234731b73bd945dc5bfc86e Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Sat, 4 Mar 2023 12:10:32 +0100 Subject: [PATCH] Add errors to coordinator proto --- .../coordinatorproto/coordinator.pb.go | 126 ++++++++++++------ coordinator/coordinatorproto/errors.go | 16 +++ .../coordinatorproto/protos/coordinator.proto | 9 ++ 3 files changed, 109 insertions(+), 42 deletions(-) create mode 100644 coordinator/coordinatorproto/errors.go diff --git a/coordinator/coordinatorproto/coordinator.pb.go b/coordinator/coordinatorproto/coordinator.pb.go index b638938c..d35c7b8a 100644 --- a/coordinator/coordinatorproto/coordinator.pb.go +++ b/coordinator/coordinatorproto/coordinator.pb.go @@ -22,6 +22,43 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type ErrorCodes int32 + +const ( + ErrorCodes_Unexpected ErrorCodes = 0 + ErrorCodes_SpaceDeleted ErrorCodes = 1 + ErrorCodes_SpaceDeletionPending ErrorCodes = 2 + ErrorCodes_SpaceCreated ErrorCodes = 3 + ErrorCodes_SpaceNotExists ErrorCodes = 4 + ErrorCodes_ErrorOffset ErrorCodes = 300 +) + +var ErrorCodes_name = map[int32]string{ + 0: "Unexpected", + 1: "SpaceDeleted", + 2: "SpaceDeletionPending", + 3: "SpaceCreated", + 4: "SpaceNotExists", + 300: "ErrorOffset", +} + +var ErrorCodes_value = map[string]int32{ + "Unexpected": 0, + "SpaceDeleted": 1, + "SpaceDeletionPending": 2, + "SpaceCreated": 3, + "SpaceNotExists": 4, + "ErrorOffset": 300, +} + +func (x ErrorCodes) String() string { + return proto.EnumName(ErrorCodes_name, int32(x)) +} + +func (ErrorCodes) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_d94f6f99586adae2, []int{0} +} + type SpaceStatus int32 const ( @@ -50,7 +87,7 @@ func (x SpaceStatus) String() string { } func (SpaceStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d94f6f99586adae2, []int{0} + return fileDescriptor_d94f6f99586adae2, []int{1} } type SpaceSignRequest struct { @@ -632,6 +669,7 @@ func (m *SpaceStatusChangeResponse) GetPayload() *SpaceStatusPayload { } func init() { + proto.RegisterEnum("coordinator.ErrorCodes", ErrorCodes_name, ErrorCodes_value) proto.RegisterEnum("coordinator.SpaceStatus", SpaceStatus_name, SpaceStatus_value) proto.RegisterType((*SpaceSignRequest)(nil), "coordinator.SpaceSignRequest") proto.RegisterType((*SpaceStatusPayload)(nil), "coordinator.SpaceStatusPayload") @@ -651,47 +689,51 @@ func init() { } var fileDescriptor_d94f6f99586adae2 = []byte{ - // 630 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcd, 0x6e, 0x13, 0x3d, - 0x14, 0xcd, 0xa4, 0x7f, 0xca, 0x4d, 0xd5, 0x2f, 0xf5, 0x47, 0xcb, 0x10, 0x95, 0xa1, 0x32, 0x50, - 0x45, 0x15, 0x6a, 0xab, 0x14, 0x90, 0xd8, 0x21, 0x5a, 0x21, 0x15, 0x21, 0x84, 0x5c, 0x02, 0x02, - 0x16, 0xc8, 0x1d, 0x5b, 0x89, 0xd5, 0xc9, 0x78, 0x98, 0x71, 0x90, 0xba, 0xe0, 0x1d, 0x58, 0xf1, - 0x34, 0x3c, 0x00, 0xcb, 0x2e, 0x59, 0xa2, 0xe4, 0x29, 0xd8, 0xa1, 0x78, 0x3c, 0x89, 0x27, 0x99, - 0x24, 0x0b, 0x36, 0x49, 0x7c, 0xce, 0xbd, 0xe7, 0x1e, 0x5f, 0x5f, 0x3b, 0xf0, 0xc8, 0x97, 0x32, - 0x66, 0x22, 0xa4, 0x4a, 0xc6, 0x87, 0xd6, 0xef, 0x28, 0x96, 0x4a, 0x1e, 0xea, 0xcf, 0xc4, 0xc6, - 0x0f, 0x34, 0x84, 0xaa, 0x16, 0x84, 0x4f, 0xa1, 0x76, 0x1e, 0x51, 0x9f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, 0x6b, 0xce, 0x04, 0x9f, 0x11, 0xe7, - 0x8a, 0xc6, 0xc3, 0xfc, 0xf2, 0x84, 0xae, 0xe6, 0x39, 0xab, 0x2d, 0x35, 0xff, 0x94, 0xa1, 0x7a, - 0x32, 0xb6, 0x8a, 0x5e, 0x40, 0x65, 0xf4, 0x36, 0xa0, 0xdb, 0x05, 0xbb, 0x18, 0xbf, 0x77, 0x75, - 0x6f, 0x16, 0x6d, 0xba, 0xf2, 0x1e, 0x36, 0xf2, 0x73, 0x88, 0x70, 0x2e, 0xa3, 0xf0, 0x06, 0xd4, - 0xef, 0xce, 0x8d, 0x31, 0xd2, 0x9f, 0xb2, 0xe7, 0x77, 0x3c, 0x7d, 0xe8, 0xde, 0xac, 0x9e, 0xe7, - 0xe4, 0xef, 0x2f, 0x88, 0x32, 0x05, 0x2e, 0xb2, 0x37, 0xd2, 0x3a, 0x6e, 0x34, 0x27, 0xd7, 0x1a, - 0xd3, 0xfa, 0xde, 0xa2, 0xb0, 0xb4, 0xc6, 0xb3, 0xc7, 0x3f, 0xfb, 0x9e, 0x73, 0xdd, 0xf7, 0x9c, - 0xdf, 0x7d, 0xcf, 0xf9, 0x36, 0xf0, 0x4a, 0xd7, 0x03, 0xaf, 0xf4, 0x6b, 0xe0, 0x95, 0x3e, 0xec, - 0xcc, 0xfb, 0x87, 0xba, 0x58, 0xd5, 0x5f, 0xc7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x70, - 0x9d, 0x63, 0xc8, 0x06, 0x00, 0x00, + // 704 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4d, 0x4f, 0x13, 0x4f, + 0x18, 0xef, 0xb6, 0x05, 0xd2, 0xa7, 0xa4, 0xff, 0x65, 0xfe, 0x80, 0x6b, 0x83, 0x2b, 0x59, 0x95, + 0x34, 0xc4, 0x00, 0x29, 0x6a, 0xe2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d0, 0x2d, 0xf2, 0x1c, 0x6a, 0xfd, 0xe7, + 0x89, 0xdc, 0x2a, 0x68, 0xe4, 0xe0, 0xc9, 0x6d, 0x9a, 0xe3, 0xcc, 0xd9, 0x60, 0xde, 0x42, 0x23, + 0x7f, 0x15, 0x88, 0x95, 0x8b, 0x28, 0xbc, 0x84, 0xcd, 0x3b, 0x13, 0x7d, 0xb2, 0xd4, 0x1f, 0xe4, + 0x17, 0x60, 0x70, 0x01, 0xc8, 0xdd, 0x71, 0x63, 0xcf, 0xa5, 0xbf, 0x77, 0x8d, 0x57, 0x46, 0x70, + 0x20, 0x9f, 0x69, 0x65, 0xe3, 0xc8, 0x84, 0x58, 0xe5, 0xa6, 0x34, 0x57, 0xae, 0x73, 0x4b, 0x39, + 0x9e, 0x3e, 0xfa, 0x79, 0x69, 0x6a, 0x17, 0x97, 0xa6, 0xf6, 0xfb, 0xd2, 0xd4, 0xbe, 0x5e, 0x99, + 0xa5, 0x8b, 0x2b, 0xb3, 0xf4, 0xeb, 0xca, 0x2c, 0xbd, 0x5b, 0x9a, 0xf4, 0x91, 0x3c, 0x98, 0x4e, + 0xfe, 0x6d, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xe4, 0x76, 0x96, 0x0f, 0x4b, 0x07, 0x00, 0x00, } func (m *SpaceSignRequest) Marshal() (dAtA []byte, err error) { diff --git a/coordinator/coordinatorproto/errors.go b/coordinator/coordinatorproto/errors.go new file mode 100644 index 00000000..1fb41a2c --- /dev/null +++ b/coordinator/coordinatorproto/errors.go @@ -0,0 +1,16 @@ +package coordinatorproto + +import ( + "errors" + "github.com/anytypeio/any-sync/net/rpc/rpcerr" +) + +var ( + errGroup = rpcerr.ErrGroup(ErrorCodes_ErrorOffset) + + ErrUnexpected = errGroup.Register(errors.New("unexpected error"), uint64(ErrorCodes_Unexpected)) + ErrSpaceIsCreated = errGroup.Register(errors.New("space is missing"), uint64(ErrorCodes_SpaceCreated)) + ErrSpaceIsDeleted = errGroup.Register(errors.New("space is deleted"), uint64(ErrorCodes_SpaceDeleted)) + ErrSpaceDeletionPending = errGroup.Register(errors.New("space is set out for deletion"), uint64(ErrorCodes_SpaceDeletionPending)) + ErrSpaceNotExists = errGroup.Register(errors.New("space not exists"), uint64(ErrorCodes_SpaceNotExists)) +) diff --git a/coordinator/coordinatorproto/protos/coordinator.proto b/coordinator/coordinatorproto/protos/coordinator.proto index 4e2c2777..b828740c 100644 --- a/coordinator/coordinatorproto/protos/coordinator.proto +++ b/coordinator/coordinatorproto/protos/coordinator.proto @@ -25,6 +25,15 @@ message SpaceSignRequest { bytes header = 2; } +enum ErrorCodes { + Unexpected = 0; + SpaceDeleted = 1; + SpaceDeletionPending = 2; + SpaceCreated = 3; + SpaceNotExists = 4; + ErrorOffset = 300; +} + enum SpaceStatus { SpaceStatusCreated = 0; SpaceStatusPendingDeletion = 1;