Add better error handling
This commit is contained in:
parent
b8bdbacbce
commit
2347591c69
3
common/commonspace/cache/treecache.go
vendored
3
common/commonspace/cache/treecache.go
vendored
@ -2,12 +2,15 @@ package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
|
||||
)
|
||||
|
||||
const CName = "commonspace.cache"
|
||||
|
||||
var ErrSpaceNotFound = errors.New("space not found")
|
||||
|
||||
type TreeContainer interface {
|
||||
Tree() tree.ObjectTree
|
||||
}
|
||||
|
||||
@ -40,8 +40,6 @@ type Space interface {
|
||||
Id() string
|
||||
|
||||
SpaceSyncRpc() RpcHandler
|
||||
SyncService() syncservice.SyncService
|
||||
DiffService() diffservice.DiffService
|
||||
|
||||
DeriveTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error)
|
||||
CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error)
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
var (
|
||||
errGroup = rpcerr.ErrGroup(ErrCodes_ErrorOffset)
|
||||
|
||||
ErrUnexpected = errGroup.Register(errors.New("Unexpected error"), uint64(ErrCodes_Unexpected))
|
||||
ErrSpaceMissing = errGroup.Register(errors.New("Space is missing"), uint64(ErrCodes_SpaceMissing))
|
||||
ErrUnexpected = errGroup.Register(errors.New("unexpected error"), uint64(ErrCodes_Unexpected))
|
||||
ErrSpaceMissing = errGroup.Register(errors.New("space is missing"), uint64(ErrCodes_SpaceMissing))
|
||||
ErrSpaceExists = errGroup.Register(errors.New("space exists"), uint64(ErrCodes_SpaceMissing))
|
||||
)
|
||||
|
||||
@ -8,7 +8,8 @@ import "pkg/acl/aclrecordproto/protos/aclrecord.proto";
|
||||
enum ErrCodes {
|
||||
Unexpected = 0;
|
||||
SpaceMissing = 1;
|
||||
ErrorOffset = 16;
|
||||
SpaceExists = 2;
|
||||
ErrorOffset = 100;
|
||||
}
|
||||
|
||||
service Space {
|
||||
|
||||
@ -29,19 +29,22 @@ type ErrCodes int32
|
||||
const (
|
||||
ErrCodes_Unexpected ErrCodes = 0
|
||||
ErrCodes_SpaceMissing ErrCodes = 1
|
||||
ErrCodes_ErrorOffset ErrCodes = 16
|
||||
ErrCodes_SpaceExists ErrCodes = 2
|
||||
ErrCodes_ErrorOffset ErrCodes = 100
|
||||
)
|
||||
|
||||
var ErrCodes_name = map[int32]string{
|
||||
0: "Unexpected",
|
||||
1: "SpaceMissing",
|
||||
16: "ErrorOffset",
|
||||
2: "SpaceExists",
|
||||
100: "ErrorOffset",
|
||||
}
|
||||
|
||||
var ErrCodes_value = map[string]int32{
|
||||
"Unexpected": 0,
|
||||
"SpaceMissing": 1,
|
||||
"ErrorOffset": 16,
|
||||
"SpaceExists": 2,
|
||||
"ErrorOffset": 100,
|
||||
}
|
||||
|
||||
func (x ErrCodes) String() string {
|
||||
@ -940,64 +943,65 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_5855f4ef9cf24cdb = []byte{
|
||||
// 911 bytes of a gzipped FileDescriptorProto
|
||||
// 919 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x8e, 0x1b, 0x45,
|
||||
0x10, 0xf6, 0x78, 0x7f, 0x6c, 0x97, 0xf7, 0xc7, 0xe9, 0xb0, 0x61, 0x70, 0x88, 0x63, 0xe6, 0x80,
|
||||
0x56, 0x20, 0xd6, 0xc8, 0x1c, 0x02, 0x2c, 0x08, 0x25, 0xcb, 0xae, 0x6c, 0x85, 0x90, 0xa8, 0x37,
|
||||
0x01, 0x09, 0x71, 0xe9, 0xcc, 0xd4, 0xda, 0x43, 0xc6, 0xd3, 0x43, 0x77, 0x9b, 0xc5, 0x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0x0b, 0x00, 0x00, 0xff, 0xff, 0xce,
|
||||
0x99, 0xdc, 0xc5, 0x16, 0x09, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto"
|
||||
@ -9,6 +10,8 @@ import (
|
||||
|
||||
const CName = "commonspace.storage"
|
||||
|
||||
var ErrSpaceStorageExists = errors.New("space storage exists")
|
||||
|
||||
type SpaceStorage interface {
|
||||
storage.Provider
|
||||
ACLStorage() (storage.ListStorage, error)
|
||||
|
||||
@ -2,13 +2,17 @@ package syncservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/rpcerr"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto"
|
||||
"time"
|
||||
)
|
||||
|
||||
var log = logger.NewNamed("syncservice").Sugar()
|
||||
|
||||
type SyncService interface {
|
||||
NotifyHeadUpdate(
|
||||
ctx context.Context,
|
||||
@ -104,7 +108,12 @@ func (s *syncService) responsibleStreamCheckLoop(ctx context.Context) {
|
||||
continue
|
||||
}
|
||||
// sending empty message for the server to understand from which space is it coming
|
||||
stream.Send(&spacesyncproto.ObjectSyncMessage{SpaceId: s.spaceId})
|
||||
err = stream.Send(&spacesyncproto.ObjectSyncMessage{SpaceId: s.spaceId})
|
||||
if err != nil {
|
||||
err = rpcerr.Unwrap(err)
|
||||
log.With("spaceId", s.spaceId).Errorf("failed to open stream: %v", err)
|
||||
continue
|
||||
}
|
||||
s.streamPool.AddAndReadStreamAsync(stream)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package nodespace
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
|
||||
)
|
||||
@ -13,9 +14,14 @@ type rpcHandler struct {
|
||||
func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpaceRequest) (resp *spacesyncproto.PushSpaceResponse, err error) {
|
||||
_, err = r.s.GetSpace(ctx, req.SpaceId)
|
||||
if err == nil {
|
||||
resp = &spacesyncproto.PushSpaceResponse{}
|
||||
err = spacesyncproto.ErrSpaceExists
|
||||
return
|
||||
}
|
||||
if err != cache.ErrSpaceNotFound {
|
||||
err = spacesyncproto.ErrUnexpected
|
||||
return
|
||||
}
|
||||
|
||||
payload := storage.SpaceStorageCreatePayload{
|
||||
RecWithId: req.AclRoot,
|
||||
SpaceHeader: req.SpaceHeader,
|
||||
@ -24,6 +30,9 @@ func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpac
|
||||
_, err = r.s.spaceStorageProvider.CreateSpaceStorage(payload)
|
||||
if err != nil {
|
||||
err = spacesyncproto.ErrUnexpected
|
||||
if err == storage.ErrSpaceStorageExists {
|
||||
err = spacesyncproto.ErrSpaceExists
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user