diff --git a/admin/client.go b/admin/client.go index a837a8307..192bd7715 100644 --- a/admin/client.go +++ b/admin/client.go @@ -238,7 +238,7 @@ func (c *Client) UpdateProject( func (c *Client) ListDocuments( ctx context.Context, projectName string, - previousRefKey types.DocRefKey, + previousID string, pageSize int32, isForward bool, includeSnapshot bool, @@ -247,8 +247,7 @@ func (c *Client) ListDocuments( ctx, connect.NewRequest(&api.ListDocumentsRequest{ ProjectName: projectName, - PreviousId: previousRefKey.ID.String(), - PreviousKey: previousRefKey.Key.String(), + PreviousId: previousID, PageSize: pageSize, IsForward: isForward, IncludeSnapshot: includeSnapshot, diff --git a/api/types/resource_ref_key.go b/api/types/resource_ref_key.go index 5dc669d85..634d75f7a 100644 --- a/api/types/resource_ref_key.go +++ b/api/types/resource_ref_key.go @@ -17,47 +17,21 @@ package types import ( - "errors" "fmt" - "strings" - - "github.com/yorkie-team/yorkie/pkg/document/key" ) // EmptyDocRefKey is an empty value of DocRefKey. var EmptyDocRefKey = DocRefKey{"", ""} -// ErrInvalidDocRefKeyStringFormat is returned when the input of DocRefKey Set is invalid. -var ErrInvalidDocRefKeyStringFormat = errors.New("use the format 'docKey,docID' for the string of the docRefKey") - // DocRefKey represents an identifier used to reference a document. type DocRefKey struct { - Key key.Key - ID ID + ProjectID ID + DocID ID } // String returns the string representation of the given DocRefKey. func (r DocRefKey) String() string { - return fmt.Sprintf("Document (%s.%s)", r.Key, r.ID) -} - -// Set parses the given string (format: `{docKey},{docID}`) and assigns the values -// to the given DocRefKey. -// NOTE(sejongk): This function is necessary for Viper, an external command-line module. -func (r *DocRefKey) Set(v string) error { - parsed := strings.Split(v, ",") - if len(parsed) != 2 { - return ErrInvalidDocRefKeyStringFormat - } - r.Key = key.Key(parsed[0]) - r.ID = ID(parsed[1]) - return nil -} - -// Type returns the type string of the given DocRefKey, used in cli help text. -// NOTE(sejongk): This function is necessray for Viper, an external command-line module. -func (r DocRefKey) Type() string { - return "DocumentRefKey" + return fmt.Sprintf("Document (%s.%s)", r.ProjectID, r.DocID) } // SnapshotRefKey represents an identifier used to reference a snapshot. @@ -68,5 +42,5 @@ type SnapshotRefKey struct { // String returns the string representation of the given SnapshotRefKey. func (r SnapshotRefKey) String() string { - return fmt.Sprintf("Snapshot (%s.%s.%d)", r.DocRefKey.Key, r.DocRefKey.ID, r.ServerSeq) + return fmt.Sprintf("Snapshot (%s.%s.%d)", r.ProjectID, r.DocID, r.ServerSeq) } diff --git a/api/types/resource_ref_key_test.go b/api/types/resource_ref_key_test.go deleted file mode 100644 index 7ed345f7d..000000000 --- a/api/types/resource_ref_key_test.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2023 The Yorkie Authors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package types_test - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/yorkie-team/yorkie/api/types" - "github.com/yorkie-team/yorkie/pkg/document/key" -) - -func TestResourceRefKey(t *testing.T) { - t.Run("DocRefKey Set test", func(t *testing.T) { - docKey := key.Key("docKey") - docID := types.ID("docID") - docRef := types.DocRefKey{} - - // 01. Give an invalid input to Set. - err := docRef.Set("abc") - assert.ErrorIs(t, err, types.ErrInvalidDocRefKeyStringFormat) - - // 02. Give a valid input to Set. - err = docRef.Set(fmt.Sprintf("%s,%s", docKey, docID)) - assert.NoError(t, err) - assert.Equal(t, docKey, docRef.Key) - assert.Equal(t, docID, docRef.ID) - }) -} diff --git a/api/yorkie/v1/admin.pb.go b/api/yorkie/v1/admin.pb.go index b60646351..7ff402031 100644 --- a/api/yorkie/v1/admin.pb.go +++ b/api/yorkie/v1/admin.pb.go @@ -620,7 +620,6 @@ type ListDocumentsRequest struct { unknownFields protoimpl.UnknownFields ProjectName string `protobuf:"bytes,1,opt,name=project_name,json=projectName,proto3" json:"project_name,omitempty"` - PreviousKey string `protobuf:"bytes,6,opt,name=previous_key,json=previousKey,proto3" json:"previous_key,omitempty"` PreviousId string `protobuf:"bytes,2,opt,name=previous_id,json=previousId,proto3" json:"previous_id,omitempty"` PageSize int32 `protobuf:"varint,3,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` IsForward bool `protobuf:"varint,4,opt,name=is_forward,json=isForward,proto3" json:"is_forward,omitempty"` @@ -666,13 +665,6 @@ func (x *ListDocumentsRequest) GetProjectName() string { return "" } -func (x *ListDocumentsRequest) GetPreviousKey() string { - if x != nil { - return x.PreviousKey - } - return "" -} - func (x *ListDocumentsRequest) GetPreviousId() string { if x != nil { return x.PreviousId @@ -1365,160 +1357,157 @@ var file_yorkie_v1_admin_proto_rawDesc = []byte{ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0xe4, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0xc1, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x6b, 0x65, - 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, - 0x73, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x69, - 0x6f, 0x75, 0x73, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, - 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, - 0x64, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x73, 0x6e, 0x61, - 0x70, 0x73, 0x68, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x6e, 0x63, - 0x6c, 0x75, 0x64, 0x65, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x22, 0x51, 0x0a, 0x15, - 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x75, 0x6d, - 0x6d, 0x61, 0x72, 0x79, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, - 0x5a, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, - 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x4d, 0x0a, 0x13, 0x47, - 0x65, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x36, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, - 0x52, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x7a, 0x0a, 0x1c, 0x52, 0x65, - 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x41, 0x64, - 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, - 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, - 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x22, 0x1f, 0x0a, 0x1d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, - 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x53, - 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, + 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, + 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x12, 0x29, + 0x0a, 0x10, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, + 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, + 0x65, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x22, 0x51, 0x0a, 0x15, 0x4c, 0x69, 0x73, + 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x38, 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x5a, 0x0a, 0x12, + 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x5f, 0x73, 0x65, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x42, 0x02, 0x30, 0x01, - 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x71, 0x22, 0x53, 0x0a, 0x17, 0x47, - 0x65, 0x74, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, - 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, - 0x6f, 0x74, 0x12, 0x1c, 0x0a, 0x07, 0x6c, 0x61, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x42, 0x02, 0x30, 0x01, 0x52, 0x07, 0x6c, 0x61, 0x6d, 0x70, 0x6f, 0x72, 0x74, - 0x22, 0x6e, 0x0a, 0x16, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, - 0x65, 0x72, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, - 0x22, 0x74, 0x0a, 0x17, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, - 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x09, - 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x09, 0x64, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xbd, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, - 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, - 0x0c, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x4b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, - 0x73, 0x65, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x42, 0x02, 0x30, 0x01, 0x52, 0x0b, 0x70, - 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x53, 0x65, 0x71, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, - 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x66, 0x6f, - 0x72, 0x77, 0x61, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x46, - 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x22, 0x42, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, - 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, - 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, - 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, - 0x65, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x32, 0xf5, 0x07, 0x0a, 0x0c, 0x41, - 0x64, 0x6d, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x53, - 0x69, 0x67, 0x6e, 0x55, 0x70, 0x12, 0x18, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x55, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x19, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, - 0x55, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x05, - 0x4c, 0x6f, 0x67, 0x49, 0x6e, 0x12, 0x17, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x49, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, - 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x49, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0d, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x2e, 0x79, 0x6f, - 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x79, - 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, - 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x51, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, - 0x12, 0x1e, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, - 0x74, 0x12, 0x1c, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, - 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1d, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, - 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x54, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, - 0x74, 0x12, 0x1f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x0b, - 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x2e, 0x79, 0x6f, - 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x79, 0x6f, 0x72, - 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6c, 0x0a, 0x15, - 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, - 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x27, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x42, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, - 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x4d, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x36, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x08, 0x64, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x7a, 0x0a, 0x1c, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x0f, 0x47, 0x65, - 0x74, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x21, 0x2e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x66, 0x6f, + 0x72, 0x63, 0x65, 0x22, 0x1f, 0x0a, 0x1d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x53, 0x6e, 0x61, 0x70, + 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, + 0x73, 0x65, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x42, 0x02, 0x30, 0x01, 0x52, 0x09, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x71, 0x22, 0x53, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, + 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x12, + 0x1c, 0x0a, 0x07, 0x6c, 0x61, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, + 0x42, 0x02, 0x30, 0x01, 0x52, 0x07, 0x6c, 0x61, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x6e, 0x0a, + 0x16, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x74, 0x0a, + 0x17, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, + 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, + 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x64, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x79, + 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x22, 0xbd, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, + 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, + 0x12, 0x25, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x73, 0x65, 0x71, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x42, 0x02, 0x30, 0x01, 0x52, 0x0b, 0x70, 0x72, 0x65, 0x76, + 0x69, 0x6f, 0x75, 0x73, 0x53, 0x65, 0x71, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x66, 0x6f, 0x72, 0x77, 0x61, + 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x46, 0x6f, 0x72, 0x77, + 0x61, 0x72, 0x64, 0x22, 0x42, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x07, 0x63, 0x68, + 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x79, 0x6f, + 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x07, + 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x32, 0xf5, 0x07, 0x0a, 0x0c, 0x41, 0x64, 0x6d, 0x69, + 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e, + 0x55, 0x70, 0x12, 0x18, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x69, 0x67, 0x6e, 0x55, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x79, + 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x55, 0x70, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x05, 0x4c, 0x6f, 0x67, + 0x49, 0x6e, 0x12, 0x17, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, + 0x6f, 0x67, 0x49, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x79, 0x6f, + 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x49, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, + 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x51, 0x0a, + 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1e, 0x2e, + 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, + 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x4b, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1c, + 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x79, + 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, + 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, + 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x0b, 0x47, 0x65, 0x74, + 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6c, 0x0a, 0x15, 0x52, 0x65, 0x6d, + 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x41, 0x64, 0x6d, + 0x69, 0x6e, 0x12, 0x27, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x41, + 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x79, 0x6f, + 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x6e, + 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x21, 0x2e, 0x79, 0x6f, 0x72, + 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, + 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x6e, 0x61, - 0x70, 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x22, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, - 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x0f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x21, 0x2e, 0x79, 0x6f, 0x72, 0x6b, + 0x70, 0x73, 0x68, 0x6f, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x0f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x21, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x79, - 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, - 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, - 0x73, 0x12, 0x1d, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1e, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x65, 0x61, - 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x79, 0x6f, 0x72, - 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x4e, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x1d, + 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, + 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x68, + 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x65, 0x61, 0x6d, 0x2f, 0x79, + 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, + 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/yorkie/v1/admin.proto b/api/yorkie/v1/admin.proto index 785881fd6..753e3181c 100644 --- a/api/yorkie/v1/admin.proto +++ b/api/yorkie/v1/admin.proto @@ -94,7 +94,6 @@ message UpdateProjectResponse { message ListDocumentsRequest { string project_name = 1; - string previous_key = 6; string previous_id = 2; int32 page_size = 3; bool is_forward = 4; diff --git a/api/yorkie/v1/yorkie.pb.go b/api/yorkie/v1/yorkie.pb.go index 0e30fa035..0a49dba9f 100644 --- a/api/yorkie/v1/yorkie.pb.go +++ b/api/yorkie/v1/yorkie.pb.go @@ -447,9 +447,8 @@ type WatchDocumentRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - DocumentKey string `protobuf:"bytes,3,opt,name=document_key,json=documentKey,proto3" json:"document_key,omitempty"` - DocumentId string `protobuf:"bytes,2,opt,name=document_id,json=documentId,proto3" json:"document_id,omitempty"` + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + DocumentId string `protobuf:"bytes,2,opt,name=document_id,json=documentId,proto3" json:"document_id,omitempty"` } func (x *WatchDocumentRequest) Reset() { @@ -491,13 +490,6 @@ func (x *WatchDocumentRequest) GetClientId() string { return "" } -func (x *WatchDocumentRequest) GetDocumentKey() string { - if x != nil { - return x.DocumentKey - } - return "" -} - func (x *WatchDocumentRequest) GetDocumentId() string { if x != nil { return x.DocumentId @@ -819,11 +811,10 @@ type BroadcastRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - DocumentKey string `protobuf:"bytes,5,opt,name=document_key,json=documentKey,proto3" json:"document_key,omitempty"` - DocumentId string `protobuf:"bytes,2,opt,name=document_id,json=documentId,proto3" json:"document_id,omitempty"` - Topic string `protobuf:"bytes,3,opt,name=topic,proto3" json:"topic,omitempty"` - Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + DocumentId string `protobuf:"bytes,2,opt,name=document_id,json=documentId,proto3" json:"document_id,omitempty"` + Topic string `protobuf:"bytes,3,opt,name=topic,proto3" json:"topic,omitempty"` + Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` } func (x *BroadcastRequest) Reset() { @@ -865,13 +856,6 @@ func (x *BroadcastRequest) GetClientId() string { return "" } -func (x *BroadcastRequest) GetDocumentKey() string { - if x != nil { - return x.DocumentKey - } - return "" -} - func (x *BroadcastRequest) GetDocumentId() string { if x != nil { return x.DocumentId @@ -1028,29 +1012,41 @@ var file_yorkie_v1_yorkie_proto_rawDesc = []byte{ 0x65, 0x12, 0x36, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x0a, 0x63, - 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x22, 0x77, 0x0a, 0x14, 0x57, 0x61, 0x74, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x22, 0x54, 0x0a, 0x14, 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x21, - 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, - 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1f, + 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, + 0xd8, 0x01, 0x0a, 0x15, 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x0e, 0x69, 0x6e, 0x69, + 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x61, + 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0e, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x44, 0x6f, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, + 0x74, 0x1a, 0x2f, 0x0a, 0x0e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x73, 0x42, 0x06, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x8d, 0x01, 0x0a, 0x15, 0x52, + 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x49, 0x64, 0x22, 0xd8, 0x01, 0x0a, 0x15, 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x0e, - 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0e, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, - 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x05, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x2f, 0x0a, 0x0e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x49, 0x64, 0x73, 0x42, 0x06, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x8d, 0x01, - 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x49, 0x64, 0x12, 0x36, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x63, + 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x0a, + 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x22, 0x50, 0x0a, 0x16, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x70, + 0x61, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x79, 0x6f, 0x72, 0x6b, + 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, + 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x22, 0xab, 0x01, 0x0a, + 0x16, 0x50, 0x75, 0x73, 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, @@ -1058,90 +1054,74 @@ var file_yorkie_v1_yorkie_proto_rawDesc = []byte{ 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, - 0x6b, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x22, 0x50, 0x0a, - 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x67, - 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x79, - 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, - 0x61, 0x63, 0x6b, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x22, - 0xab, 0x01, 0x0a, 0x16, 0x50, 0x75, 0x73, 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, - 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, - 0x67, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, - 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, - 0x50, 0x61, 0x63, 0x6b, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, - 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x73, 0x68, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x08, 0x70, 0x75, 0x73, 0x68, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x51, 0x0a, - 0x17, 0x50, 0x75, 0x73, 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, - 0x67, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, - 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, - 0x50, 0x61, 0x63, 0x6b, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, - 0x22, 0xa3, 0x01, 0x0a, 0x10, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, - 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, - 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x18, 0x0a, 0x07, - 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x13, 0x0a, 0x11, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, - 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd0, 0x05, 0x0a, 0x0d, - 0x59, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, - 0x0e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, - 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, 0x69, - 0x76, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x21, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, - 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5d, 0x0a, 0x10, 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, - 0x76, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x22, 0x2e, 0x79, 0x6f, 0x72, - 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, - 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, - 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x61, 0x63, 0x74, - 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x0e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x44, - 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x79, 0x6f, 0x72, 0x6b, - 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, - 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x12, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x74, - 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, - 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x0e, 0x52, 0x65, 0x6d, 0x6f, 0x76, - 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, - 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x79, 0x6f, - 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x5a, 0x0a, 0x0f, 0x50, 0x75, 0x73, 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, - 0x67, 0x65, 0x73, 0x12, 0x21, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x50, 0x75, 0x73, 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x67, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x0d, - 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x2e, - 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, - 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, - 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, - 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x30, 0x01, 0x12, 0x48, 0x0a, 0x09, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, - 0x74, 0x12, 0x1b, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x72, - 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, - 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x72, 0x6f, 0x61, 0x64, - 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, - 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x65, 0x61, 0x6d, 0x2f, 0x79, 0x6f, - 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, - 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6b, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x12, 0x1b, 0x0a, + 0x09, 0x70, 0x75, 0x73, 0x68, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x08, 0x70, 0x75, 0x73, 0x68, 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x51, 0x0a, 0x17, 0x50, 0x75, + 0x73, 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, + 0x70, 0x61, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x79, 0x6f, 0x72, + 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, + 0x6b, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x22, 0x80, 0x01, + 0x0a, 0x10, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, + 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, + 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x22, 0x13, 0x0a, 0x11, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd0, 0x05, 0x0a, 0x0d, 0x59, 0x6f, 0x72, 0x6b, 0x69, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x0e, 0x41, 0x63, 0x74, 0x69, 0x76, + 0x61, 0x74, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, + 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x79, 0x6f, + 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x5d, 0x0a, 0x10, 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x12, 0x22, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x57, 0x0a, 0x0e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x12, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, + 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, + 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x20, 0x2e, 0x79, 0x6f, 0x72, + 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x79, + 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x57, 0x0a, 0x0e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x0f, 0x50, 0x75, + 0x73, 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x21, 0x2e, + 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x50, 0x75, + 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x22, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x75, 0x73, + 0x68, 0x50, 0x75, 0x6c, 0x6c, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x0d, 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x48, + 0x0a, 0x09, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x12, 0x1b, 0x2e, 0x79, 0x6f, + 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, + 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, + 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, + 0x69, 0x65, 0x2d, 0x74, 0x65, 0x61, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/yorkie/v1/yorkie.proto b/api/yorkie/v1/yorkie.proto index 05c3cd7ee..8ca20e120 100644 --- a/api/yorkie/v1/yorkie.proto +++ b/api/yorkie/v1/yorkie.proto @@ -77,7 +77,6 @@ message DetachDocumentResponse { message WatchDocumentRequest { string client_id = 1; - string document_key = 3; string document_id = 2; } @@ -115,7 +114,6 @@ message PushPullChangesResponse { message BroadcastRequest { string client_id = 1; - string document_key = 5; string document_id = 2; string topic = 3; bytes payload = 4; diff --git a/build/docker/sharding/scripts/init-mongos1.js b/build/docker/sharding/scripts/init-mongos1.js index cd875933a..bf43e2884 100644 --- a/build/docker/sharding/scripts/init-mongos1.js +++ b/build/docker/sharding/scripts/init-mongos1.js @@ -10,27 +10,28 @@ function findAnotherShard(shard) { } function shardOfChunk(minKeyOfChunk) { - return db.getSiblingDB("config").chunks.findOne({ min: { key: minKeyOfChunk } }).shard + return db.getSiblingDB("config").chunks.findOne({ min: { project_id: minKeyOfChunk } }).shard } // Shard the database for the mongo client test const mongoClientDB = "test-yorkie-meta-mongo-client" sh.enableSharding(mongoClientDB) -sh.shardCollection(mongoClientDB + ".documents", { key: 1 }) -sh.shardCollection(mongoClientDB + ".changes", { doc_key: 1 }) -sh.shardCollection(mongoClientDB + ".snapshots", { doc_key: 1 }) -sh.shardCollection(mongoClientDB + ".syncedseqs", { doc_key: 1 }) +sh.shardCollection(mongoClientDB + ".documents", { project_id: 1 }) +sh.shardCollection(mongoClientDB + ".changes", { doc_id: 1 }) +sh.shardCollection(mongoClientDB + ".snapshots", { doc_id: 1 }) +sh.shardCollection(mongoClientDB + ".syncedseqs", { doc_id: 1 }) -// Split the inital range at "duplicateIDTestDocKey5" to allow doc_ids duplicate in different shards. -const docSplitKey = "duplicateIDTestDocKey5" -sh.splitAt(mongoClientDB + ".documents", { key: docSplitKey }) +// Split the inital range at `splitPoint` to allow doc_ids duplicate in different shards. +const splitPoint = ObjectId("500000000000000000000000") +sh.splitAt(mongoClientDB + ".documents", { project_id: splitPoint }) // Move the chunk to another shard. -db.adminCommand({ moveChunk: mongoClientDB + ".documents", find: { key: docSplitKey }, to: findAnotherShard(shardOfChunk(docSplitKey)) }) +db.adminCommand({ moveChunk: mongoClientDB + ".documents", find: { project_id: splitPoint }, to: findAnotherShard(shardOfChunk(splitPoint)) }) // Shard the database for the server test const serverDB = "test-yorkie-meta-server" sh.enableSharding(serverDB) -sh.shardCollection(serverDB + ".documents", { key: 1 }) -sh.shardCollection(serverDB + ".changes", { doc_key: 1 }) -sh.shardCollection(serverDB + ".snapshots", { doc_key: 1 }) -sh.shardCollection(serverDB + ".syncedseqs", { doc_key: 1 }) +sh.shardCollection(serverDB + ".documents", { project_id: 1 }) +sh.shardCollection(serverDB + ".changes", { doc_id: 1 }) +sh.shardCollection(serverDB + ".snapshots", { doc_id: 1 }) +sh.shardCollection(serverDB + ".syncedseqs", { doc_id: 1 }) + diff --git a/client/client.go b/client/client.go index ed29c238e..f1673a9ac 100644 --- a/client/client.go +++ b/client/client.go @@ -424,9 +424,8 @@ func (c *Client) Watch( stream, err := c.client.WatchDocument( ctx, withShardKey(connect.NewRequest(&api.WatchDocumentRequest{ - ClientId: c.id.String(), - DocumentKey: doc.Key().String(), - DocumentId: attachment.docID.String(), + ClientId: c.id.String(), + DocumentId: attachment.docID.String(), }, ), c.options.APIKey, doc.Key().String())) if err != nil { @@ -698,11 +697,10 @@ func (c *Client) broadcast(ctx context.Context, doc *document.Document, topic st _, err := c.client.Broadcast( ctx, withShardKey(connect.NewRequest(&api.BroadcastRequest{ - ClientId: c.id.String(), - DocumentKey: doc.Key().String(), - DocumentId: attachment.docID.String(), - Topic: topic, - Payload: payload, + ClientId: c.id.String(), + DocumentId: attachment.docID.String(), + Topic: topic, + Payload: payload, }, ), c.options.APIKey, doc.Key().String())) if err != nil { diff --git a/cmd/yorkie/document/list.go b/cmd/yorkie/document/list.go index 3dda31986..71d886e87 100644 --- a/cmd/yorkie/document/list.go +++ b/cmd/yorkie/document/list.go @@ -26,15 +26,14 @@ import ( "github.com/spf13/viper" "github.com/yorkie-team/yorkie/admin" - "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/cmd/yorkie/config" "github.com/yorkie-team/yorkie/pkg/units" ) var ( - previousRefKey types.DocRefKey - pageSize int32 - isForward bool + previousID string + pageSize int32 + isForward bool ) func newListCommand() *cobra.Command { @@ -64,7 +63,7 @@ func newListCommand() *cobra.Command { }() ctx := context.Background() - documents, err := cli.ListDocuments(ctx, projectName, previousRefKey, pageSize, isForward, true) + documents, err := cli.ListDocuments(ctx, projectName, previousID, pageSize, isForward, true) if err != nil { return err } @@ -101,10 +100,11 @@ func newListCommand() *cobra.Command { func init() { cmd := newListCommand() - cmd.Flags().Var( - &previousRefKey, - "previous-refKey", - "The previous document refKey to start from. Use the format 'docKey,docID' for the input.", + cmd.Flags().StringVar( + &previousID, + "previous-id", + "", + "The previous document ID to start from", ) cmd.Flags().Int32Var( &pageSize, diff --git a/server/backend/database/change_info.go b/server/backend/database/change_info.go index 47976b15b..f35635d6c 100644 --- a/server/backend/database/change_info.go +++ b/server/backend/database/change_info.go @@ -28,7 +28,6 @@ import ( api "github.com/yorkie-team/yorkie/api/yorkie/v1" "github.com/yorkie-team/yorkie/pkg/document/change" "github.com/yorkie-team/yorkie/pkg/document/innerpresence" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/operations" "github.com/yorkie-team/yorkie/pkg/document/time" ) @@ -42,7 +41,7 @@ var ErrDecodeOperationFailed = errors.New("decode operations failed") // ChangeInfo is a structure representing information of a change. type ChangeInfo struct { ID types.ID `bson:"_id"` - DocKey key.Key `bson:"doc_key"` + ProjectID types.ID `bson:"project_id"` DocID types.ID `bson:"doc_id"` ServerSeq int64 `bson:"server_seq"` ClientSeq uint32 `bson:"client_seq"` diff --git a/server/backend/database/client_info.go b/server/backend/database/client_info.go index a9a98096c..570b380aa 100644 --- a/server/backend/database/client_info.go +++ b/server/backend/database/client_info.go @@ -55,7 +55,7 @@ type ClientDocInfo struct { } // ClientDocInfoMap is a map that associates DocRefKey with ClientDocInfo instances. -type ClientDocInfoMap map[types.DocRefKey]*ClientDocInfo +type ClientDocInfoMap map[types.ID]*ClientDocInfo // ClientInfo is a structure representing information of a client. type ClientInfo struct { @@ -104,22 +104,22 @@ func (i *ClientInfo) Deactivate() { } // AttachDocument attaches the given document to this client. -func (i *ClientInfo) AttachDocument(refKey types.DocRefKey) error { +func (i *ClientInfo) AttachDocument(docID types.ID) error { if i.Status != ClientActivated { return fmt.Errorf("client(%s) attaches %s: %w", - i.ID, refKey, ErrClientNotActivated) + i.ID, docID, ErrClientNotActivated) } if i.Documents == nil { - i.Documents = make(map[types.DocRefKey]*ClientDocInfo) + i.Documents = make(map[types.ID]*ClientDocInfo) } - if i.hasDocument(refKey) && i.Documents[refKey].Status == DocumentAttached { + if i.hasDocument(docID) && i.Documents[docID].Status == DocumentAttached { return fmt.Errorf("client(%s) attaches %s: %w", - i.ID, refKey, ErrDocumentAlreadyAttached) + i.ID, docID, ErrDocumentAlreadyAttached) } - i.Documents[refKey] = &ClientDocInfo{ + i.Documents[docID] = &ClientDocInfo{ Status: DocumentAttached, ServerSeq: 0, ClientSeq: 0, @@ -130,46 +130,46 @@ func (i *ClientInfo) AttachDocument(refKey types.DocRefKey) error { } // DetachDocument detaches the given document from this client. -func (i *ClientInfo) DetachDocument(refKey types.DocRefKey) error { - if err := i.EnsureDocumentAttached(refKey); err != nil { +func (i *ClientInfo) DetachDocument(docID types.ID) error { + if err := i.EnsureDocumentAttached(docID); err != nil { return err } - i.Documents[refKey].Status = DocumentDetached - i.Documents[refKey].ClientSeq = 0 - i.Documents[refKey].ServerSeq = 0 + i.Documents[docID].Status = DocumentDetached + i.Documents[docID].ClientSeq = 0 + i.Documents[docID].ServerSeq = 0 i.UpdatedAt = time.Now() return nil } // RemoveDocument removes the given document from this client. -func (i *ClientInfo) RemoveDocument(refKey types.DocRefKey) error { - if err := i.EnsureDocumentAttached(refKey); err != nil { +func (i *ClientInfo) RemoveDocument(docID types.ID) error { + if err := i.EnsureDocumentAttached(docID); err != nil { return err } - i.Documents[refKey].Status = DocumentRemoved - i.Documents[refKey].ClientSeq = 0 - i.Documents[refKey].ServerSeq = 0 + i.Documents[docID].Status = DocumentRemoved + i.Documents[docID].ClientSeq = 0 + i.Documents[docID].ServerSeq = 0 i.UpdatedAt = time.Now() return nil } // IsAttached returns whether the given document is attached to this client. -func (i *ClientInfo) IsAttached(refKey types.DocRefKey) (bool, error) { - if !i.hasDocument(refKey) { +func (i *ClientInfo) IsAttached(docID types.ID) (bool, error) { + if !i.hasDocument(docID) { return false, fmt.Errorf("check %s is attached: %w", - refKey, ErrDocumentNeverAttached) + docID, ErrDocumentNeverAttached) } - return i.Documents[refKey].Status == DocumentAttached, nil + return i.Documents[docID].Status == DocumentAttached, nil } // Checkpoint returns the checkpoint of the given document. -func (i *ClientInfo) Checkpoint(refKey types.DocRefKey) change.Checkpoint { - clientDocInfo := i.Documents[refKey] +func (i *ClientInfo) Checkpoint(docID types.ID) change.Checkpoint { + clientDocInfo := i.Documents[docID] if clientDocInfo == nil { return change.InitialCheckpoint } @@ -179,30 +179,30 @@ func (i *ClientInfo) Checkpoint(refKey types.DocRefKey) change.Checkpoint { // UpdateCheckpoint updates the checkpoint of the given document. func (i *ClientInfo) UpdateCheckpoint( - refKey types.DocRefKey, + docID types.ID, cp change.Checkpoint, ) error { - if !i.hasDocument(refKey) { - return fmt.Errorf("update checkpoint in %s: %w", refKey, ErrDocumentNeverAttached) + if !i.hasDocument(docID) { + return fmt.Errorf("update checkpoint in %s: %w", docID, ErrDocumentNeverAttached) } - i.Documents[refKey].ServerSeq = cp.ServerSeq - i.Documents[refKey].ClientSeq = cp.ClientSeq + i.Documents[docID].ServerSeq = cp.ServerSeq + i.Documents[docID].ClientSeq = cp.ClientSeq i.UpdatedAt = time.Now() return nil } // EnsureDocumentAttached ensures the given document is attached. -func (i *ClientInfo) EnsureDocumentAttached(refKey types.DocRefKey) error { +func (i *ClientInfo) EnsureDocumentAttached(docID types.ID) error { if i.Status != ClientActivated { return fmt.Errorf("ensure attached %s in client(%s): %w", - refKey, i.ID, ErrClientNotActivated) + docID, i.ID, ErrClientNotActivated) } - if !i.hasDocument(refKey) || i.Documents[refKey].Status != DocumentAttached { + if !i.hasDocument(docID) || i.Documents[docID].Status != DocumentAttached { return fmt.Errorf("ensure attached %s in client(%s): %w", - refKey, i.ID, ErrDocumentNotAttached) + docID, i.ID, ErrDocumentNotAttached) } return nil @@ -214,9 +214,9 @@ func (i *ClientInfo) DeepCopy() *ClientInfo { return nil } - documents := make(map[types.DocRefKey]*ClientDocInfo, len(i.Documents)) - for refKey, docInfo := range i.Documents { - documents[refKey] = &ClientDocInfo{ + documents := make(map[types.ID]*ClientDocInfo, len(i.Documents)) + for docID, docInfo := range i.Documents { + documents[docID] = &ClientDocInfo{ Status: docInfo.Status, ServerSeq: docInfo.ServerSeq, ClientSeq: docInfo.ClientSeq, @@ -234,6 +234,6 @@ func (i *ClientInfo) DeepCopy() *ClientInfo { } } -func (i *ClientInfo) hasDocument(refKey types.DocRefKey) bool { - return i.Documents != nil && i.Documents[refKey] != nil +func (i *ClientInfo) hasDocument(docID types.ID) bool { + return i.Documents != nil && i.Documents[docID] != nil } diff --git a/server/backend/database/client_info_test.go b/server/backend/database/client_info_test.go index ae83e29fd..bf06f693d 100644 --- a/server/backend/database/client_info_test.go +++ b/server/backend/database/client_info_test.go @@ -23,16 +23,16 @@ import ( "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/pkg/document/change" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/server/backend/database" ) func TestClientInfo(t *testing.T) { - dummyDocKey := key.Key("dummy") - dummyDocID := types.ID("000000000000000000000000") + dummyProjectID := types.ID("000000000000000000000000") + otherProjectID := types.ID("000000000000000000000001") + dummyDocID := types.ID("000000000000000000000001") dummyDocRefKey := types.DocRefKey{ - Key: dummyDocKey, - ID: dummyDocID, + ProjectID: dummyProjectID, + DocID: dummyDocID, } t.Run("attach/detach document test", func(t *testing.T) { @@ -40,34 +40,33 @@ func TestClientInfo(t *testing.T) { Status: database.ClientActivated, } - err := clientInfo.AttachDocument(dummyDocRefKey) + err := clientInfo.AttachDocument(dummyDocRefKey.DocID) assert.NoError(t, err) - isAttached, err := clientInfo.IsAttached(dummyDocRefKey) + isAttached, err := clientInfo.IsAttached(dummyDocRefKey.DocID) assert.NoError(t, err) assert.True(t, isAttached) - err = clientInfo.UpdateCheckpoint(dummyDocRefKey, change.MaxCheckpoint) + err = clientInfo.UpdateCheckpoint(dummyDocRefKey.DocID, change.MaxCheckpoint) assert.NoError(t, err) - err = clientInfo.EnsureDocumentAttached(dummyDocRefKey) + err = clientInfo.EnsureDocumentAttached(dummyDocRefKey.DocID) assert.NoError(t, err) - err = clientInfo.DetachDocument(dummyDocRefKey) + err = clientInfo.DetachDocument(dummyDocRefKey.DocID) assert.NoError(t, err) - isAttached, err = clientInfo.IsAttached(dummyDocRefKey) + isAttached, err = clientInfo.IsAttached(dummyDocRefKey.DocID) assert.NoError(t, err) assert.False(t, isAttached) - err = clientInfo.AttachDocument(dummyDocRefKey) + err = clientInfo.AttachDocument(dummyDocRefKey.DocID) assert.NoError(t, err) - isAttached, err = clientInfo.IsAttached(dummyDocRefKey) + isAttached, err = clientInfo.IsAttached(dummyDocRefKey.DocID) assert.NoError(t, err) assert.True(t, isAttached) }) t.Run("check if in project test", func(t *testing.T) { - dummyProjectID := types.ID("000000000000000000000000") clientInfo := database.ClientInfo{ ProjectID: dummyProjectID, } @@ -77,8 +76,6 @@ func TestClientInfo(t *testing.T) { }) t.Run("check if in project error test", func(t *testing.T) { - dummyProjectID := types.ID("000000000000000000000000") - otherProjectID := types.ID("000000000000000000000001") clientInfo := database.ClientInfo{ ProjectID: dummyProjectID, } @@ -92,15 +89,15 @@ func TestClientInfo(t *testing.T) { Status: database.ClientActivated, } - err := clientInfo.AttachDocument(dummyDocRefKey) + err := clientInfo.AttachDocument(dummyDocRefKey.DocID) assert.NoError(t, err) - isAttached, err := clientInfo.IsAttached(dummyDocRefKey) + isAttached, err := clientInfo.IsAttached(dummyDocRefKey.DocID) assert.NoError(t, err) assert.True(t, isAttached) clientInfo.Deactivate() - err = clientInfo.EnsureDocumentAttached(dummyDocRefKey) + err = clientInfo.EnsureDocumentAttached(dummyDocRefKey.DocID) assert.ErrorIs(t, err, database.ErrClientNotActivated) }) @@ -109,13 +106,13 @@ func TestClientInfo(t *testing.T) { Status: database.ClientDeactivated, } - err := clientInfo.AttachDocument(dummyDocRefKey) + err := clientInfo.AttachDocument(dummyDocRefKey.DocID) assert.ErrorIs(t, err, database.ErrClientNotActivated) - err = clientInfo.EnsureDocumentAttached(dummyDocRefKey) + err = clientInfo.EnsureDocumentAttached(dummyDocRefKey.DocID) assert.ErrorIs(t, err, database.ErrClientNotActivated) - err = clientInfo.DetachDocument(dummyDocRefKey) + err = clientInfo.DetachDocument(dummyDocRefKey.DocID) assert.ErrorIs(t, err, database.ErrClientNotActivated) }) @@ -123,7 +120,7 @@ func TestClientInfo(t *testing.T) { clientInfo := database.ClientInfo{ Status: database.ClientActivated, } - err := clientInfo.DetachDocument(dummyDocRefKey) + err := clientInfo.DetachDocument(dummyDocRefKey.DocID) assert.ErrorIs(t, err, database.ErrDocumentNotAttached) }) @@ -131,10 +128,10 @@ func TestClientInfo(t *testing.T) { clientInfo := database.ClientInfo{ Status: database.ClientActivated, } - _, err := clientInfo.IsAttached(dummyDocRefKey) + _, err := clientInfo.IsAttached(dummyDocRefKey.DocID) assert.ErrorIs(t, err, database.ErrDocumentNeverAttached) - err = clientInfo.UpdateCheckpoint(dummyDocRefKey, change.MaxCheckpoint) + err = clientInfo.UpdateCheckpoint(dummyDocRefKey.DocID, change.MaxCheckpoint) assert.ErrorIs(t, err, database.ErrDocumentNeverAttached) }) @@ -143,13 +140,13 @@ func TestClientInfo(t *testing.T) { Status: database.ClientActivated, } - err := clientInfo.AttachDocument(dummyDocRefKey) + err := clientInfo.AttachDocument(dummyDocRefKey.DocID) assert.NoError(t, err) - isAttached, err := clientInfo.IsAttached(dummyDocRefKey) + isAttached, err := clientInfo.IsAttached(dummyDocRefKey.DocID) assert.NoError(t, err) assert.True(t, isAttached) - err = clientInfo.AttachDocument(dummyDocRefKey) + err = clientInfo.AttachDocument(dummyDocRefKey.DocID) assert.ErrorIs(t, err, database.ErrDocumentAlreadyAttached) }) } diff --git a/server/backend/database/database.go b/server/backend/database/database.go index e6e8be5db..11c780aba 100644 --- a/server/backend/database/database.go +++ b/server/backend/database/database.go @@ -178,14 +178,12 @@ type Database interface { // FindDocInfoByRefKey finds the document of the given refKey. FindDocInfoByRefKey( ctx context.Context, - projectID types.ID, refKey types.DocRefKey, ) (*DocInfo, error) // UpdateDocInfoStatusToRemoved updates the document status to removed. UpdateDocInfoStatusToRemoved( ctx context.Context, - projectID types.ID, refKey types.DocRefKey, ) error @@ -270,7 +268,7 @@ type Database interface { FindDocInfosByPaging( ctx context.Context, projectID types.ID, - paging types.Paging[types.DocRefKey], + paging types.Paging[types.ID], ) ([]*DocInfo, error) // FindDocInfosByQuery returns the documentInfos which match the given query. @@ -284,7 +282,6 @@ type Database interface { // IsDocumentAttached returns true if the document is attached to clients. IsDocumentAttached( ctx context.Context, - projectID types.ID, docRefKey types.DocRefKey, excludeClientID types.ID, ) (bool, error) diff --git a/server/backend/database/doc_info.go b/server/backend/database/doc_info.go index ccfc3eee4..088efcaff 100644 --- a/server/backend/database/doc_info.go +++ b/server/backend/database/doc_info.go @@ -86,7 +86,7 @@ func (info *DocInfo) DeepCopy() *DocInfo { // RefKey returns the refKey of the document. func (info *DocInfo) RefKey() types.DocRefKey { return types.DocRefKey{ - Key: info.Key, - ID: info.ID, + ProjectID: info.ProjectID, + DocID: info.ID, } } diff --git a/server/backend/database/memory/database.go b/server/backend/database/memory/database.go index 3a57b3b1d..05ff6d1e5 100644 --- a/server/backend/database/memory/database.go +++ b/server/backend/database/memory/database.go @@ -565,8 +565,8 @@ func (d *DB) UpdateClientInfoAfterPushPull( docInfo *database.DocInfo, ) error { docRefKey := docInfo.RefKey() - clientDocInfo := clientInfo.Documents[docRefKey] - attached, err := clientInfo.IsAttached(docRefKey) + clientDocInfo := clientInfo.Documents[docRefKey.DocID] + attached, err := clientInfo.IsAttached(docRefKey.DocID) if err != nil { return err } @@ -585,16 +585,16 @@ func (d *DB) UpdateClientInfoAfterPushPull( loaded := raw.(*database.ClientInfo).DeepCopy() if !attached { - loaded.Documents[docRefKey] = &database.ClientDocInfo{ + loaded.Documents[docRefKey.DocID] = &database.ClientDocInfo{ Status: clientDocInfo.Status, } loaded.UpdatedAt = gotime.Now() } else { - if _, ok := loaded.Documents[docRefKey]; !ok { - loaded.Documents[docRefKey] = &database.ClientDocInfo{} + if _, ok := loaded.Documents[docRefKey.DocID]; !ok { + loaded.Documents[docRefKey.DocID] = &database.ClientDocInfo{} } - loadedClientDocInfo := loaded.Documents[docRefKey] + loadedClientDocInfo := loaded.Documents[docRefKey.DocID] serverSeq := loadedClientDocInfo.ServerSeq if clientDocInfo.ServerSeq > loadedClientDocInfo.ServerSeq { serverSeq = clientDocInfo.ServerSeq @@ -603,7 +603,7 @@ func (d *DB) UpdateClientInfoAfterPushPull( if clientDocInfo.ClientSeq > loadedClientDocInfo.ClientSeq { clientSeq = clientDocInfo.ClientSeq } - loaded.Documents[docRefKey] = &database.ClientDocInfo{ + loaded.Documents[docRefKey.DocID] = &database.ClientDocInfo{ ServerSeq: serverSeq, ClientSeq: clientSeq, Status: clientDocInfo.Status, @@ -749,24 +749,23 @@ func (d *DB) FindDocInfoByKey( // FindDocInfoByRefKey finds a docInfo of the given refKey. func (d *DB) FindDocInfoByRefKey( _ context.Context, - projectID types.ID, refKey types.DocRefKey, ) (*database.DocInfo, error) { txn := d.db.Txn(true) defer txn.Abort() - raw, err := txn.First(tblDocuments, "id", refKey.ID.String()) + raw, err := txn.First(tblDocuments, "id", refKey.DocID.String()) if err != nil { return nil, fmt.Errorf("find document by id: %w", err) } if raw == nil { - return nil, fmt.Errorf("finding doc info by ID(%s): %w", refKey.ID, database.ErrDocumentNotFound) + return nil, fmt.Errorf("finding doc info by ID(%s): %w", refKey.DocID, database.ErrDocumentNotFound) } docInfo := raw.(*database.DocInfo) - if docInfo.ProjectID != projectID { - return nil, fmt.Errorf("finding doc info by ID(%s): %w", refKey.ID, database.ErrDocumentNotFound) + if docInfo.ProjectID != refKey.ProjectID { + return nil, fmt.Errorf("finding doc info by ID(%s): %w", refKey.DocID, database.ErrDocumentNotFound) } return docInfo.DeepCopy(), nil @@ -775,24 +774,23 @@ func (d *DB) FindDocInfoByRefKey( // UpdateDocInfoStatusToRemoved updates the status of the document to removed. func (d *DB) UpdateDocInfoStatusToRemoved( _ context.Context, - projectID types.ID, refKey types.DocRefKey, ) error { txn := d.db.Txn(true) defer txn.Abort() - raw, err := txn.First(tblDocuments, "id", refKey.ID.String()) + raw, err := txn.First(tblDocuments, "id", refKey.DocID.String()) if err != nil { return fmt.Errorf("find document by id: %w", err) } if raw == nil { - return fmt.Errorf("finding doc info by ID(%s): %w", refKey.ID, database.ErrDocumentNotFound) + return fmt.Errorf("finding doc info by ID(%s): %w", refKey.DocID, database.ErrDocumentNotFound) } docInfo := raw.(*database.DocInfo) - if docInfo.ProjectID != projectID { - return fmt.Errorf("finding doc info by ID(%s): %w", refKey.ID, database.ErrDocumentNotFound) + if docInfo.ProjectID != refKey.ProjectID { + return fmt.Errorf("finding doc info by ID(%s): %w", refKey.DocID, database.ErrDocumentNotFound) } docInfo.RemovedAt = gotime.Now() @@ -834,7 +832,7 @@ func (d *DB) CreateChangeInfos( if err := txn.Insert(tblChanges, &database.ChangeInfo{ ID: newID(), - DocKey: docInfo.Key, + ProjectID: docInfo.ProjectID, DocID: docInfo.ID, ServerSeq: cn.ServerSeq(), ActorID: types.ID(cn.ID().ActorID().String()), @@ -902,7 +900,7 @@ func (d *DB) PurgeStaleChanges( minSyncedServerSeq := change.MaxServerSeq for raw := it.Next(); raw != nil; raw = it.Next() { info := raw.(*database.SyncedSeqInfo) - if info.DocID == docRefKey.ID && info.ServerSeq < minSyncedServerSeq { + if info.DocID == docRefKey.DocID && info.ServerSeq < minSyncedServerSeq { minSyncedServerSeq = info.ServerSeq } } @@ -914,7 +912,7 @@ func (d *DB) PurgeStaleChanges( iterator, err := txn.ReverseLowerBound( tblChanges, "doc_id_server_seq", - docRefKey.ID.String(), + docRefKey.DocID.String(), minSyncedServerSeq, ) if err != nil { @@ -970,7 +968,7 @@ func (d *DB) FindChangeInfosBetweenServerSeqs( iterator, err := txn.LowerBound( tblChanges, "doc_id_server_seq", - docRefKey.ID.String(), + docRefKey.DocID.String(), from, ) if err != nil { @@ -979,7 +977,7 @@ func (d *DB) FindChangeInfosBetweenServerSeqs( for raw := iterator.Next(); raw != nil; raw = iterator.Next() { info := raw.(*database.ChangeInfo) - if info.DocID != docRefKey.ID || info.ServerSeq > to { + if info.DocID != docRefKey.DocID || info.ServerSeq > to { break } infos = append(infos, info.DeepCopy()) @@ -1003,8 +1001,8 @@ func (d *DB) CreateSnapshotInfo( if err := txn.Insert(tblSnapshots, &database.SnapshotInfo{ ID: newID(), - DocKey: docRefKey.Key, - DocID: docRefKey.ID, + ProjectID: docRefKey.ProjectID, + DocID: docRefKey.DocID, ServerSeq: doc.Checkpoint().ServerSeq, Lamport: doc.Lamport(), Snapshot: snapshot, @@ -1023,12 +1021,15 @@ func (d *DB) FindSnapshotInfoByRefKey( ) (*database.SnapshotInfo, error) { txn := d.db.Txn(false) defer txn.Abort() - raw, err := txn.First(tblSnapshots, "id", refKey.ID.String()) + raw, err := txn.First(tblSnapshots, "doc_id_server_seq", + refKey.DocID.String(), + refKey.ServerSeq, + ) if err != nil { return nil, fmt.Errorf("find snapshot by id: %w", err) } if raw == nil { - return nil, fmt.Errorf("%s: %w", refKey.ID, database.ErrSnapshotNotFound) + return nil, fmt.Errorf("%s: %w", refKey, database.ErrSnapshotNotFound) } return raw.(*database.SnapshotInfo).DeepCopy(), nil @@ -1047,7 +1048,7 @@ func (d *DB) FindClosestSnapshotInfo( iterator, err := txn.ReverseLowerBound( tblSnapshots, "doc_id_server_seq", - docRefKey.ID.String(), + docRefKey.DocID.String(), serverSeq, ) if err != nil { @@ -1057,10 +1058,10 @@ func (d *DB) FindClosestSnapshotInfo( var snapshotInfo *database.SnapshotInfo for raw := iterator.Next(); raw != nil; raw = iterator.Next() { info := raw.(*database.SnapshotInfo) - if info.DocID == docRefKey.ID { + if info.DocID == docRefKey.DocID { snapshotInfo = &database.SnapshotInfo{ ID: info.ID, - DocKey: info.DocKey, + ProjectID: info.ProjectID, DocID: info.DocID, ServerSeq: info.ServerSeq, Lamport: info.Lamport, @@ -1097,7 +1098,7 @@ func (d *DB) FindMinSyncedSeqInfo( minSyncedServerSeq := change.MaxServerSeq for raw := it.Next(); raw != nil; raw = it.Next() { info := raw.(*database.SyncedSeqInfo) - if info.DocID == docRefKey.ID && info.ServerSeq < minSyncedServerSeq { + if info.DocID == docRefKey.DocID && info.ServerSeq < minSyncedServerSeq { minSyncedServerSeq = info.ServerSeq syncedSeqInfo = info } @@ -1127,18 +1128,18 @@ func (d *DB) UpdateAndFindMinSyncedTicket( iterator, err := txn.LowerBound( tblSyncedSeqs, "doc_id_lamport_actor_id", - docRefKey.ID.String(), + docRefKey.DocID.String(), int64(0), time.InitialActorID.String(), ) if err != nil { - return nil, fmt.Errorf("fetch smallest syncedseq of %s: %w", docRefKey.ID.String(), err) + return nil, fmt.Errorf("fetch smallest syncedseq of %s: %w", docRefKey.DocID.String(), err) } var syncedSeqInfo *database.SyncedSeqInfo if raw := iterator.Next(); raw != nil { info := raw.(*database.SyncedSeqInfo) - if info.DocID == docRefKey.ID { + if info.DocID == docRefKey.DocID { syncedSeqInfo = info } } @@ -1169,7 +1170,7 @@ func (d *DB) UpdateSyncedSeq( txn := d.db.Txn(true) defer txn.Abort() - isAttached, err := clientInfo.IsAttached(docRefKey) + isAttached, err := clientInfo.IsAttached(docRefKey.DocID) if err != nil { return err } @@ -1178,10 +1179,10 @@ func (d *DB) UpdateSyncedSeq( if _, err = txn.DeleteAll( tblSyncedSeqs, "doc_id_client_id", - docRefKey.ID.String(), + docRefKey.DocID.String(), clientInfo.ID.String(), ); err != nil { - return fmt.Errorf("delete syncedseqs of %s: %w", docRefKey.ID.String(), err) + return fmt.Errorf("delete syncedseqs of %s: %w", docRefKey.DocID.String(), err) } txn.Commit() return nil @@ -1195,16 +1196,16 @@ func (d *DB) UpdateSyncedSeq( raw, err := txn.First( tblSyncedSeqs, "doc_id_client_id", - docRefKey.ID.String(), + docRefKey.DocID.String(), clientInfo.ID.String(), ) if err != nil { - return fmt.Errorf("fetch syncedseqs of %s: %w", docRefKey.ID.String(), err) + return fmt.Errorf("fetch syncedseqs of %s: %w", docRefKey.DocID.String(), err) } syncedSeqInfo := &database.SyncedSeqInfo{ - DocKey: docRefKey.Key, - DocID: docRefKey.ID, + ProjectID: docRefKey.ProjectID, + DocID: docRefKey.DocID, ClientID: clientInfo.ID, Lamport: ticket.Lamport(), ActorID: types.ID(ticket.ActorID().String()), @@ -1217,7 +1218,7 @@ func (d *DB) UpdateSyncedSeq( } if err := txn.Insert(tblSyncedSeqs, syncedSeqInfo); err != nil { - return fmt.Errorf("insert syncedseqs of %s: %w", docRefKey.ID.String(), err) + return fmt.Errorf("insert syncedseqs of %s: %w", docRefKey.DocID.String(), err) } txn.Commit() @@ -1228,7 +1229,7 @@ func (d *DB) UpdateSyncedSeq( func (d *DB) FindDocInfosByPaging( _ context.Context, projectID types.ID, - paging types.Paging[types.DocRefKey], + paging types.Paging[types.ID], ) ([]*database.DocInfo, error) { txn := d.db.Txn(false) defer txn.Abort() @@ -1240,19 +1241,19 @@ func (d *DB) FindDocInfosByPaging( tblDocuments, "project_id_id", projectID.String(), - paging.Offset.ID.String(), + paging.Offset.String(), ) } else { offset := paging.Offset - if paging.Offset.ID == "" { - offset.ID = types.IDFromActorID(time.MaxActorID) + if paging.Offset == "" { + offset = types.IDFromActorID(time.MaxActorID) } iterator, err = txn.ReverseLowerBound( tblDocuments, "project_id_id", projectID.String(), - offset.ID.String(), + offset.String(), ) } if err != nil { @@ -1266,7 +1267,7 @@ func (d *DB) FindDocInfosByPaging( break } - if info.ID != paging.Offset.ID && info.RemovedAt.IsZero() { + if info.ID != paging.Offset && info.RemovedAt.IsZero() { docInfos = append(docInfos, info) } } @@ -1308,14 +1309,13 @@ func (d *DB) FindDocInfosByQuery( // IsDocumentAttached returns whether the document is attached to clients. func (d *DB) IsDocumentAttached( _ context.Context, - projectID types.ID, refKey types.DocRefKey, excludeClientID types.ID, ) (bool, error) { txn := d.db.Txn(false) defer txn.Abort() - it, err := txn.Get(tblClients, "project_id", projectID.String()) + it, err := txn.Get(tblClients, "project_id", refKey.ProjectID.String()) if err != nil { return false, fmt.Errorf("%w", err) } @@ -1328,7 +1328,7 @@ func (d *DB) IsDocumentAttached( if clientInfo.ID == excludeClientID { continue } - clientDocInfo := clientInfo.Documents[refKey] + clientDocInfo := clientInfo.Documents[refKey.DocID] if clientDocInfo == nil { continue } @@ -1352,16 +1352,16 @@ func (d *DB) findTicketByServerSeq( raw, err := txn.First( tblChanges, "doc_id_server_seq", - docRefKey.ID.String(), + docRefKey.DocID.String(), serverSeq, ) if err != nil { - return nil, fmt.Errorf("fetch change of %s: %w", docRefKey.ID.String(), err) + return nil, fmt.Errorf("fetch change of %s: %w", docRefKey.DocID.String(), err) } if raw == nil { return nil, fmt.Errorf( "docID %s, serverSeq %d: %w", - docRefKey.ID.String(), + docRefKey.DocID.String(), serverSeq, database.ErrDocumentNotFound, ) diff --git a/server/backend/database/mongo/client.go b/server/backend/database/mongo/client.go index 702f2f348..e28821268 100644 --- a/server/backend/database/mongo/client.go +++ b/server/backend/database/mongo/client.go @@ -571,7 +571,7 @@ func (c *Client) UpdateClientInfoAfterPushPull( ) error { docRefKey := docInfo.RefKey() clientDocInfoKey := getClientDocInfoKey(docRefKey) - clientDocInfo, ok := clientInfo.Documents[docRefKey] + clientDocInfo, ok := clientInfo.Documents[docRefKey.DocID] if !ok { return fmt.Errorf("client doc info: %w", database.ErrDocumentNeverAttached) } @@ -587,7 +587,7 @@ func (c *Client) UpdateClientInfoAfterPushPull( }, } - attached, err := clientInfo.IsAttached(docRefKey) + attached, err := clientInfo.IsAttached(docRefKey.DocID) if err != nil { return err } @@ -678,8 +678,8 @@ func (c *Client) FindDocInfoByKeyAndOwner( var result *mongo.SingleResult if res.UpsertedCount > 0 { result = c.collection(ColDocuments).FindOneAndUpdate(ctx, bson.M{ - "key": docKey, - "_id": res.UpsertedID, + "project_id": projectID, + "_id": res.UpsertedID, }, bson.M{ "$set": bson.M{ "owner": clientID, @@ -736,13 +736,11 @@ func (c *Client) FindDocInfoByKey( // FindDocInfoByRefKey finds a docInfo of the given refKey. func (c *Client) FindDocInfoByRefKey( ctx context.Context, - projectID types.ID, refKey types.DocRefKey, ) (*database.DocInfo, error) { result := c.collection(ColDocuments).FindOne(ctx, bson.M{ - "key": refKey.Key, - "_id": refKey.ID, - "project_id": projectID, + "project_id": refKey.ProjectID, + "_id": refKey.DocID, }) if result.Err() == mongo.ErrNoDocuments { return nil, fmt.Errorf("%s: %w", refKey, database.ErrDocumentNotFound) @@ -762,13 +760,11 @@ func (c *Client) FindDocInfoByRefKey( // UpdateDocInfoStatusToRemoved updates the document status to removed. func (c *Client) UpdateDocInfoStatusToRemoved( ctx context.Context, - projectID types.ID, refKey types.DocRefKey, ) error { result := c.collection(ColDocuments).FindOneAndUpdate(ctx, bson.M{ - "key": refKey.Key, - "_id": refKey.ID, - "project_id": projectID, + "project_id": refKey.ProjectID, + "_id": refKey.DocID, }, bson.M{ "$set": bson.M{ "removed_at": gotime.Now(), @@ -808,8 +804,8 @@ func (c *Client) CreateChangeInfos( } models = append(models, mongo.NewUpdateOneModel().SetFilter(bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, "server_seq": cn.ServerSeq(), }).SetUpdate(bson.M{"$set": bson.M{ "actor_id": cn.ID().ActorID(), @@ -843,8 +839,8 @@ func (c *Client) CreateChangeInfos( } res, err := c.collection(ColDocuments).UpdateOne(ctx, bson.M{ - "key": docRefKey.Key, - "_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "_id": docRefKey.DocID, "server_seq": initialServerSeq, }, bson.M{ "$set": updateFields, @@ -873,8 +869,8 @@ func (c *Client) PurgeStaleChanges( result := c.collection(ColSyncedSeqs).FindOne( ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, }, options.FindOne().SetSort(bson.M{"server_seq": 1}), ) @@ -893,8 +889,8 @@ func (c *Client) PurgeStaleChanges( if _, err := c.collection(ColChanges).DeleteMany( ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, "server_seq": bson.M{"$lt": minSyncedSeqInfo.ServerSeq}, }, options.Delete(), @@ -937,8 +933,8 @@ func (c *Client) FindChangeInfosBetweenServerSeqs( to int64, ) ([]*database.ChangeInfo, error) { cursor, err := c.collection(ColChanges).Find(ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, "server_seq": bson.M{ "$gte": from, "$lte": to, @@ -968,8 +964,8 @@ func (c *Client) CreateSnapshotInfo( } if _, err := c.collection(ColSnapshots).InsertOne(ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, "server_seq": doc.Checkpoint().ServerSeq, "lamport": doc.Lamport(), "snapshot": snapshot, @@ -987,8 +983,8 @@ func (c *Client) FindSnapshotInfoByRefKey( refKey types.SnapshotRefKey, ) (*database.SnapshotInfo, error) { result := c.collection(ColSnapshots).FindOne(ctx, bson.M{ - "doc_key": refKey.DocRefKey.Key, - "doc_id": refKey.DocRefKey.ID, + "project_id": refKey.ProjectID, + "doc_id": refKey.DocID, "server_seq": refKey.ServerSeq, }) @@ -1023,8 +1019,8 @@ func (c *Client) FindClosestSnapshotInfo( } result := c.collection(ColSnapshots).FindOne(ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, "server_seq": bson.M{ "$lte": serverSeq, }, @@ -1051,8 +1047,8 @@ func (c *Client) FindMinSyncedSeqInfo( docRefKey types.DocRefKey, ) (*database.SyncedSeqInfo, error) { syncedSeqResult := c.collection(ColSyncedSeqs).FindOne(ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, }, options.FindOne().SetSort(bson.D{ {Key: "server_seq", Value: 1}, })) @@ -1086,8 +1082,8 @@ func (c *Client) UpdateAndFindMinSyncedTicket( // 02. find min synced seq of the given document. result := c.collection(ColSyncedSeqs).FindOne(ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, }, options.FindOne().SetSort(bson.D{ {Key: "lamport", Value: 1}, {Key: "actor_id", Value: 1}, @@ -1123,7 +1119,7 @@ func (c *Client) UpdateAndFindMinSyncedTicket( func (c *Client) FindDocInfosByPaging( ctx context.Context, projectID types.ID, - paging types.Paging[types.DocRefKey], + paging types.Paging[types.ID], ) ([]*database.DocInfo, error) { filter := bson.M{ "project_id": bson.M{ @@ -1133,28 +1129,21 @@ func (c *Client) FindDocInfosByPaging( "$exists": false, }, } - if paging.Offset.Key != "" && paging.Offset.ID != "" { + if paging.Offset != "" { k := "$lt" if paging.IsForward { k = "$gt" } - // NOTE(sejongk): this filter handles the case of duplicate IDs in the MongoDB - // sharded cluster. - // For example, when the paging direction is forward and the offset is (2, "b"), - // this filter includes the documents(e.g. (2, "c"), (3, "d")) that comes after - // (2, "b"). - // (_id, key): [(1, "a"), (2, "b"),(2, "c"), (3, "d")] - filter["$or"] = []bson.M{ - {"_id": bson.M{k: paging.Offset.ID}}, - {"_id": paging.Offset.ID, "key": bson.M{k: paging.Offset.Key}}, + filter["_id"] = bson.M{ + k: paging.Offset, } } opts := options.Find().SetLimit(int64(paging.PageSize)) if paging.IsForward { - opts = opts.SetSort(bson.D{{Key: "_id", Value: 1}, {Key: "key", Value: 1}}) + opts = opts.SetSort(map[string]int{"_id": 1}) } else { - opts = opts.SetSort(bson.D{{Key: "_id", Value: -1}, {Key: "key", Value: -1}}) + opts = opts.SetSort(map[string]int{"_id": -1}) } cursor, err := c.collection(ColDocuments).Find(ctx, filter, opts) @@ -1210,16 +1199,16 @@ func (c *Client) UpdateSyncedSeq( serverSeq int64, ) error { // 01. update synced seq of the given client. - isAttached, err := clientInfo.IsAttached(docRefKey) + isAttached, err := clientInfo.IsAttached(docRefKey.DocID) if err != nil { return err } if !isAttached { if _, err = c.collection(ColSyncedSeqs).DeleteOne(ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, - "client_id": clientInfo.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, + "client_id": clientInfo.ID, }, options.Delete()); err != nil { return fmt.Errorf("delete synced seq: %w", err) } @@ -1232,9 +1221,9 @@ func (c *Client) UpdateSyncedSeq( } if _, err = c.collection(ColSyncedSeqs).UpdateOne(ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, - "client_id": clientInfo.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, + "client_id": clientInfo.ID, }, bson.M{ "$set": bson.M{ "lamport": ticket.Lamport(), @@ -1251,13 +1240,12 @@ func (c *Client) UpdateSyncedSeq( // IsDocumentAttached returns whether the given document is attached to clients. func (c *Client) IsDocumentAttached( ctx context.Context, - projectID types.ID, docRefKey types.DocRefKey, excludeClientID types.ID, ) (bool, error) { clientDocInfoKey := getClientDocInfoKey(docRefKey) filter := bson.M{ - "project_id": projectID, + "project_id": docRefKey.ProjectID, clientDocInfoKey + "status": database.DocumentAttached, } @@ -1283,8 +1271,8 @@ func (c *Client) findTicketByServerSeq( } result := c.collection(ColChanges).FindOne(ctx, bson.M{ - "doc_key": docRefKey.Key, - "doc_id": docRefKey.ID, + "project_id": docRefKey.ProjectID, + "doc_id": docRefKey.DocID, "server_seq": serverSeq, }) if result.Err() == mongo.ErrNoDocuments { @@ -1344,5 +1332,5 @@ func escapeRegex(str string) string { } func getClientDocInfoKey(refKey types.DocRefKey) string { - return fmt.Sprintf("documents.%s.%s.", refKey.Key, refKey.ID) + return fmt.Sprintf("documents.%s.", refKey.DocID) } diff --git a/server/backend/database/mongo/indexes.go b/server/backend/database/mongo/indexes.go index 6ef2e92fc..0e1e2a5a5 100644 --- a/server/backend/database/mongo/indexes.go +++ b/server/backend/database/mongo/indexes.go @@ -87,7 +87,7 @@ var collectionInfos = []collectionInfo{ name: ColClients, indexes: []mongo.IndexModel{{ Keys: bsonx.Doc{ - {Key: "project_id", Value: bsonx.Int32(1)}, + {Key: "project_id", Value: bsonx.Int32(1)}, // shard key {Key: "key", Value: bsonx.Int32(1)}, }, Options: options.Index().SetUnique(true), @@ -107,8 +107,8 @@ var collectionInfos = []collectionInfo{ name: ColDocuments, indexes: []mongo.IndexModel{{ Keys: bsonx.Doc{ + {Key: "project_id", Value: bsonx.Int32(1)}, // shard key {Key: "key", Value: bsonx.Int32(1)}, - {Key: "project_id", Value: bsonx.Int32(1)}, }, Options: options.Index().SetPartialFilterExpression( bsonx.Doc{ @@ -120,8 +120,8 @@ var collectionInfos = []collectionInfo{ name: ColChanges, indexes: []mongo.IndexModel{{ Keys: bsonx.Doc{ - {Key: "doc_key", Value: bsonx.Int32(1)}, - {Key: "doc_id", Value: bsonx.Int32(1)}, + {Key: "doc_id", Value: bsonx.Int32(1)}, // shard key + {Key: "project_id", Value: bsonx.Int32(1)}, {Key: "server_seq", Value: bsonx.Int32(1)}, }, Options: options.Index().SetUnique(true), @@ -130,8 +130,8 @@ var collectionInfos = []collectionInfo{ name: ColSnapshots, indexes: []mongo.IndexModel{{ Keys: bsonx.Doc{ - {Key: "doc_key", Value: bsonx.Int32(1)}, - {Key: "doc_id", Value: bsonx.Int32(1)}, + {Key: "doc_id", Value: bsonx.Int32(1)}, // shard key + {Key: "project_id", Value: bsonx.Int32(1)}, {Key: "server_seq", Value: bsonx.Int32(1)}, }, Options: options.Index().SetUnique(true), @@ -140,15 +140,15 @@ var collectionInfos = []collectionInfo{ name: ColSyncedSeqs, indexes: []mongo.IndexModel{{ Keys: bsonx.Doc{ - {Key: "doc_key", Value: bsonx.Int32(1)}, - {Key: "doc_id", Value: bsonx.Int32(1)}, + {Key: "doc_id", Value: bsonx.Int32(1)}, // shard key + {Key: "project_id", Value: bsonx.Int32(1)}, {Key: "client_id", Value: bsonx.Int32(1)}, }, Options: options.Index().SetUnique(true), }, { Keys: bsonx.Doc{ - {Key: "doc_key", Value: bsonx.Int32(1)}, {Key: "doc_id", Value: bsonx.Int32(1)}, + {Key: "project_id", Value: bsonx.Int32(1)}, {Key: "lamport", Value: bsonx.Int32(1)}, {Key: "actor_id", Value: bsonx.Int32(1)}, }, diff --git a/server/backend/database/mongo/registry.go b/server/backend/database/mongo/registry.go index 9eeb4a836..07e960cb9 100644 --- a/server/backend/database/mongo/registry.go +++ b/server/backend/database/mongo/registry.go @@ -26,7 +26,6 @@ import ( "go.mongodb.org/mongo-driver/bson/bsonrw" "github.com/yorkie-team/yorkie/api/types" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/time" "github.com/yorkie-team/yorkie/server/backend/database" ) @@ -54,14 +53,6 @@ func NewRegistryBuilder() *bsoncodec.RegistryBuilder { // Register the encoder for time.ActorID rb.RegisterTypeEncoder(tActorID, bsoncodec.ValueEncoderFunc(actorIDEncoder)) - // Register a decoder that converts the `documents` field in the clients collection - // into `database.ClientDocInfo.Documents`. The `documents` field is a two level map - // containing a number of `doc_key`.`doc_id`.{`client_seq`, `server_seq`, `status`}s. - rb.RegisterTypeDecoder( - tClientDocInfoMap, - bsoncodec.ValueDecoderFunc(clientDocumentsDecoder), - ) - return rb } @@ -89,54 +80,3 @@ func actorIDEncoder(_ bsoncodec.EncodeContext, vw bsonrw.ValueWriter, val reflec } return nil } - -func clientDocumentsDecoder(_ bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { - docs, err := vr.ReadDocument() - if err != nil { - return fmt.Errorf("read documents: %w", err) - } - if val.IsNil() { - val.Set(reflect.MakeMap(val.Type())) - } - - for { - docKey, docInfoByDocIDMapReader, err := docs.ReadElement() - if err != nil { - if err == bsonrw.ErrEOD { - break - } - return fmt.Errorf("read the element in documents: %w", err) - } - docInfoByDocIDMap, err := docInfoByDocIDMapReader.ReadDocument() - if err != nil { - return fmt.Errorf("read docInfoByDocID: %w", err) - } - for { - docID, docInfoReader, err := docInfoByDocIDMap.ReadElement() - if err != nil { - if err == bsonrw.ErrEOD { - break - } - return fmt.Errorf("read the element in docInfoByDocID: %w", err) - } - - docInfo := &database.ClientDocInfo{} - docInfoDecoder, err := bson.NewDecoder(docInfoReader) - if err != nil { - return fmt.Errorf("create docInfoDecoder: %w", err) - } - err = docInfoDecoder.Decode(docInfo) - if err != nil { - return fmt.Errorf("decode docInfo: %w", err) - } - - docRef := reflect.ValueOf(types.DocRefKey{ - Key: key.Key(docKey), - ID: types.ID(docID), - }) - val.SetMapIndex(docRef, reflect.ValueOf(docInfo)) - } - } - - return nil -} diff --git a/server/backend/database/mongo/registry_test.go b/server/backend/database/mongo/registry_test.go index e41e674a1..3b4e00afb 100644 --- a/server/backend/database/mongo/registry_test.go +++ b/server/backend/database/mongo/registry_test.go @@ -28,7 +28,6 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" "github.com/yorkie-team/yorkie/api/types" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/time" "github.com/yorkie-team/yorkie/server/backend/database" ) @@ -88,63 +87,3 @@ func TestEncoder(t *testing.T) { assert.Equal(t, actorID.String(), result[field]) }) } - -func TestDecoder(t *testing.T) { - t.Run("clientDocumentsDecoder test", func(t *testing.T) { - docs := []struct { - docRefKey types.DocRefKey - docInfo database.ClientDocInfo - }{ - { - docRefKey: types.DocRefKey{ - Key: key.Key("test-doc-key1"), - ID: types.ID("test-doc-id1"), - }, - docInfo: database.ClientDocInfo{ - ClientSeq: 0, - ServerSeq: 0, - Status: database.DocumentAttached, - }, - }, - { - docRefKey: types.DocRefKey{ - Key: key.Key("test-doc-key2"), - ID: types.ID("test-doc-id2"), - }, - docInfo: database.ClientDocInfo{ - ClientSeq: 0, - ServerSeq: 0, - Status: database.DocumentDetached, - }, - }, - } - - bsonDocs := make(bson.M) - for _, doc := range docs { - bsonDocs[doc.docRefKey.Key.String()] = bson.M{ - doc.docRefKey.ID.String(): bson.M{ - "client_seq": doc.docInfo.ClientSeq, - "server_seq": doc.docInfo.ServerSeq, - "status": doc.docInfo.Status, - }, - } - } - - marshaledDocs, err := bson.Marshal(bsonDocs) - assert.NoError(t, err) - - clientDocInfoMap := make(database.ClientDocInfoMap) - err = clientDocumentsDecoder( - bsoncodec.DecodeContext{}, - bsonrw.NewBSONDocumentReader(marshaledDocs), - reflect.ValueOf(clientDocInfoMap), - ) - assert.NoError(t, err) - assert.Len(t, clientDocInfoMap, len(docs)) - for _, doc := range docs { - assert.Equal(t, doc.docInfo.ClientSeq, clientDocInfoMap[doc.docRefKey].ClientSeq) - assert.Equal(t, doc.docInfo.ServerSeq, clientDocInfoMap[doc.docRefKey].ServerSeq) - assert.Equal(t, doc.docInfo.Status, clientDocInfoMap[doc.docRefKey].Status) - } - }) -} diff --git a/server/backend/database/snapshot_info.go b/server/backend/database/snapshot_info.go index c398d673b..ca0255f96 100644 --- a/server/backend/database/snapshot_info.go +++ b/server/backend/database/snapshot_info.go @@ -20,7 +20,6 @@ import ( "time" "github.com/yorkie-team/yorkie/api/types" - "github.com/yorkie-team/yorkie/pkg/document/key" ) // SnapshotInfo is a structure representing information of the snapshot. @@ -28,8 +27,8 @@ type SnapshotInfo struct { // ID is the unique ID of the snapshot. ID types.ID `bson:"_id"` - // DocKey is the key of the document which the snapshot belongs to. - DocKey key.Key `bson:"doc_key"` + // ProjectID is the ID of the project which the snapshot belongs to. + ProjectID types.ID `bson:"project_id"` // DocID is the ID of the document which the snapshot belongs to. DocID types.ID `bson:"doc_id"` @@ -55,7 +54,7 @@ func (i *SnapshotInfo) DeepCopy() *SnapshotInfo { return &SnapshotInfo{ ID: i.ID, - DocKey: i.DocKey, + ProjectID: i.ProjectID, DocID: i.DocID, ServerSeq: i.ServerSeq, Lamport: i.Lamport, @@ -68,8 +67,8 @@ func (i *SnapshotInfo) DeepCopy() *SnapshotInfo { func (i *SnapshotInfo) RefKey() types.SnapshotRefKey { return types.SnapshotRefKey{ DocRefKey: types.DocRefKey{ - Key: i.DocKey, - ID: i.DocID, + ProjectID: i.ProjectID, + DocID: i.DocID, }, ServerSeq: i.ServerSeq, } diff --git a/server/backend/database/synced_seq_info.go b/server/backend/database/synced_seq_info.go index 9cfc87822..489275859 100644 --- a/server/backend/database/synced_seq_info.go +++ b/server/backend/database/synced_seq_info.go @@ -18,14 +18,13 @@ package database import ( "github.com/yorkie-team/yorkie/api/types" - "github.com/yorkie-team/yorkie/pkg/document/key" ) // SyncedSeqInfo is a structure representing information about the synchronized // sequence for each client. type SyncedSeqInfo struct { ID types.ID `bson:"_id"` - DocKey key.Key `bson:"doc_key"` + ProjectID types.ID `bson:"project_id"` DocID types.ID `bson:"doc_id"` ClientID types.ID `bson:"client_id"` Lamport int64 `bson:"lamport"` diff --git a/server/backend/database/testcases/testcases.go b/server/backend/database/testcases/testcases.go index 4fdc092b3..1cdddea71 100644 --- a/server/backend/database/testcases/testcases.go +++ b/server/backend/database/testcases/testcases.go @@ -21,7 +21,6 @@ package testcases import ( "context" "fmt" - "sort" "strconv" "testing" gotime "time" @@ -58,9 +57,9 @@ func RunFindDocInfoTest( clientInfo, err := db.ActivateClient(ctx, projectID, t.Name()) assert.NoError(t, err) - _, err = db.FindDocInfoByRefKey(context.Background(), projectID, types.DocRefKey{ - Key: "dummy", - ID: dummyClientID, + _, err = db.FindDocInfoByRefKey(context.Background(), types.DocRefKey{ + ProjectID: projectID, + DocID: dummyClientID, }) assert.ErrorIs(t, err, database.ErrDocumentNotFound) @@ -200,7 +199,7 @@ func RunFindChangesBetweenServerSeqsTest( clientInfo, _ := db.ActivateClient(ctx, projectID, t.Name()) docInfo, _ := db.FindDocInfoByKeyAndOwner(ctx, projectID, clientInfo.ID, docKey, true) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) bytesID, _ := clientInfo.ID.Bytes() @@ -503,8 +502,6 @@ func RunFindDocInfosByPagingTest(t *testing.T, db database.Database, projectID t docInfos = append(docInfos, docInfo) } - // NOTE(sejongk): sorting is required because doc_id may not sequentially increase in a sharded DB cluster. - SortDocInfos(docInfos) docKeys := make([]key.Key, 0, totalSize) docKeysInReverse := make([]key.Key, 0, totalSize) for _, docInfo := range docInfos { @@ -513,29 +510,29 @@ func RunFindDocInfosByPagingTest(t *testing.T, db database.Database, projectID t } // initial page, offset is empty - infos, err := db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.DocRefKey]{PageSize: pageSize}) + infos, err := db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.ID]{PageSize: pageSize}) assert.NoError(t, err) AssertKeys(t, docKeysInReverse[:pageSize], infos) // backward - infos, err = db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.DocRefKey]{ - Offset: infos[len(infos)-1].RefKey(), + infos, err = db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.ID]{ + Offset: infos[len(infos)-1].ID, PageSize: pageSize, }) assert.NoError(t, err) AssertKeys(t, docKeysInReverse[pageSize:], infos) // backward again - emptyInfos, err := db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.DocRefKey]{ - Offset: infos[len(infos)-1].RefKey(), + emptyInfos, err := db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.ID]{ + Offset: infos[len(infos)-1].ID, PageSize: pageSize, }) assert.NoError(t, err) AssertKeys(t, nil, emptyInfos) // forward - infos, err = db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.DocRefKey]{ - Offset: infos[0].RefKey(), + infos, err = db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.ID]{ + Offset: infos[0].ID, PageSize: pageSize, IsForward: true, }) @@ -543,8 +540,8 @@ func RunFindDocInfosByPagingTest(t *testing.T, db database.Database, projectID t AssertKeys(t, docKeys[totalSize-pageSize:], infos) // forward again - emptyInfos, err = db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.DocRefKey]{ - Offset: infos[len(infos)-1].RefKey(), + emptyInfos, err = db.FindDocInfosByPaging(ctx, projectID, types.Paging[types.ID]{ + Offset: infos[len(infos)-1].ID, PageSize: pageSize, IsForward: true, }) @@ -569,68 +566,65 @@ func RunFindDocInfosByPagingTest(t *testing.T, db database.Database, projectID t dummyDocInfos = append(dummyDocInfos, docInfo) } - // NOTE(sejongk): sorting is required because doc_id may not sequentially increase in a sharded DB cluster. - SortDocInfos(dummyDocInfos) - cases := []struct { name string - offset types.DocRefKey + offset types.ID pageSize int isForward bool testResult []int }{ { name: "FindDocInfosByPaging no flag test", - offset: types.EmptyDocRefKey, + offset: "", pageSize: 0, isForward: false, testResult: helper.NewRangeSlice(testDocCnt, 0), }, { name: "FindDocInfosByPaging --forward test", - offset: types.EmptyDocRefKey, + offset: "", pageSize: 0, isForward: true, testResult: helper.NewRangeSlice(0, testDocCnt), }, { name: "FindDocInfosByPaging --size test", - offset: types.EmptyDocRefKey, + offset: "", pageSize: 4, isForward: false, testResult: helper.NewRangeSlice(testDocCnt, testDocCnt-4), }, { name: "FindDocInfosByPaging --size --forward test", - offset: types.EmptyDocRefKey, + offset: "", pageSize: 4, isForward: true, testResult: helper.NewRangeSlice(0, 3), }, { name: "FindDocInfosByPaging --offset test", - offset: dummyDocInfos[13].RefKey(), + offset: dummyDocInfos[13].ID, pageSize: 0, isForward: false, testResult: helper.NewRangeSlice(12, 0), }, { name: "FindDocInfosByPaging --forward --offset test", - offset: dummyDocInfos[13].RefKey(), + offset: dummyDocInfos[13].ID, pageSize: 0, isForward: true, testResult: helper.NewRangeSlice(14, testDocCnt), }, { name: "FindDocInfosByPaging --size --offset test", - offset: dummyDocInfos[13].RefKey(), + offset: dummyDocInfos[13].ID, pageSize: 10, isForward: false, testResult: helper.NewRangeSlice(12, 3), }, { name: "FindDocInfosByPaging --size --forward --offset test", - offset: dummyDocInfos[13].RefKey(), + offset: dummyDocInfos[13].ID, pageSize: 10, isForward: true, testResult: helper.NewRangeSlice(14, 23), @@ -640,7 +634,7 @@ func RunFindDocInfosByPagingTest(t *testing.T, db database.Database, projectID t for _, c := range cases { t.Run(c.name, func(t *testing.T) { ctx := context.Background() - testPaging := types.Paging[types.DocRefKey]{ + testPaging := types.Paging[types.ID]{ Offset: c.offset, PageSize: c.pageSize, IsForward: c.isForward, @@ -675,15 +669,13 @@ func RunFindDocInfosByPagingTest(t *testing.T, db database.Database, projectID t docInfos = append(docInfos, docInfo) } - // NOTE(sejongk): sorting is required because doc_id may not sequentially increase in a sharded DB cluster. - SortDocInfos(docInfos) docKeysInReverse := make([]key.Key, 0, testDocCnt) for _, docInfo := range docInfos { docKeysInReverse = append([]key.Key{docInfo.Key}, docKeysInReverse...) } // 02. List the documents. - result, err := db.FindDocInfosByPaging(ctx, projectInfo.ID, types.Paging[types.DocRefKey]{ + result, err := db.FindDocInfosByPaging(ctx, projectInfo.ID, types.Paging[types.ID]{ PageSize: 10, IsForward: false, }) @@ -698,7 +690,7 @@ func RunFindDocInfosByPagingTest(t *testing.T, db database.Database, projectID t assert.NoError(t, err) // 04. List the documents again and check the filtered result. - result, err = db.FindDocInfosByPaging(ctx, projectInfo.ID, types.Paging[types.DocRefKey]{ + result, err = db.FindDocInfosByPaging(ctx, projectInfo.ID, types.Paging[types.ID]{ PageSize: 10, IsForward: false, }) @@ -718,13 +710,13 @@ func RunCreateChangeInfosTest(t *testing.T, db database.Database, projectID type clientInfo, _ := db.ActivateClient(ctx, projectID, t.Name()) docInfo, _ := db.FindDocInfoByKeyAndOwner(ctx, projectID, clientInfo.ID, docKey, true) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) // 02. Remove the document and check the document is removed. err := db.CreateChangeInfos(ctx, projectID, docInfo, 0, []*change.Change{}, true) assert.NoError(t, err) - docInfo, err = db.FindDocInfoByRefKey(ctx, projectID, docRefKey) + docInfo, err = db.FindDocInfoByRefKey(ctx, docRefKey) assert.NoError(t, err) assert.Equal(t, false, docInfo.RemovedAt.IsZero()) }) @@ -737,18 +729,18 @@ func RunCreateChangeInfosTest(t *testing.T, db database.Database, projectID type clientInfo1, _ := db.ActivateClient(ctx, projectID, t.Name()) docInfo1, _ := db.FindDocInfoByKeyAndOwner(ctx, projectID, clientInfo1.ID, docKey, true) docRefKey1 := docInfo1.RefKey() - assert.NoError(t, clientInfo1.AttachDocument(docRefKey1)) + assert.NoError(t, clientInfo1.AttachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo1, docInfo1)) // 02. Remove the document. - assert.NoError(t, clientInfo1.RemoveDocument(docRefKey1)) + assert.NoError(t, clientInfo1.RemoveDocument(docRefKey1.DocID)) err := db.CreateChangeInfos(ctx, projectID, docInfo1, 0, []*change.Change{}, true) assert.NoError(t, err) // 03. Create a document with same key and check they have same key but different id. docInfo2, _ := db.FindDocInfoByKeyAndOwner(ctx, projectID, clientInfo1.ID, docKey, true) docRefKey2 := docInfo2.RefKey() - assert.NoError(t, clientInfo1.AttachDocument(docRefKey2)) + assert.NoError(t, clientInfo1.AttachDocument(docRefKey2.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo1, docInfo2)) assert.Equal(t, docInfo1.Key, docInfo2.Key) assert.NotEqual(t, docInfo1.ID, docInfo2.ID) @@ -761,26 +753,26 @@ func RunCreateChangeInfosTest(t *testing.T, db database.Database, projectID type clientInfo, _ := db.ActivateClient(ctx, projectID, t.Name()) docInfo, _ := db.FindDocInfoByKeyAndOwner(ctx, projectID, clientInfo.ID, docKey, true) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) doc := document.New(key.Key(t.Name())) pack := doc.CreateChangePack() // Set removed_at in docInfo and store changes - assert.NoError(t, clientInfo.RemoveDocument(docRefKey)) + assert.NoError(t, clientInfo.RemoveDocument(docRefKey.DocID)) err := db.CreateChangeInfos(ctx, projectID, docInfo, 0, pack.Changes, true) assert.NoError(t, err) // Check whether removed_at is set in docInfo - docInfo, err = db.FindDocInfoByRefKey(ctx, projectID, docRefKey) + docInfo, err = db.FindDocInfoByRefKey(ctx, docRefKey) assert.NoError(t, err) assert.NotEqual(t, gotime.Time{}, docInfo.RemovedAt) // Check whether DocumentRemoved status is set in clientInfo clientInfo, err = db.FindClientInfoByID(ctx, projectID, clientInfo.ID) assert.NoError(t, err) - assert.NotEqual(t, database.DocumentRemoved, clientInfo.Documents[docRefKey].Status) + assert.NotEqual(t, database.DocumentRemoved, clientInfo.Documents[docRefKey.DocID].Status) }) } @@ -800,7 +792,7 @@ func RunUpdateClientInfoAfterPushPullTest(t *testing.T, db database.Database, pr err = db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo) assert.ErrorIs(t, err, database.ErrDocumentNeverAttached) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) }) @@ -813,13 +805,13 @@ func RunUpdateClientInfoAfterPushPullTest(t *testing.T, db database.Database, pr assert.NoError(t, err) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) result, err := db.FindClientInfoByID(ctx, projectID, clientInfo.ID) - assert.Equal(t, result.Documents[docRefKey].Status, database.DocumentAttached) - assert.Equal(t, result.Documents[docRefKey].ServerSeq, int64(0)) - assert.Equal(t, result.Documents[docRefKey].ClientSeq, uint32(0)) + assert.Equal(t, result.Documents[docRefKey.DocID].Status, database.DocumentAttached) + assert.Equal(t, result.Documents[docRefKey.DocID].ServerSeq, int64(0)) + assert.Equal(t, result.Documents[docRefKey.DocID].ClientSeq, uint32(0)) assert.NoError(t, err) }) @@ -832,37 +824,37 @@ func RunUpdateClientInfoAfterPushPullTest(t *testing.T, db database.Database, pr assert.NoError(t, err) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) - clientInfo.Documents[docRefKey].ServerSeq = 1 - clientInfo.Documents[docRefKey].ClientSeq = 1 + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) + clientInfo.Documents[docRefKey.DocID].ServerSeq = 1 + clientInfo.Documents[docRefKey.DocID].ClientSeq = 1 assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) result, err := db.FindClientInfoByID(ctx, projectID, clientInfo.ID) - assert.Equal(t, result.Documents[docRefKey].Status, database.DocumentAttached) - assert.Equal(t, result.Documents[docRefKey].ServerSeq, int64(1)) - assert.Equal(t, result.Documents[docRefKey].ClientSeq, uint32(1)) + assert.Equal(t, result.Documents[docRefKey.DocID].Status, database.DocumentAttached) + assert.Equal(t, result.Documents[docRefKey.DocID].ServerSeq, int64(1)) + assert.Equal(t, result.Documents[docRefKey.DocID].ClientSeq, uint32(1)) assert.NoError(t, err) // update with larger seq - clientInfo.Documents[docRefKey].ServerSeq = 3 - clientInfo.Documents[docRefKey].ClientSeq = 5 + clientInfo.Documents[docRefKey.DocID].ServerSeq = 3 + clientInfo.Documents[docRefKey.DocID].ClientSeq = 5 assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) result, err = db.FindClientInfoByID(ctx, projectID, clientInfo.ID) - assert.Equal(t, result.Documents[docRefKey].Status, database.DocumentAttached) - assert.Equal(t, result.Documents[docRefKey].ServerSeq, int64(3)) - assert.Equal(t, result.Documents[docRefKey].ClientSeq, uint32(5)) + assert.Equal(t, result.Documents[docRefKey.DocID].Status, database.DocumentAttached) + assert.Equal(t, result.Documents[docRefKey.DocID].ServerSeq, int64(3)) + assert.Equal(t, result.Documents[docRefKey.DocID].ClientSeq, uint32(5)) assert.NoError(t, err) // update with smaller seq(should be ignored) - clientInfo.Documents[docRefKey].ServerSeq = 2 - clientInfo.Documents[docRefKey].ClientSeq = 3 + clientInfo.Documents[docRefKey.DocID].ServerSeq = 2 + clientInfo.Documents[docRefKey.DocID].ClientSeq = 3 assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) result, err = db.FindClientInfoByID(ctx, projectID, clientInfo.ID) - assert.Equal(t, result.Documents[docRefKey].Status, database.DocumentAttached) - assert.Equal(t, result.Documents[docRefKey].ServerSeq, int64(3)) - assert.Equal(t, result.Documents[docRefKey].ClientSeq, uint32(5)) + assert.Equal(t, result.Documents[docRefKey.DocID].Status, database.DocumentAttached) + assert.Equal(t, result.Documents[docRefKey.DocID].ServerSeq, int64(3)) + assert.Equal(t, result.Documents[docRefKey.DocID].ClientSeq, uint32(5)) assert.NoError(t, err) }) @@ -875,24 +867,24 @@ func RunUpdateClientInfoAfterPushPullTest(t *testing.T, db database.Database, pr assert.NoError(t, err) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) - clientInfo.Documents[docRefKey].ServerSeq = 1 - clientInfo.Documents[docRefKey].ClientSeq = 1 + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) + clientInfo.Documents[docRefKey.DocID].ServerSeq = 1 + clientInfo.Documents[docRefKey.DocID].ClientSeq = 1 assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) result, err := db.FindClientInfoByID(ctx, projectID, clientInfo.ID) - assert.Equal(t, result.Documents[docRefKey].Status, database.DocumentAttached) - assert.Equal(t, result.Documents[docRefKey].ServerSeq, int64(1)) - assert.Equal(t, result.Documents[docRefKey].ClientSeq, uint32(1)) + assert.Equal(t, result.Documents[docRefKey.DocID].Status, database.DocumentAttached) + assert.Equal(t, result.Documents[docRefKey.DocID].ServerSeq, int64(1)) + assert.Equal(t, result.Documents[docRefKey.DocID].ClientSeq, uint32(1)) assert.NoError(t, err) - assert.NoError(t, clientInfo.DetachDocument(docRefKey)) + assert.NoError(t, clientInfo.DetachDocument(docRefKey.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) result, err = db.FindClientInfoByID(ctx, projectID, clientInfo.ID) - assert.Equal(t, result.Documents[docRefKey].Status, database.DocumentDetached) - assert.Equal(t, result.Documents[docRefKey].ServerSeq, int64(0)) - assert.Equal(t, result.Documents[docRefKey].ClientSeq, uint32(0)) + assert.Equal(t, result.Documents[docRefKey.DocID].Status, database.DocumentDetached) + assert.Equal(t, result.Documents[docRefKey.DocID].ServerSeq, int64(0)) + assert.Equal(t, result.Documents[docRefKey.DocID].ClientSeq, uint32(0)) assert.NoError(t, err) }) @@ -905,24 +897,24 @@ func RunUpdateClientInfoAfterPushPullTest(t *testing.T, db database.Database, pr assert.NoError(t, err) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) - clientInfo.Documents[docRefKey].ServerSeq = 1 - clientInfo.Documents[docRefKey].ClientSeq = 1 + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) + clientInfo.Documents[docRefKey.DocID].ServerSeq = 1 + clientInfo.Documents[docRefKey.DocID].ClientSeq = 1 assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) result, err := db.FindClientInfoByID(ctx, projectID, clientInfo.ID) - assert.Equal(t, result.Documents[docRefKey].Status, database.DocumentAttached) - assert.Equal(t, result.Documents[docRefKey].ServerSeq, int64(1)) - assert.Equal(t, result.Documents[docRefKey].ClientSeq, uint32(1)) + assert.Equal(t, result.Documents[docRefKey.DocID].Status, database.DocumentAttached) + assert.Equal(t, result.Documents[docRefKey.DocID].ServerSeq, int64(1)) + assert.Equal(t, result.Documents[docRefKey.DocID].ClientSeq, uint32(1)) assert.NoError(t, err) - assert.NoError(t, clientInfo.RemoveDocument(docRefKey)) + assert.NoError(t, clientInfo.RemoveDocument(docRefKey.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) result, err = db.FindClientInfoByID(ctx, projectID, clientInfo.ID) - assert.Equal(t, result.Documents[docRefKey].Status, database.DocumentRemoved) - assert.Equal(t, result.Documents[docRefKey].ServerSeq, int64(0)) - assert.Equal(t, result.Documents[docRefKey].ClientSeq, uint32(0)) + assert.Equal(t, result.Documents[docRefKey.DocID].Status, database.DocumentRemoved) + assert.Equal(t, result.Documents[docRefKey.DocID].ServerSeq, int64(0)) + assert.Equal(t, result.Documents[docRefKey.DocID].ClientSeq, uint32(0)) assert.NoError(t, err) }) @@ -935,7 +927,7 @@ func RunUpdateClientInfoAfterPushPullTest(t *testing.T, db database.Database, pr assert.NoError(t, err) docRefKey := docInfo.RefKey() - assert.NoError(t, clientInfo.AttachDocument(docRefKey)) + assert.NoError(t, clientInfo.AttachDocument(docRefKey.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) clientInfo.ID = "invalid clientInfo id" @@ -961,44 +953,44 @@ func RunIsDocumentAttachedTest(t *testing.T, db database.Database, projectID typ // 01. Check if document is attached without attaching docRefKey1 := d1.RefKey() - attached, err := db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err := db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.False(t, attached) // 02. Check if document is attached after attaching - assert.NoError(t, c1.AttachDocument(docRefKey1)) + assert.NoError(t, c1.AttachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.True(t, attached) // 03. Check if document is attached after detaching - assert.NoError(t, c1.DetachDocument(docRefKey1)) + assert.NoError(t, c1.DetachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.False(t, attached) // 04. Check if document is attached after two clients attaching - assert.NoError(t, c1.AttachDocument(docRefKey1)) + assert.NoError(t, c1.AttachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - assert.NoError(t, c2.AttachDocument(docRefKey1)) + assert.NoError(t, c2.AttachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c2, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.True(t, attached) // 05. Check if document is attached after a client detaching - assert.NoError(t, c1.DetachDocument(docRefKey1)) + assert.NoError(t, c1.DetachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.True(t, attached) // 06. Check if document is attached after another client detaching - assert.NoError(t, c2.DetachDocument(docRefKey1)) + assert.NoError(t, c2.DetachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c2, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.False(t, attached) }) @@ -1016,33 +1008,33 @@ func RunIsDocumentAttachedTest(t *testing.T, db database.Database, projectID typ // 01. Check if documents are attached after attaching docRefKey1 := d1.RefKey() - assert.NoError(t, c1.AttachDocument(docRefKey1)) + assert.NoError(t, c1.AttachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - attached, err := db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err := db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.True(t, attached) docRefKey2 := d2.RefKey() - assert.NoError(t, c1.AttachDocument(docRefKey2)) + assert.NoError(t, c1.AttachDocument(docRefKey2.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d2)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey2, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey2, "") assert.NoError(t, err) assert.True(t, attached) // 02. Check if a document is attached after detaching another document - assert.NoError(t, c1.DetachDocument(docRefKey2)) + assert.NoError(t, c1.DetachDocument(docRefKey2.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d2)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey2, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey2, "") assert.NoError(t, err) assert.False(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.True(t, attached) // 03. Check if a document is attached after detaching remaining document - assert.NoError(t, c1.DetachDocument(docRefKey1)) + assert.NoError(t, c1.DetachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.False(t, attached) }) @@ -1060,68 +1052,68 @@ func RunIsDocumentAttachedTest(t *testing.T, db database.Database, projectID typ // 01. Check if document is attached without attaching docRefKey1 := d1.RefKey() - attached, err := db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err := db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.False(t, attached) // 02. Check if document is attached after attaching - assert.NoError(t, c1.AttachDocument(docRefKey1)) + assert.NoError(t, c1.AttachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.True(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, c1.ID) + attached, err = db.IsDocumentAttached(ctx, docRefKey1, c1.ID) assert.NoError(t, err) assert.False(t, attached) // 03. Check if document is attached after detaching - assert.NoError(t, c1.DetachDocument(docRefKey1)) + assert.NoError(t, c1.DetachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.False(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, c1.ID) + attached, err = db.IsDocumentAttached(ctx, docRefKey1, c1.ID) assert.NoError(t, err) assert.False(t, attached) // 04. Check if document is attached after two clients attaching - assert.NoError(t, c1.AttachDocument(docRefKey1)) + assert.NoError(t, c1.AttachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - assert.NoError(t, c2.AttachDocument(docRefKey1)) + assert.NoError(t, c2.AttachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c2, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.True(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, c1.ID) + attached, err = db.IsDocumentAttached(ctx, docRefKey1, c1.ID) assert.NoError(t, err) assert.True(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, c2.ID) + attached, err = db.IsDocumentAttached(ctx, docRefKey1, c2.ID) assert.NoError(t, err) assert.True(t, attached) // 05. Check if document is attached after a client detaching - assert.NoError(t, c1.DetachDocument(docRefKey1)) + assert.NoError(t, c1.DetachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c1, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.True(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, c1.ID) + attached, err = db.IsDocumentAttached(ctx, docRefKey1, c1.ID) assert.NoError(t, err) assert.True(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, c2.ID) + attached, err = db.IsDocumentAttached(ctx, docRefKey1, c2.ID) assert.NoError(t, err) assert.False(t, attached) // 06. Check if document is attached after another client detaching - assert.NoError(t, c2.DetachDocument(docRefKey1)) + assert.NoError(t, c2.DetachDocument(docRefKey1.DocID)) assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, c2, d1)) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, "") + attached, err = db.IsDocumentAttached(ctx, docRefKey1, "") assert.NoError(t, err) assert.False(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, c1.ID) + attached, err = db.IsDocumentAttached(ctx, docRefKey1, c1.ID) assert.NoError(t, err) assert.False(t, attached) - attached, err = db.IsDocumentAttached(ctx, projectID, docRefKey1, c2.ID) + attached, err = db.IsDocumentAttached(ctx, docRefKey1, c2.ID) assert.NoError(t, err) assert.False(t, attached) }) @@ -1210,16 +1202,6 @@ func RunFindDeactivateCandidatesPerProjectTest(t *testing.T, db database.Databas }) } -// SortDocInfos sorts the given docInfo slice using the (doc_id, doc_key) ascending order. -func SortDocInfos(docInfos []*database.DocInfo) { - sort.Slice(docInfos, func(i, j int) bool { - if docInfos[i].ID != docInfos[j].ID { - return docInfos[i].ID < docInfos[j].ID - } - return docInfos[i].Key < docInfos[j].Key - }) -} - // AssertKeys checks the equivalence between the provided expectedKeys and the keys in the given infos. func AssertKeys(t *testing.T, expectedKeys []key.Key, infos []*database.DocInfo) { var keys []key.Key diff --git a/server/backend/sync/memory/coordinator_test.go b/server/backend/sync/memory/coordinator_test.go index e4d8e7b72..9f0dcc7db 100644 --- a/server/backend/sync/memory/coordinator_test.go +++ b/server/backend/sync/memory/coordinator_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/yorkie-team/yorkie/api/types" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/time" "github.com/yorkie-team/yorkie/server/backend/sync/memory" ) @@ -31,11 +30,9 @@ import ( func TestCoordinator(t *testing.T) { t.Run("subscriptions map test", func(t *testing.T) { coordinator := memory.NewCoordinator(nil) - docKey := key.Key(t.Name() + "key") - docID := types.ID(t.Name() + "id") docRefKey := types.DocRefKey{ - Key: docKey, - ID: docID, + ProjectID: types.ID("000000000000000000000000"), + DocID: types.ID("000000000000000000000000"), } ctx := context.Background() diff --git a/server/backend/sync/memory/pubsub_test.go b/server/backend/sync/memory/pubsub_test.go index a45652609..ea375f854 100644 --- a/server/backend/sync/memory/pubsub_test.go +++ b/server/backend/sync/memory/pubsub_test.go @@ -24,7 +24,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/yorkie-team/yorkie/api/types" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/time" "github.com/yorkie-team/yorkie/server/backend/sync" "github.com/yorkie-team/yorkie/server/backend/sync/memory" @@ -38,11 +37,9 @@ func TestPubSub(t *testing.T) { t.Run("publish subscribe test", func(t *testing.T) { pubSub := memory.NewPubSub() - key := key.Key(t.Name() + "key") - id := types.ID(t.Name() + "id") refKey := types.DocRefKey{ - Key: key, - ID: id, + ProjectID: types.ID("000000000000000000000000"), + DocID: types.ID("000000000000000000000000"), } docEvent := sync.DocEvent{ Type: types.DocumentWatchedEvent, diff --git a/server/clients/clients.go b/server/clients/clients.go index 325175992..ad6e6633e 100644 --- a/server/clients/clients.go +++ b/server/clients/clients.go @@ -60,8 +60,8 @@ func Deactivate( return nil, err } - for docRefKey, clientDocInfo := range clientInfo.Documents { - isAttached, err := clientInfo.IsAttached(docRefKey) + for docID, clientDocInfo := range clientInfo.Documents { + isAttached, err := clientInfo.IsAttached(docID) if err != nil { return nil, err } @@ -69,7 +69,7 @@ func Deactivate( continue } - if err := clientInfo.DetachDocument(docRefKey); err != nil { + if err := clientInfo.DetachDocument(docID); err != nil { return nil, err } @@ -81,7 +81,10 @@ func Deactivate( if err := db.UpdateSyncedSeq( ctx, clientInfo, - docRefKey, + types.DocRefKey{ + ProjectID: projectID, + DocID: docID, + }, clientDocInfo.ServerSeq, ); err != nil { return nil, err diff --git a/server/documents/documents.go b/server/documents/documents.go index 846362bf1..57d1b4081 100644 --- a/server/documents/documents.go +++ b/server/documents/documents.go @@ -48,7 +48,7 @@ func ListDocumentSummaries( ctx context.Context, be *backend.Backend, project *types.Project, - paging types.Paging[types.DocRefKey], + paging types.Paging[types.ID], includeSnapshot bool, ) ([]*types.DocumentSummary, error) { if paging.PageSize > pageSizeLimit { @@ -199,10 +199,9 @@ func FindDocInfoByKey( func FindDocInfoByRefKey( ctx context.Context, be *backend.Backend, - project *types.Project, refkey types.DocRefKey, ) (*database.DocInfo, error) { - return be.DB.FindDocInfoByRefKey(ctx, project.ID, refkey) + return be.DB.FindDocInfoByRefKey(ctx, refkey) } // FindDocInfoByKeyAndOwner returns a document for the given document key. If @@ -229,15 +228,14 @@ func FindDocInfoByKeyAndOwner( func RemoveDocument( ctx context.Context, be *backend.Backend, - project *types.Project, refKey types.DocRefKey, force bool, ) error { if force { - return be.DB.UpdateDocInfoStatusToRemoved(ctx, project.ID, refKey) + return be.DB.UpdateDocInfoStatusToRemoved(ctx, refKey) } - isAttached, err := be.DB.IsDocumentAttached(ctx, project.ID, refKey, "") + isAttached, err := be.DB.IsDocumentAttached(ctx, refKey, "") if err != nil { return err } @@ -245,16 +243,15 @@ func RemoveDocument( return ErrDocumentAttached } - return be.DB.UpdateDocInfoStatusToRemoved(ctx, project.ID, refKey) + return be.DB.UpdateDocInfoStatusToRemoved(ctx, refKey) } // IsDocumentAttached returns true if the given document is attached to any client. func IsDocumentAttached( ctx context.Context, be *backend.Backend, - project *types.Project, docRefKey types.DocRefKey, excludeClientID types.ID, ) (bool, error) { - return be.DB.IsDocumentAttached(ctx, project.ID, docRefKey, excludeClientID) + return be.DB.IsDocumentAttached(ctx, docRefKey, excludeClientID) } diff --git a/server/packs/packs.go b/server/packs/packs.go index c436c68c2..6015dbf68 100644 --- a/server/packs/packs.go +++ b/server/packs/packs.go @@ -85,7 +85,7 @@ func PushPull( be.Metrics.AddPushPullSnapshotBytes(respPack.SnapshotLen()) docRefKey := docInfo.RefKey() - if err := clientInfo.UpdateCheckpoint(docRefKey, respPack.Checkpoint); err != nil { + if err := clientInfo.UpdateCheckpoint(docRefKey.DocID, respPack.Checkpoint); err != nil { return nil, err } diff --git a/server/packs/pushpull.go b/server/packs/pushpull.go index c4db2b427..addea98a5 100644 --- a/server/packs/pushpull.go +++ b/server/packs/pushpull.go @@ -43,7 +43,7 @@ func pushChanges( reqPack *change.Pack, initialServerSeq int64, ) (change.Checkpoint, []*change.Change) { - cp := clientInfo.Checkpoint(docInfo.RefKey()) + cp := clientInfo.Checkpoint(docInfo.ID) var pushedChanges []*change.Change for _, cn := range reqPack.Changes { diff --git a/server/rpc/admin_server.go b/server/rpc/admin_server.go index 3a398c051..dc57c66c9 100644 --- a/server/rpc/admin_server.go +++ b/server/rpc/admin_server.go @@ -252,11 +252,8 @@ func (s *adminServer) ListDocuments( ctx, s.backend, project, - types.Paging[types.DocRefKey]{ - Offset: types.DocRefKey{ - Key: key.Key(req.Msg.PreviousKey), - ID: types.ID(req.Msg.PreviousId), - }, + types.Paging[types.ID]{ + Offset: types.ID(req.Msg.PreviousId), PageSize: int(req.Msg.PageSize), IsForward: req.Msg.IsForward, }, @@ -331,7 +328,7 @@ func (s *adminServer) RemoveDocumentByAdmin( }() if err := documents.RemoveDocument( - ctx, s.backend, project, + ctx, s.backend, docInfo.RefKey(), req.Msg.Force, ); err != nil { diff --git a/server/rpc/testcases/testcases.go b/server/rpc/testcases/testcases.go index f4512646c..c3712784b 100644 --- a/server/rpc/testcases/testcases.go +++ b/server/rpc/testcases/testcases.go @@ -591,9 +591,8 @@ func RunWatchDocumentTest( watchResp, err := testClient.WatchDocument( context.Background(), connect.NewRequest(&api.WatchDocumentRequest{ - ClientId: activateResp.Msg.ClientId, - DocumentKey: docKey, - DocumentId: resPack.Msg.DocumentId, + ClientId: activateResp.Msg.ClientId, + DocumentId: resPack.Msg.DocumentId, }, )) assert.NoError(t, err) diff --git a/server/rpc/yorkie_server.go b/server/rpc/yorkie_server.go index 19e87ee3a..a940ae9fe 100644 --- a/server/rpc/yorkie_server.go +++ b/server/rpc/yorkie_server.go @@ -150,7 +150,7 @@ func (s *yorkieServer) AttachDocument( return nil, err } - if err := clientInfo.AttachDocument(docInfo.RefKey()); err != nil { + if err := clientInfo.AttachDocument(docInfo.ID); err != nil { return nil, err } @@ -184,8 +184,8 @@ func (s *yorkieServer) DetachDocument( if err != nil { return nil, err } - docID := types.ID(req.Msg.DocumentId) - if err := docID.Validate(); err != nil { + docID, err := converter.FromDocumentID(req.Msg.DocumentId) + if err != nil { return nil, err } @@ -217,16 +217,16 @@ func (s *yorkieServer) DetachDocument( } docRefKey := types.DocRefKey{ - Key: pack.DocumentKey, - ID: docID, + ProjectID: project.ID, + DocID: docID, } - docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, project, docRefKey) + docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, docRefKey) if err != nil { return nil, err } isAttached, err := documents.IsDocumentAttached( - ctx, s.backend, project, + ctx, s.backend, docRefKey, clientInfo.ID, ) @@ -236,11 +236,11 @@ func (s *yorkieServer) DetachDocument( if req.Msg.RemoveIfNotAttached && !isAttached { pack.IsRemoved = true - if err := clientInfo.RemoveDocument(docRefKey); err != nil { + if err := clientInfo.RemoveDocument(docInfo.ID); err != nil { return nil, err } } else { - if err := clientInfo.DetachDocument(docRefKey); err != nil { + if err := clientInfo.DetachDocument(docInfo.ID); err != nil { return nil, err } } @@ -275,8 +275,8 @@ func (s *yorkieServer) PushPullChanges( if err != nil { return nil, err } - docID := types.ID(req.Msg.DocumentId) - if err := docID.Validate(); err != nil { + docID, err := converter.FromDocumentID(req.Msg.DocumentId) + if err != nil { return nil, err } @@ -318,15 +318,15 @@ func (s *yorkieServer) PushPullChanges( } docRefKey := types.DocRefKey{ - Key: pack.DocumentKey, - ID: docID, + ProjectID: project.ID, + DocID: docID, } - docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, project, docRefKey) + docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, docRefKey) if err != nil { return nil, err } - if err := clientInfo.EnsureDocumentAttached(docRefKey); err != nil { + if err := clientInfo.EnsureDocumentAttached(docInfo.ID); err != nil { return nil, err } @@ -357,20 +357,19 @@ func (s *yorkieServer) WatchDocument( return err } - docKey := key.Key(req.Msg.DocumentKey) + project := projects.From(ctx) docID, err := converter.FromDocumentID(req.Msg.DocumentId) if err != nil { return err } docRefKey := types.DocRefKey{ - Key: docKey, - ID: docID, + ProjectID: project.ID, + DocID: docID, } docInfo, err := documents.FindDocInfoByRefKey( ctx, s.backend, - projects.From(ctx), docRefKey, ) if err != nil { @@ -384,7 +383,6 @@ func (s *yorkieServer) WatchDocument( return err } - project := projects.From(ctx) if _, err = clients.FindClientInfo(ctx, s.backend.DB, project, clientID); err != nil { return err } @@ -472,8 +470,8 @@ func (s *yorkieServer) RemoveDocument( if err != nil { return nil, err } - docID := types.ID(req.Msg.DocumentId) - if err := docID.Validate(); err != nil { + docID, err := converter.FromDocumentID(req.Msg.DocumentId) + if err != nil { return nil, err } @@ -507,15 +505,15 @@ func (s *yorkieServer) RemoveDocument( } docRefKey := types.DocRefKey{ - Key: pack.DocumentKey, - ID: docID, + ProjectID: project.ID, + DocID: docID, } - docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, project, docRefKey) + docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, docRefKey) if err != nil { return nil, err } - if err := clientInfo.RemoveDocument(docRefKey); err != nil { + if err := clientInfo.RemoveDocument(docInfo.ID); err != nil { return nil, err } @@ -584,20 +582,19 @@ func (s *yorkieServer) Broadcast( return nil, err } - docKey := key.Key(req.Msg.DocumentKey) + project := projects.From(ctx) docID, err := converter.FromDocumentID(req.Msg.DocumentId) if err != nil { return nil, err } docRefKey := types.DocRefKey{ - Key: docKey, - ID: docID, + ProjectID: project.ID, + DocID: docID, } docInfo, err := documents.FindDocInfoByRefKey( ctx, s.backend, - projects.From(ctx), docRefKey, ) if err != nil { @@ -612,7 +609,6 @@ func (s *yorkieServer) Broadcast( return nil, err } - project := projects.From(ctx) if _, err = clients.FindClientInfo(ctx, s.backend.DB, project, clientID); err != nil { return nil, err } diff --git a/test/bench/push_pull_bench_test.go b/test/bench/push_pull_bench_test.go index 22a900494..48cf55a51 100644 --- a/test/bench/push_pull_bench_test.go +++ b/test/bench/push_pull_bench_test.go @@ -90,7 +90,7 @@ func setUpClientsAndDocs( assert.NoError(b, err) docInfo, err := be.DB.FindDocInfoByKeyAndOwner(ctx, database.DefaultProjectID, clientInfo.ID, docKey, true) assert.NoError(b, err) - assert.NoError(b, clientInfo.AttachDocument(docInfo.RefKey())) + assert.NoError(b, clientInfo.AttachDocument(docInfo.ID)) assert.NoError(b, be.DB.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) bytesID, _ := clientInfo.ID.Bytes() @@ -137,9 +137,9 @@ func benchmarkPushChanges( docKey := getDocKey(b, i) clientInfos, docID, docs := setUpClientsAndDocs(ctx, 1, docKey, b, be) pack := createChangePack(changeCnt, docs[0], b) - docInfo, err := documents.FindDocInfoByRefKey(ctx, be, project, types.DocRefKey{ - Key: docKey, - ID: docID, + docInfo, err := documents.FindDocInfoByRefKey(ctx, be, types.DocRefKey{ + ProjectID: project.ID, + DocID: docID, }) assert.NoError(b, err) b.StartTimer() @@ -166,15 +166,15 @@ func benchmarkPullChanges( pullPack := createChangePack(0, pullerDoc, b) docRefKey := types.DocRefKey{ - Key: docKey, - ID: docID, + ProjectID: project.ID, + DocID: docID, } - docInfo, err := documents.FindDocInfoByRefKey(ctx, be, project, docRefKey) + docInfo, err := documents.FindDocInfoByRefKey(ctx, be, docRefKey) assert.NoError(b, err) _, err = packs.PushPull(ctx, be, project, pusherClientInfo, docInfo, pushPack, types.SyncModePushPull) assert.NoError(b, err) - docInfo, err = documents.FindDocInfoByRefKey(ctx, be, project, docRefKey) + docInfo, err = documents.FindDocInfoByRefKey(ctx, be, docRefKey) assert.NoError(b, err) b.StartTimer() @@ -196,15 +196,15 @@ func benchmarkPushSnapshots( docKey := getDocKey(b, i) clientInfos, docID, docs := setUpClientsAndDocs(ctx, 1, docKey, b, be) docRefKey := types.DocRefKey{ - Key: docKey, - ID: docID, + ProjectID: project.ID, + DocID: docID, } b.StartTimer() for j := 0; j < snapshotCnt; j++ { b.StopTimer() pushPack := createChangePack(changeCnt, docs[0], b) - docInfo, err := documents.FindDocInfoByRefKey(ctx, be, project, docRefKey) + docInfo, err := documents.FindDocInfoByRefKey(ctx, be, docRefKey) assert.NoError(b, err) b.StartTimer() @@ -239,15 +239,15 @@ func benchmarkPullSnapshot( pullPack := createChangePack(0, pullerDoc, b) docRefKey := types.DocRefKey{ - Key: docKey, - ID: docID, + ProjectID: project.ID, + DocID: docID, } - docInfo, err := documents.FindDocInfoByRefKey(ctx, be, project, docRefKey) + docInfo, err := documents.FindDocInfoByRefKey(ctx, be, docRefKey) assert.NoError(b, err) _, err = packs.PushPull(ctx, be, project, pusherClientInfo, docInfo, pushPack, types.SyncModePushPull) assert.NoError(b, err) - docInfo, err = documents.FindDocInfoByRefKey(ctx, be, project, docRefKey) + docInfo, err = documents.FindDocInfoByRefKey(ctx, be, docRefKey) assert.NoError(b, err) b.StartTimer() diff --git a/test/helper/helper.go b/test/helper/helper.go index cc463784c..362270f06 100644 --- a/test/helper/helper.go +++ b/test/helper/helper.go @@ -404,7 +404,6 @@ func CreateDummyDocumentWithID( // FindDocInfosWithID finds the docInfos of the given projectID and docID. func FindDocInfosWithID( databaseName string, - projectID types.ID, docID types.ID, ) ([]*database.DocInfo, error) { ctx := context.Background() @@ -416,8 +415,7 @@ func FindDocInfosWithID( cursor, err := cli.Database(databaseName).Collection(mongo.ColDocuments).Find( ctx, bson.M{ - "_id": docID, - "project_id": projectID, + "_id": docID, }, options.Find()) if err != nil { return nil, err diff --git a/test/integration/document_test.go b/test/integration/document_test.go index 3c20b8c66..a163ab758 100644 --- a/test/integration/document_test.go +++ b/test/integration/document_test.go @@ -29,7 +29,6 @@ import ( "github.com/stretchr/testify/assert" - "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/client" "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/innerpresence" @@ -807,12 +806,11 @@ func TestDocumentWithProjects(t *testing.T) { assert.NoError(t, cli.Sync(ctx)) - previousRefKey := types.DocRefKey{Key: "", ID: ""} - docs, err := adminCli.ListDocuments(ctx, "default", previousRefKey, 0, true, false) + docs, err := adminCli.ListDocuments(ctx, "default", "", 0, true, false) assert.NoError(t, err) assert.Equal(t, "", docs[0].Snapshot) - docs, err = adminCli.ListDocuments(ctx, "default", previousRefKey, 0, true, true) + docs, err = adminCli.ListDocuments(ctx, "default", "", 0, true, true) assert.NoError(t, err) assert.NotEqual(t, 0, len(docs[0].Snapshot)) }) diff --git a/test/sharding/mongo_client_test.go b/test/sharding/mongo_client_test.go index 682f34110..a92bdc125 100644 --- a/test/sharding/mongo_client_test.go +++ b/test/sharding/mongo_client_test.go @@ -21,14 +21,12 @@ package sharding import ( "context" "fmt" - "strconv" "testing" "github.com/stretchr/testify/assert" "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/pkg/document/key" - "github.com/yorkie-team/yorkie/server/backend/database" "github.com/yorkie-team/yorkie/server/backend/database/mongo" "github.com/yorkie-team/yorkie/server/backend/database/testcases" "github.com/yorkie-team/yorkie/test/helper" @@ -120,22 +118,23 @@ func TestClientWithShardedDB(t *testing.T) { testcases.RunIsDocumentAttachedTest(t, cli, dummyProjectID) }) - t.Run("FindDocInfoByKeyAndID with duplicate ID test", func(t *testing.T) { + t.Run("FindDocInfoByRefKey with duplicate ID test", func(t *testing.T) { ctx := context.Background() - // 01. Initialize a project and create a document. - projectInfo, err := cli.CreateProjectInfo(ctx, t.Name(), dummyOwnerID, clientDeactivateThreshold) - assert.NoError(t, err) + projectID1 := types.ID("000000000000000000000000") + projectID2 := types.ID("FFFFFFFFFFFFFFFFFFFFFFFF") - docKey1 := key.Key(fmt.Sprintf("%s%d", "duplicateIDTestDocKey", 0)) - docInfo1, err := cli.FindDocInfoByKeyAndOwner(ctx, projectInfo.ID, dummyClientID, docKey1, true) + docKey1 := key.Key(fmt.Sprintf("%s%d", t.Name(), 1)) + docKey2 := key.Key(fmt.Sprintf("%s%d", t.Name(), 2)) + + // 01. Initialize a project and create a document. + docInfo1, err := cli.FindDocInfoByKeyAndOwner(ctx, projectID1, dummyClientID, docKey1, true) assert.NoError(t, err) // 02. Create an extra document with duplicate ID. - docKey2 := key.Key(fmt.Sprintf("%s%d", "duplicateIDTestDocKey", 5)) err = helper.CreateDummyDocumentWithID( shardedDBNameForMongoClient, - projectInfo.ID, + projectID2, docInfo1.ID, docKey2, ) @@ -144,7 +143,6 @@ func TestClientWithShardedDB(t *testing.T) { // 03. Check if there are two documents with the same ID. infos, err := helper.FindDocInfosWithID( shardedDBNameForMongoClient, - projectInfo.ID, docInfo1.ID, ) assert.NoError(t, err) @@ -153,69 +151,13 @@ func TestClientWithShardedDB(t *testing.T) { // 04. Check if the document is correctly found using docKey and docID. result, err := cli.FindDocInfoByRefKey( ctx, - projectInfo.ID, types.DocRefKey{ - Key: docKey1, - ID: docInfo1.ID, + ProjectID: projectID1, + DocID: docInfo1.ID, }, ) assert.NoError(t, err) assert.Equal(t, docInfo1.Key, result.Key) assert.Equal(t, docInfo1.ID, result.ID) }) - - t.Run("FindDocInfosByPaging with duplicate ID test", func(t *testing.T) { - const totalDocCnt = 10 - const duplicateIDDocCnt = 1 - ctx := context.Background() - - // 01. Initialize a project and create documents. - projectInfo, err := cli.CreateProjectInfo(ctx, t.Name(), dummyOwnerID, clientDeactivateThreshold) - assert.NoError(t, err) - - var docInfos []*database.DocInfo - var duplicateID types.ID - for i := 0; i < totalDocCnt-duplicateIDDocCnt; i++ { - testDocKey := key.Key("duplicateIDTestDocKey" + strconv.Itoa(i)) - docInfo, err := cli.FindDocInfoByKeyAndOwner(ctx, projectInfo.ID, dummyClientID, testDocKey, true) - assert.NoError(t, err) - docInfos = append(docInfos, docInfo) - - if i == 0 { - duplicateID = docInfo.ID - } - } - // NOTE(sejongk): sorting is required because doc_id may not sequentially increase in a sharded DB cluster. - testcases.SortDocInfos(docInfos) - - // 02. Create an extra document with duplicate ID. - for i := totalDocCnt - duplicateIDDocCnt; i < totalDocCnt; i++ { - testDocKey := key.Key("duplicateIDTestDocKey" + strconv.Itoa(i)) - err = helper.CreateDummyDocumentWithID( - shardedDBNameForMongoClient, - projectInfo.ID, - duplicateID, - testDocKey, - ) - assert.NoError(t, err) - docInfos = append(docInfos, &database.DocInfo{ - ID: duplicateID, - Key: testDocKey, - }) - } - testcases.SortDocInfos(docInfos) - - docKeysInReverse := make([]key.Key, 0, totalDocCnt) - for _, docInfo := range docInfos { - docKeysInReverse = append([]key.Key{docInfo.Key}, docKeysInReverse...) - } - - // 03. List the documents. - result, err := cli.FindDocInfosByPaging(ctx, projectInfo.ID, types.Paging[types.DocRefKey]{ - PageSize: 10, - IsForward: false, - }) - assert.NoError(t, err) - testcases.AssertKeys(t, docKeysInReverse, result) - }) }