diff --git a/api/converter/from_pb.go b/api/converter/from_pb.go index ac4d6effa..f63585a2d 100644 --- a/api/converter/from_pb.go +++ b/api/converter/from_pb.go @@ -29,7 +29,6 @@ import ( "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/operations" "github.com/yorkie-team/yorkie/pkg/document/time" - "github.com/yorkie-team/yorkie/server/backend/sync" ) // FromUser converts the given Protobuf formats to model format. @@ -192,16 +191,6 @@ func fromChangeID(id *api.ChangeID) (change.ID, error) { ), nil } -// FromDocumentKey converts the given Protobuf formats to model format. -func FromDocumentKey(pbKey string) (key.Key, error) { - k := key.Key(pbKey) - if err := k.Validate(); err != nil { - return "", err - } - - return k, nil -} - // FromDocumentID converts the given Protobuf formats to model format. func FromDocumentID(pbID string) (types.ID, error) { id := types.ID(pbID) @@ -225,24 +214,6 @@ func FromEventType(pbDocEventType api.DocEventType) (types.DocEventType, error) return "", fmt.Errorf("%v: %w", pbDocEventType, ErrUnsupportedEventType) } -// FromDocEvent converts the given Protobuf formats to model format. -func FromDocEvent(docEvent *api.DocEvent) (*sync.DocEvent, error) { - client, err := time.ActorIDFromBytes(docEvent.Publisher) - if err != nil { - return nil, err - } - - eventType, err := FromEventType(docEvent.Type) - if err != nil { - return nil, err - } - - return &sync.DocEvent{ - Type: eventType, - Publisher: client, - }, nil -} - // FromOperations converts the given Protobuf formats to model format. func FromOperations(pbOps []*api.Operation) ([]operations.Operation, error) { var ops []operations.Operation diff --git a/api/converter/to_pb.go b/api/converter/to_pb.go index 48362c6a1..79a3114ac 100644 --- a/api/converter/to_pb.go +++ b/api/converter/to_pb.go @@ -29,7 +29,6 @@ import ( "github.com/yorkie-team/yorkie/pkg/document/innerpresence" "github.com/yorkie-team/yorkie/pkg/document/operations" "github.com/yorkie-team/yorkie/pkg/document/time" - "github.com/yorkie-team/yorkie/server/backend/sync" ) // ToUser converts the given model format to Protobuf format. @@ -214,19 +213,6 @@ func ToDocEventType(eventType types.DocEventType) (api.DocEventType, error) { } } -// ToDocEvent converts the given model to Protobuf format. -func ToDocEvent(docEvent sync.DocEvent) (*api.DocEvent, error) { - eventType, err := ToDocEventType(docEvent.Type) - if err != nil { - return nil, err - } - - return &api.DocEvent{ - Type: eventType, - Publisher: docEvent.Publisher.Bytes(), - }, nil -} - // ToOperations converts the given model format to Protobuf format. func ToOperations(ops []operations.Operation) ([]*api.Operation, error) { var pbOperations []*api.Operation diff --git a/api/types/change_summary_test.go b/api/types/change_summary_test.go index 7a9a729d5..773a3b021 100644 --- a/api/types/change_summary_test.go +++ b/api/types/change_summary_test.go @@ -122,7 +122,7 @@ func TestChangeSummary(t *testing.T) { PageSize: 3, IsForward: true, }, lastSeq) - assert.Equal(t, int64(lastSeq+1), from) - assert.Equal(t, int64(lastSeq+1), to) + assert.Equal(t, lastSeq+1, from) + assert.Equal(t, lastSeq+1, to) }) } diff --git a/api/yorkie/v1/resources.proto b/api/yorkie/v1/resources.proto index 46d879aad..7f6b3ca1b 100644 --- a/api/yorkie/v1/resources.proto +++ b/api/yorkie/v1/resources.proto @@ -95,6 +95,10 @@ message Operation { TimeTicket executed_at = 6; map attributes = 7; } + // NOTE(hackerwins): Select Operation is not used in the current version. + // In the previous version, it was used to represent selection of Text. + // However, it has been replaced by Presence now. It is retained for backward + // compatibility purposes. message Select { TimeTicket parent_created_at = 1; TextNodePos from = 2; diff --git a/cmd/yorkie/server.go b/cmd/yorkie/server.go index 583188698..3fdb18a97 100644 --- a/cmd/yorkie/server.go +++ b/cmd/yorkie/server.go @@ -51,12 +51,6 @@ var ( authWebhookCacheAuthTTL time.Duration authWebhookCacheUnauthTTL time.Duration - etcdEndpoints []string - etcdDialTimeout time.Duration - etcdUsername string - etcdPassword string - etcdLockLeaseTime time.Duration - conf = server.NewConfig() ) diff --git a/pkg/document/crdt/primitive.go b/pkg/document/crdt/primitive.go index 0308db5c9..c109007aa 100644 --- a/pkg/document/crdt/primitive.go +++ b/pkg/document/crdt/primitive.go @@ -52,7 +52,7 @@ func ValueFromBytes(valueType ValueType, value []byte) interface{} { return false case Integer: val := int32(binary.LittleEndian.Uint32(value)) - return int32(val) + return val case Long: return int64(binary.LittleEndian.Uint64(value)) case Double: diff --git a/pkg/document/crdt/tree.go b/pkg/document/crdt/tree.go index 0e0894676..efd14500e 100644 --- a/pkg/document/crdt/tree.go +++ b/pkg/document/crdt/tree.go @@ -117,7 +117,7 @@ func NewTreeNode(pos *TreePos, nodeType string, attributes *RHT, value ...string // Type returns the type of the Node. func (n *TreeNode) Type() string { - return string(n.IndexTreeNode.Type) + return n.IndexTreeNode.Type } // Len returns the length of the Node. diff --git a/pkg/index/tree.go b/pkg/index/tree.go index d0b29ab63..468ff3a3a 100644 --- a/pkg/index/tree.go +++ b/pkg/index/tree.go @@ -107,21 +107,6 @@ func postorderTraversal[V Value](node *Node[V], callback func(node *Node[V], dep callback(node, depth) } -// postorderTraversalAll traverses the whole tree (include tombstones) with postorder traversal. -func postorderTraversalAll[V Value](node *Node[V], callback func(node *Node[V], depth int) error, depth int) error { - if node == nil { - return nil - } - - for _, child := range node.children { - if err := postorderTraversalAll(child, callback, depth+1); err != nil { - return err - } - } - - return callback(node, depth) -} - // nodesBetween iterates the nodes between the given range. // If the given range is collapsed, the callback is not called. // It traverses the tree with postorder traversal. @@ -193,11 +178,6 @@ func Traverse[V Value](tree *Tree[V], callback func(node *Node[V], depth int)) { postorderTraversal(tree.root, callback, 0) } -// TraverseAll traverses the whole tree (include tombstones) with postorder traversal. -func TraverseAll[V Value](tree *Tree[V], callback func(node *Node[V], depth int) error) error { - return postorderTraversalAll(tree.root, callback, 0) -} - // Value represents the data stored in the nodes of Tree. type Value interface { IsRemoved() bool diff --git a/server/backend/database/database.go b/server/backend/database/database.go index 2d4922fee..894f89e93 100644 --- a/server/backend/database/database.go +++ b/server/backend/database/database.go @@ -47,9 +47,6 @@ var ( // ErrDocumentNotFound is returned when the document could not be found. ErrDocumentNotFound = errors.New("document not found") - // ErrClientDocNotFound is returned when mapping between client and document could not be found. - ErrClientDocNotFound = errors.New("client document not found") - // ErrConflictOnUpdate is returned when a conflict occurs during update. ErrConflictOnUpdate = errors.New("conflict on update") diff --git a/server/backend/database/project_info.go b/server/backend/database/project_info.go index 2be73d0d6..8c5fe7eca 100644 --- a/server/backend/database/project_info.go +++ b/server/backend/database/project_info.go @@ -81,22 +81,6 @@ func NewProjectInfo(name string, owner types.ID, clientDeactivateThreshold strin } } -// ToProjectInfo converts the given types.Project to ProjectInfo. -func ToProjectInfo(project *types.Project) *ProjectInfo { - return &ProjectInfo{ - ID: project.ID, - Name: project.Name, - Owner: project.Owner, - PublicKey: project.PublicKey, - SecretKey: project.SecretKey, - AuthWebhookURL: project.AuthWebhookURL, - AuthWebhookMethods: project.AuthWebhookMethods, - ClientDeactivateThreshold: project.ClientDeactivateThreshold, - CreatedAt: project.CreatedAt, - UpdatedAt: project.UpdatedAt, - } -} - // DeepCopy returns a deep copy of the ProjectInfo. func (i *ProjectInfo) DeepCopy() *ProjectInfo { if i == nil { diff --git a/server/users/users.go b/server/users/users.go index cf158a0ae..e24d383f0 100644 --- a/server/users/users.go +++ b/server/users/users.go @@ -38,7 +38,7 @@ func SignUp( return nil, fmt.Errorf("cannot hash password: %w", err) } - info, err := be.DB.CreateUserInfo(ctx, username, string(hashed)) + info, err := be.DB.CreateUserInfo(ctx, username, hashed) if err != nil { return nil, err } diff --git a/test/bench/grpc_bench_test.go b/test/bench/grpc_bench_test.go index 05650a643..254bed7f1 100644 --- a/test/bench/grpc_bench_test.go +++ b/test/bench/grpc_bench_test.go @@ -33,7 +33,6 @@ import ( "github.com/yorkie-team/yorkie/client" "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/presence" "github.com/yorkie-team/yorkie/server" "github.com/yorkie-team/yorkie/server/backend/database" @@ -105,7 +104,7 @@ func benchmarkUpdateProject(ctx context.Context, b *testing.B, cnt int, adminCli for i := 0; i < cnt; i++ { name := fmt.Sprintf("name%d", i) authWebhookURL := fmt.Sprintf("http://authWebhookURL%d", i) - authWebhookMethods := []string{} + var authWebhookMethods []string for _, m := range types.AuthMethods() { authWebhookMethods = append(authWebhookMethods, string(m)) } @@ -203,7 +202,7 @@ func BenchmarkRPC(b *testing.B) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(b))) + d1 := document.New(helper.TestDocKey(b)) err := c1.Attach(ctx, d1) assert.NoError(b, err) testKey1 := "testKey1" @@ -213,7 +212,7 @@ func BenchmarkRPC(b *testing.B) { }) assert.NoError(b, err) - d2 := document.New(key.Key(helper.TestDocKey(b))) + d2 := document.New(helper.TestDocKey(b)) err = c2.Attach(ctx, d2) assert.NoError(b, err) testKey2 := "testKey2" @@ -268,8 +267,8 @@ func BenchmarkRPC(b *testing.B) { defer cleanupClients(b, clients) ctx := context.Background() - doc1 := document.New(key.Key(helper.TestDocKey(b))) - doc2 := document.New(key.Key(helper.TestDocKey(b))) + doc1 := document.New(helper.TestDocKey(b)) + doc2 := document.New(helper.TestDocKey(b)) err := doc1.Update(func(root *json.Object, p *presence.Presence) error { text := root.SetNewText("k1") diff --git a/test/integration/document_test.go b/test/integration/document_test.go index 2a5981c3d..c190fe9ae 100644 --- a/test/integration/document_test.go +++ b/test/integration/document_test.go @@ -30,7 +30,6 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/innerpresence" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/presence" "github.com/yorkie-team/yorkie/test/helper" ) @@ -68,7 +67,7 @@ func TestDocument(t *testing.T) { assert.True(t, doc2.IsAttached()) assert.Equal(t, `{"k1":"v2"}`, doc2.Marshal()) - doc3 := document.New(key.Key("invalid$key")) + doc3 := document.New("invalid$key") err = c1.Attach(ctx, doc3) assert.Error(t, err) })