diff --git a/api/types/project.go b/api/types/project.go index 1edd4ed28..420b0cf67 100644 --- a/api/types/project.go +++ b/api/types/project.go @@ -20,7 +20,6 @@ package types import "time" // Project is a project that consists of multiple documents and clients. -// It allows developers to work on the same cluster. type Project struct { // ID is the unique ID of the project. ID ID `json:"id"` diff --git a/api/yorkie/v1/cluster.pb.go b/api/yorkie/v1/cluster.pb.go deleted file mode 100644 index 20ae6b294..000000000 --- a/api/yorkie/v1/cluster.pb.go +++ /dev/null @@ -1,607 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: yorkie/v1/cluster.proto - -package v1 - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type BroadcastEventRequest struct { - PublisherId []byte `protobuf:"bytes,1,opt,name=publisher_id,json=publisherId,proto3" json:"publisher_id,omitempty"` - Event *DocEvent `protobuf:"bytes,2,opt,name=event,proto3" json:"event,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BroadcastEventRequest) Reset() { *m = BroadcastEventRequest{} } -func (m *BroadcastEventRequest) String() string { return proto.CompactTextString(m) } -func (*BroadcastEventRequest) ProtoMessage() {} -func (*BroadcastEventRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_af343d6b11b4d4ad, []int{0} -} -func (m *BroadcastEventRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BroadcastEventRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BroadcastEventRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *BroadcastEventRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_BroadcastEventRequest.Merge(m, src) -} -func (m *BroadcastEventRequest) XXX_Size() int { - return m.Size() -} -func (m *BroadcastEventRequest) XXX_DiscardUnknown() { - xxx_messageInfo_BroadcastEventRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_BroadcastEventRequest proto.InternalMessageInfo - -func (m *BroadcastEventRequest) GetPublisherId() []byte { - if m != nil { - return m.PublisherId - } - return nil -} - -func (m *BroadcastEventRequest) GetEvent() *DocEvent { - if m != nil { - return m.Event - } - return nil -} - -type BroadcastEventResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BroadcastEventResponse) Reset() { *m = BroadcastEventResponse{} } -func (m *BroadcastEventResponse) String() string { return proto.CompactTextString(m) } -func (*BroadcastEventResponse) ProtoMessage() {} -func (*BroadcastEventResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_af343d6b11b4d4ad, []int{1} -} -func (m *BroadcastEventResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BroadcastEventResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BroadcastEventResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *BroadcastEventResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BroadcastEventResponse.Merge(m, src) -} -func (m *BroadcastEventResponse) XXX_Size() int { - return m.Size() -} -func (m *BroadcastEventResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BroadcastEventResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_BroadcastEventResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*BroadcastEventRequest)(nil), "yorkie.v1.BroadcastEventRequest") - proto.RegisterType((*BroadcastEventResponse)(nil), "yorkie.v1.BroadcastEventResponse") -} - -func init() { proto.RegisterFile("yorkie/v1/cluster.proto", fileDescriptor_af343d6b11b4d4ad) } - -var fileDescriptor_af343d6b11b4d4ad = []byte{ - // 243 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xaf, 0xcc, 0x2f, 0xca, - 0xce, 0x4c, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0xce, 0x29, 0x2d, 0x2e, 0x49, 0x2d, 0xd2, 0x2b, 0x28, - 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x84, 0x48, 0xe8, 0x95, 0x19, 0x4a, 0x49, 0x22, 0xd4, 0x14, 0xa5, - 0x16, 0xe7, 0x97, 0x16, 0x25, 0xa7, 0x16, 0x43, 0x54, 0x29, 0xa5, 0x72, 0x89, 0x3a, 0x15, 0xe5, - 0x27, 0xa6, 0x24, 0x27, 0x16, 0x97, 0xb8, 0x96, 0xa5, 0xe6, 0x95, 0x04, 0xa5, 0x16, 0x96, 0xa6, - 0x16, 0x97, 0x08, 0x29, 0x72, 0xf1, 0x14, 0x94, 0x26, 0xe5, 0x64, 0x16, 0x67, 0xa4, 0x16, 0xc5, - 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, 0x71, 0xc3, 0xc5, 0x3c, 0x53, 0x84, 0x34, - 0xb9, 0x58, 0x53, 0x41, 0x5a, 0x24, 0x98, 0x14, 0x18, 0x35, 0xb8, 0x8d, 0x84, 0xf5, 0xe0, 0x36, - 0xea, 0xb9, 0xe4, 0x27, 0x43, 0x4c, 0x83, 0xa8, 0x50, 0x92, 0xe0, 0x12, 0x43, 0xb7, 0xa6, 0xb8, - 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0x28, 0x93, 0x8b, 0xcf, 0x19, 0xe2, 0xee, 0xe0, 0xd4, 0xa2, 0xb2, - 0xcc, 0xe4, 0x54, 0xa1, 0x70, 0x2e, 0x3e, 0x54, 0xb5, 0x42, 0x0a, 0x48, 0x26, 0x63, 0x75, 0xad, - 0x94, 0x22, 0x1e, 0x15, 0x10, 0x8b, 0x94, 0x18, 0x9c, 0xb4, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, - 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x19, 0x8f, 0xe5, 0x18, 0xb8, 0x04, 0x53, 0x52, 0xcb, - 0x60, 0x3a, 0x13, 0x0b, 0x32, 0xf5, 0xca, 0x0c, 0x03, 0x18, 0xa3, 0x58, 0xf4, 0xac, 0xcb, 0x0c, - 0x93, 0xd8, 0xc0, 0xe1, 0x63, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x12, 0x41, 0xee, 0x60, - 0x01, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ClusterServiceClient is the client API for ClusterService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ClusterServiceClient interface { - BroadcastEvent(ctx context.Context, in *BroadcastEventRequest, opts ...grpc.CallOption) (*BroadcastEventResponse, error) -} - -type clusterServiceClient struct { - cc *grpc.ClientConn -} - -func NewClusterServiceClient(cc *grpc.ClientConn) ClusterServiceClient { - return &clusterServiceClient{cc} -} - -func (c *clusterServiceClient) BroadcastEvent(ctx context.Context, in *BroadcastEventRequest, opts ...grpc.CallOption) (*BroadcastEventResponse, error) { - out := new(BroadcastEventResponse) - err := c.cc.Invoke(ctx, "/yorkie.v1.ClusterService/BroadcastEvent", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ClusterServiceServer is the server API for ClusterService service. -type ClusterServiceServer interface { - BroadcastEvent(context.Context, *BroadcastEventRequest) (*BroadcastEventResponse, error) -} - -// UnimplementedClusterServiceServer can be embedded to have forward compatible implementations. -type UnimplementedClusterServiceServer struct { -} - -func (*UnimplementedClusterServiceServer) BroadcastEvent(ctx context.Context, req *BroadcastEventRequest) (*BroadcastEventResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BroadcastEvent not implemented") -} - -func RegisterClusterServiceServer(s *grpc.Server, srv ClusterServiceServer) { - s.RegisterService(&_ClusterService_serviceDesc, srv) -} - -func _ClusterService_BroadcastEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(BroadcastEventRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ClusterServiceServer).BroadcastEvent(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/yorkie.v1.ClusterService/BroadcastEvent", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ClusterServiceServer).BroadcastEvent(ctx, req.(*BroadcastEventRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _ClusterService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "yorkie.v1.ClusterService", - HandlerType: (*ClusterServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "BroadcastEvent", - Handler: _ClusterService_BroadcastEvent_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "yorkie/v1/cluster.proto", -} - -func (m *BroadcastEventRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BroadcastEventRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BroadcastEventRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Event != nil { - { - size, err := m.Event.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCluster(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.PublisherId) > 0 { - i -= len(m.PublisherId) - copy(dAtA[i:], m.PublisherId) - i = encodeVarintCluster(dAtA, i, uint64(len(m.PublisherId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *BroadcastEventResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BroadcastEventResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BroadcastEventResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - return len(dAtA) - i, nil -} - -func encodeVarintCluster(dAtA []byte, offset int, v uint64) int { - offset -= sovCluster(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *BroadcastEventRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PublisherId) - if l > 0 { - n += 1 + l + sovCluster(uint64(l)) - } - if m.Event != nil { - l = m.Event.Size() - n += 1 + l + sovCluster(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *BroadcastEventResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovCluster(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozCluster(x uint64) (n int) { - return sovCluster(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *BroadcastEventRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCluster - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BroadcastEventRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BroadcastEventRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PublisherId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCluster - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthCluster - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthCluster - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PublisherId = append(m.PublisherId[:0], dAtA[iNdEx:postIndex]...) - if m.PublisherId == nil { - m.PublisherId = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Event", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCluster - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCluster - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCluster - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Event == nil { - m.Event = &DocEvent{} - } - if err := m.Event.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCluster(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCluster - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BroadcastEventResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCluster - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BroadcastEventResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BroadcastEventResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipCluster(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCluster - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipCluster(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCluster - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCluster - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCluster - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthCluster - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupCluster - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthCluster - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthCluster = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCluster = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupCluster = fmt.Errorf("proto: unexpected end of group") -) diff --git a/api/yorkie/v1/cluster.proto b/api/yorkie/v1/cluster.proto deleted file mode 100644 index cac0a9087..000000000 --- a/api/yorkie/v1/cluster.proto +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2022 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. - */ -syntax = "proto3"; - -package yorkie.v1; - -import "yorkie/v1/resources.proto"; - -option go_package = ".;v1"; - -option java_multiple_files = true; -option java_package = "dev.yorkie.api.v1"; - -// Cluster is a service that provides a API used by Yorkie Cluster. -service ClusterService { - rpc BroadcastEvent (BroadcastEventRequest) returns (BroadcastEventResponse) {} -} - -message BroadcastEventRequest { - bytes publisher_id = 1; - DocEvent event = 2; -} - -message BroadcastEventResponse {} diff --git a/cmd/yorkie/server.go b/cmd/yorkie/server.go index 4d7d8bf83..56057c307 100644 --- a/cmd/yorkie/server.go +++ b/cmd/yorkie/server.go @@ -27,7 +27,6 @@ import ( "github.com/yorkie-team/yorkie/server" "github.com/yorkie-team/yorkie/server/backend/database/mongo" - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" "github.com/yorkie-team/yorkie/server/logging" ) @@ -85,16 +84,6 @@ func newServerCmd() *cobra.Command { } } - if etcdEndpoints != nil { - conf.ETCD = &etcd.Config{ - Endpoints: etcdEndpoints, - DialTimeout: etcdDialTimeout.String(), - Username: etcdUsername, - Password: etcdPassword, - LockLeaseTime: etcdLockLeaseTime.String(), - } - } - // If config file is given, command-line arguments will be overwritten. if flagConfPath != "" { parsed, err := server.NewConfigFromFile(flagConfPath) @@ -256,36 +245,6 @@ func init() { server.DefaultMongoPingTimeout, "Mongo DB's ping timeout", ) - cmd.Flags().StringSliceVar( - &etcdEndpoints, - "etcd-endpoints", - nil, - "Comma separated list of etcd endpoints", - ) - cmd.Flags().DurationVar( - &etcdDialTimeout, - "etcd-dial-timeout", - etcd.DefaultDialTimeout, - "ETCD's dial timeout", - ) - cmd.Flags().StringVar( - &etcdUsername, - "etcd-username", - "", - "ETCD's user name", - ) - cmd.Flags().StringVar( - &etcdPassword, - "etcd-password", - "", - "ETCD's password", - ) - cmd.Flags().DurationVar( - &etcdLockLeaseTime, - "etcd-lock-lease-time", - etcd.DefaultLockLeaseTime, - "ETCD's lease time for lock", - ) cmd.Flags().StringVar( &conf.Backend.AdminUser, "backend-admin-user", diff --git a/design/README.md b/design/README.md index a8c182d57..391d30d86 100644 --- a/design/README.md +++ b/design/README.md @@ -11,7 +11,6 @@ - [Garbage Collection for Text Type](gc-for-text-type.md): Garbage collection for text nodes - [Housekeeping](housekeeping.md): Deactivating outdated clients for efficient garbage collection - [Retention](retention.md): Clearing unnecessary changes with `--backend-snapshot-with-purging-changes` flag -- [Cluster Mode](cluster-mode.md): Multiple-agent cluster mode with ETCD - [Document Removal](document-removal.md): Soft deletion of document ## Maintaining the Document diff --git a/design/cluster-mode.md b/design/cluster-mode.md deleted file mode 100644 index fecbbfc0b..000000000 --- a/design/cluster-mode.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -title: cluster-mode -target-version: 0.1.6 ---- - -# Cluster Mode - -## Summary - -In a production environment, it is generally expected more than one agent to -handle client's requests. Even if an agent goes down, the other agents must be -able to handle the request. To support this scenario, agents must be able to -increase or decrease easily in the cluster. We will provide a Cluster Mode in -which multiple agents can run by moving agent's local state to a remote -location. - -### Goals - -Provide cluster mode when the user sets the etcd configuration. If the user does -not set etcd configuration, agent runs in the standalone mode as before. - -### Non-Goals - -In the cluster, the load balancer is not provided by Yorkie directly, we only -provide a guide for users to configure themselves for their own environment. - -## Proposal details - -### How to use - -When users set etcd configuration in `config.yml`, internal etcd client is -created to store agent's states at the remote location when the agent starts. - -```yaml -RPC: - Port: 11101, - CertFile: "", - KeyFile: "" - - // ... other configurations... -ETCD: - Endpoints: [ - "localhost:2379" - ] -``` - -### How does it work? - -An example when a user runs two Agents in cluster mode with etcd and introduces -load balancer is as follows: - -![cluster-mode-example](media/cluster-mode-example.png) - -- Load Balancer: It Receives requests from clients and forwards it to one of - Agents. -- Broadcast Channel: It is used to deliver `DocEvent` to other Agents when it - occurs by a Client connected to the Agent. -- etcd: etcd is responsible for three tasks. it is used to maintain `MemberMaps` - , a map of agents in the cluster. It is used to create cluster-wide locks and - to store `SubscriptionMaps`. - -The agent's states to be moved to etcd are as follows: - -- `LockerMap`: A map of locker used to maintain consistency of metadata of the - documents such as checkpoints when modifying documents. -- `SubscriptionMap`: A map of subscription used to deliver events to other peers - when an event such as a document change occurs. - -The interfaces of `LockerMap` and `SubscriptionMap` are defined in the -`backend/sync` package and there are memory-based implementations in -`backend/sync/memory` and etcd-based implementations in `backend/sync/etcd`. - -#### MemberMap - -Agents have replicas of `MemberMap` within the cluster in an optimistic -replication manner. `MemberMap` is used by an Agent to broadcast DocEvents to -other Agents. - -![member-map](media/member-map.png) - -When an Agent started, background routines used to maintain -`MemberMap` are executed. These routines save the current Agent information by -periodically with the TTL in etcd and update the local MemberMap with any -changes to the `/agents` in etcd. - -#### LockerMap based on etcd - -The etcd-based implementation of `LockerMap` uses the lock and unlock -of [etcd concurrency API](https://etcd.io/docs/v3.4.0/dev-guide/api_concurrency_reference_v3/) -. The concurrency API provides lease time to avoid the problem that crashed -agent holding a lock forever and never releasing it. - -Because many factors( -e.g. [stop-the-world GC pause of a runtime](https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html)) -can cause false expiration of a granted lease, `serverSeq` is used as a fencing -token. - -![fencing tokens][fencing-tokens] - -```go -// backend/database/mongo/client.go > StoreChangeInfos -res, err := c.collection(ColDocuments, opts).UpdateOne(ctx, bson.M{ -"_id": encodedDocID, -"server_seq": initialServerSeq, -}, bson.M{ -"$set": bson.M{ -"server_seq": docInfo.ServerSeq, -"updated_at": now, -}, -}) -if res.MatchedCount == 0 { -return nil, fmt.Errorf("%s: %w", docInfo.ID, db.ErrConflictOnUpdate) -} -``` - -[fencing-tokens]: https://martin.kleppmann.com/2016/02/fencing-tokens.png diff --git a/design/pub-sub.md b/design/pub-sub.md index 153af3b2d..25658fcac 100644 --- a/design/pub-sub.md +++ b/design/pub-sub.md @@ -137,7 +137,4 @@ func (s *yorkieServer) WatchDocuments( ### Risks and Mitigation -Currently, Subscription instances are managed in memory. This can be a problem -when building a cluster of servers. -To solve this problem, we are planning to support cluster-mode -using [etcd](https://github.com/etcd-io/etcd). +Currently, Subscription instances are managed in memory. \ No newline at end of file diff --git a/docker/README.md b/docker/README.md index 0bd27bc56..58e2afb05 100644 --- a/docker/README.md +++ b/docker/README.md @@ -17,6 +17,6 @@ docker-compose -f docker/docker-compose.yml down The docker-compose files we use are as follows: - `docker-compose.yml`: This file is used to run Yorkie's integration tests. It - runs MongoDB and etcd. + runs MongoDB. - `docker-compose-full.yml`: This file launches all the applications needed to develop Yorkie. It also runs monitoring tools such as Prometheus and Grafana. diff --git a/docker/docker-compose-full.yml b/docker/docker-compose-full.yml index 6e0c3789e..c6739062d 100644 --- a/docker/docker-compose-full.yml +++ b/docker/docker-compose-full.yml @@ -17,22 +17,6 @@ services: - '3000:3000' depends_on: - prometheus - etcd: - image: quay.io/coreos/etcd:latest - container_name: etcd - entrypoint: /usr/local/bin/etcd - command: - - '--name=etcd' - - '--initial-advertise-peer-urls=http://etcd:2379,http://etcd:2380' - - '--advertise-client-urls=http://etcd:2379,http://etcd:2380' - - '--listen-client-urls=http://0.0.0.0:2379' - - '--listen-peer-urls=http://0.0.0.0:2380' - - '--initial-cluster=etcd=http://etcd:2379,etcd=http://etcd:2380' - - '--initial-cluster-token=etcd' - - '--initial-cluster-state=new' - ports: - - '2379:2379' - - '2380:2380' mongo: image: mongo:latest container_name: mongo diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index ab4b14f86..47380177c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,22 +1,6 @@ version: '3.3' services: - etcd: - image: quay.io/coreos/etcd:latest - container_name: etcd - entrypoint: /usr/local/bin/etcd - command: - - '--name=etcd' - - '--initial-advertise-peer-urls=http://etcd:2379,http://etcd:2380' - - '--advertise-client-urls=http://etcd:2379,http://etcd:2380' - - '--listen-client-urls=http://0.0.0.0:2379' - - '--listen-peer-urls=http://0.0.0.0:2380' - - '--initial-cluster=etcd=http://etcd:2379,etcd=http://etcd:2380' - - '--initial-cluster-token=etcd' - - '--initial-cluster-state=new' - ports: - - '2379:2379' - - '2380:2380' mongo: image: mongo:latest container_name: mongo diff --git a/go.mod b/go.mod index 76361dc40..d527f2633 100644 --- a/go.mod +++ b/go.mod @@ -18,8 +18,6 @@ require ( github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 github.com/undefinedlabs/go-mpatch v1.0.6 - go.etcd.io/etcd/api/v3 v3.5.5 - go.etcd.io/etcd/client/v3 v3.5.5 go.mongodb.org/mongo-driver v1.10.3 go.uber.org/zap v1.23.0 golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b @@ -33,8 +31,6 @@ require ( require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/coreos/go-semver v0.3.0 // indirect - github.com/coreos/go-systemd/v22 v22.4.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect @@ -56,7 +52,6 @@ require ( github.com/xdg-go/scram v1.1.1 // indirect github.com/xdg-go/stringprep v1.0.3 // indirect github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect diff --git a/go.sum b/go.sum index c1f411da8..2fcb442b1 100644 --- a/go.sum +++ b/go.sum @@ -38,7 +38,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -53,27 +52,15 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/go-systemd/v22 v22.4.0 h1:y9YHcjnjynCd/DVbg5j9L/33jQM3MxJlbj/zWskzfGU= -github.com/coreos/go-systemd/v22 v22.4.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -94,7 +81,6 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -155,14 +141,12 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hackerwins/go-memdb v1.3.3-0.20211225080334-513a74641622 h1:7UYuTq6zV83XV4zqn14gUuTtcywzbxGhUnj+hr/MUrE= github.com/hackerwins/go-memdb v1.3.3-0.20211225080334-513a74641622/go.mod h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg= github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -236,7 +220,6 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= @@ -261,7 +244,6 @@ github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0ua github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8= github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= @@ -282,7 +264,6 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -306,13 +287,6 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.etcd.io/etcd/api/v3 v3.5.5 h1:BX4JIbQ7hl7+jL+g+2j5UAr0o1bctCm6/Ct+ArBGkf0= -go.etcd.io/etcd/api/v3 v3.5.5/go.mod h1:KFtNaxGDw4Yx/BA4iPPwevUTAuqcsPxzyX8PHydchN8= -go.etcd.io/etcd/client/pkg/v3 v3.5.5 h1:9S0JUVvmrVl7wCF39iTQthdaaNIiAaQbmK75ogO6GU8= -go.etcd.io/etcd/client/pkg/v3 v3.5.5/go.mod h1:ggrwbk069qxpKPq8/FKkQ3Xq9y39kbFR4LnKszpRXeQ= -go.etcd.io/etcd/client/v3 v3.5.5 h1:q++2WTJbUgpQu4B6hCuT7VkdwaTP7Qz6Daak3WzbrlI= -go.etcd.io/etcd/client/v3 v3.5.5/go.mod h1:aApjR4WGlSumpnJ2kloS75h6aHUmAyaPLjHMxpc7E7c= go.mongodb.org/mongo-driver v1.10.3 h1:XDQEvmh6z1EUsXuIkXE9TaVeqHw6SwS1uf93jFs0HBA= go.mongodb.org/mongo-driver v1.10.3/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -320,18 +294,15 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -367,7 +338,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -376,7 +346,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -406,7 +375,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -467,10 +435,7 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -485,7 +450,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= @@ -535,7 +499,6 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -586,14 +549,12 @@ google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20220930163606-c98284e70a91 h1:Ezh2cpcnP5Rq60sLensUsFnxh7P6513NLvNtCm9iyJ4= google.golang.org/genproto v0.0.0-20220930163606-c98284e70a91/go.mod h1:3526vdqwhZAwq4wsRUaVG555sVgsNmIjRtO7t/JH29U= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -608,10 +569,6 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= google.golang.org/grpc v1.50.0 h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -637,10 +594,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -658,4 +613,3 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/server/admin/cluster_server.go b/server/admin/cluster_server.go deleted file mode 100644 index 68fd4ecb4..000000000 --- a/server/admin/cluster_server.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2021 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 admin - -import ( - "context" - - "github.com/yorkie-team/yorkie/api/converter" - "github.com/yorkie-team/yorkie/api/types" - api "github.com/yorkie-team/yorkie/api/yorkie/v1" - "github.com/yorkie-team/yorkie/pkg/document/time" - "github.com/yorkie-team/yorkie/server/backend" -) - -// clusterServer is a normal server that processes the broadcast by the server. -type clusterServer struct { - backend *backend.Backend -} - -// newClusterServer creates a new instance of clusterServer. -func newClusterServer(be *backend.Backend) *clusterServer { - return &clusterServer{backend: be} -} - -// BroadcastEvent publishes the given event to the given document. -func (s *clusterServer) BroadcastEvent( - ctx context.Context, - request *api.BroadcastEventRequest, -) (*api.BroadcastEventResponse, error) { - actorID, err := time.ActorIDFromBytes(request.PublisherId) - if err != nil { - return nil, err - } - - docEvent, err := converter.FromDocEvent(request.Event) - if err != nil { - return nil, err - } - - switch docEvent.Type { - case types.DocumentsWatchedEvent, - types.DocumentsUnwatchedEvent, - types.DocumentsChangedEvent: - s.backend.Coordinator.PublishToLocal(ctx, actorID, *docEvent) - case types.PresenceChangedEvent: - if err := s.backend.Coordinator.UpdatePresence( - ctx, - &docEvent.Publisher, - docEvent.DocumentID, - ); err != nil { - return nil, err - } - - s.backend.Coordinator.PublishToLocal(ctx, actorID, *docEvent) - } - - return &api.BroadcastEventResponse{}, nil -} diff --git a/server/admin/interceptors/auth.go b/server/admin/interceptors/auth.go index ac21c0815..e4428f72a 100644 --- a/server/admin/interceptors/auth.go +++ b/server/admin/interceptors/auth.go @@ -18,7 +18,6 @@ package interceptors import ( "context" - "strings" grpcmiddleware "github.com/grpc-ecosystem/go-grpc-middleware" "google.golang.org/grpc" @@ -120,11 +119,8 @@ func (i *AuthInterceptor) Stream() grpc.StreamServerInterceptor { } func isRequiredAuth(method string) bool { - // NOTE(hackerwins): We don't need to authenticate the request if the - // request is from the peer clusters. return method != "/yorkie.v1.AdminService/LogIn" && - method != "/yorkie.v1.AdminService/SignUp" && - strings.HasPrefix(method, "/yorkie.v1.AdminService/") + method != "/yorkie.v1.AdminService/SignUp" } // authenticate does authenticate the request. diff --git a/server/admin/server.go b/server/admin/server.go index e1754f645..d3793d609 100644 --- a/server/admin/server.go +++ b/server/admin/server.go @@ -93,18 +93,13 @@ func NewServer(conf *Config, be *backend.Backend) *Server { } grpcServer := grpc.NewServer(opts...) - server := &Server{ conf: conf, grpcServer: grpcServer, backend: be, tokenManager: tokenManager, } - api.RegisterAdminServiceServer(grpcServer, server) - // TODO(hackerwins): ClusterServer need to be handled by different authentication mechanism. - // Consider extracting the servers to another grpcServer. - api.RegisterClusterServiceServer(grpcServer, newClusterServer(be)) return server } diff --git a/server/backend/backend.go b/server/backend/backend.go index c9c542947..3f9fd7e44 100644 --- a/server/backend/backend.go +++ b/server/backend/backend.go @@ -35,7 +35,6 @@ import ( "github.com/yorkie-team/yorkie/server/backend/database/mongo" "github.com/yorkie-team/yorkie/server/backend/housekeeping" "github.com/yorkie-team/yorkie/server/backend/sync" - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" memsync "github.com/yorkie-team/yorkie/server/backend/sync/memory" "github.com/yorkie-team/yorkie/server/logging" "github.com/yorkie-team/yorkie/server/profiling/prometheus" @@ -60,9 +59,7 @@ type Backend struct { func New( conf *Config, mongoConf *mongo.Config, - etcdConf *etcd.Config, housekeepingConf *housekeeping.Config, - clusterAddr string, metrics *prometheus.Metrics, ) (*Backend, error) { hostname := conf.Hostname @@ -75,10 +72,9 @@ func New( } serverInfo := &sync.ServerInfo{ - ID: xid.New().String(), - Hostname: hostname, - ClusterAddr: clusterAddr, - UpdatedAt: time.Now(), + ID: xid.New().String(), + Hostname: hostname, + UpdatedAt: time.Now(), } bg := background.New() @@ -97,20 +93,10 @@ func New( } } - var coordinator sync.Coordinator - if etcdConf != nil { - etcdClient, err := etcd.Dial(etcdConf, serverInfo) - if err != nil { - return nil, err - } - if err := etcdClient.Initialize(); err != nil { - return nil, err - } - - coordinator = etcdClient - } else { - coordinator = memsync.NewCoordinator(serverInfo) - } + // TODO(hackerwins): Implement the coordinator for a shard. For now, we + // distribute workloads to all shards per document. In the future, we + // will need to distribute workloads of a document. + coordinator := memsync.NewCoordinator(serverInfo) authWebhookCache, err := cache.NewLRUExpireCache[string, *types.AuthWebhookResponse](conf.AuthWebhookCacheSize) if err != nil { @@ -134,7 +120,6 @@ func New( logging.DefaultLogger().Infof( "backend created: id: %s, rpc: %s: db: %s", serverInfo.ID, - serverInfo.ClusterAddr, dbInfo, ) @@ -178,12 +163,7 @@ func (b *Backend) Shutdown() error { logging.DefaultLogger().Error(err) } - logging.DefaultLogger().Infof( - "backend stoped: id: %s, rpc: %s", - b.serverInfo.ID, - b.serverInfo.ClusterAddr, - ) - + logging.DefaultLogger().Infof("backend stoped: id: %s", b.serverInfo.ID) return nil } diff --git a/server/backend/sync/coordinator.go b/server/backend/sync/coordinator.go index 6296a1953..ff70e1006 100644 --- a/server/backend/sync/coordinator.go +++ b/server/backend/sync/coordinator.go @@ -19,24 +19,17 @@ package sync import ( "context" - "errors" gotime "time" "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/pkg/document/time" ) -var ( - // ErrEmptyDocKeys is returned when the given keys is empty. - ErrEmptyDocKeys = errors.New("empty doc keys") -) - // ServerInfo represents the information of the Server. type ServerInfo struct { - ID string `json:"id"` - Hostname string `json:"hostname"` - ClusterAddr string `json:"cluster_addr"` - UpdatedAt gotime.Time `json:"updated_at"` + ID string `json:"id"` + Hostname string `json:"hostname"` + UpdatedAt gotime.Time `json:"updated_at"` } // Coordinator provides synchronization functions such as locks and event Pub/Sub. diff --git a/server/backend/sync/etcd/client.go b/server/backend/sync/etcd/client.go deleted file mode 100644 index 7981e37ae..000000000 --- a/server/backend/sync/etcd/client.go +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2021 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 etcd provides etcd implementation of the sync. It is used to -// synchronize the state of the cluster. -package etcd - -import ( - "context" - "fmt" - gosync "sync" - - clientv3 "go.etcd.io/etcd/client/v3" - "google.golang.org/grpc" - - api "github.com/yorkie-team/yorkie/api/yorkie/v1" - "github.com/yorkie-team/yorkie/server/backend/sync" - "github.com/yorkie-team/yorkie/server/backend/sync/memory" - "github.com/yorkie-team/yorkie/server/logging" -) - -// clusterClientInfo represents a cluster client and its connection. -type clusterClientInfo struct { - client api.ClusterServiceClient - conn *grpc.ClientConn -} - -// Client is a client that connects to ETCD. -type Client struct { - config *Config - serverInfo *sync.ServerInfo - - localPubSub *memory.PubSub - - memberMapMu *gosync.RWMutex - memberMap map[string]*sync.ServerInfo - clusterClientMapMu *gosync.RWMutex - clusterClientMap map[string]*clusterClientInfo - - client *clientv3.Client - - ctx context.Context - cancelFunc context.CancelFunc -} - -// newClient creates a new instance of Client. -func newClient( - conf *Config, - serverInfo *sync.ServerInfo, -) *Client { - ctx, cancelFunc := context.WithCancel(context.Background()) - - return &Client{ - config: conf, - serverInfo: serverInfo, - - localPubSub: memory.NewPubSub(), - - memberMapMu: &gosync.RWMutex{}, - memberMap: make(map[string]*sync.ServerInfo), - clusterClientMapMu: &gosync.RWMutex{}, - clusterClientMap: make(map[string]*clusterClientInfo), - - ctx: ctx, - cancelFunc: cancelFunc, - } -} - -// Dial creates a new instance of Client and dials the given ETCD. -func Dial( - conf *Config, - serverInfo *sync.ServerInfo, -) ( - *Client, error) { - c := newClient(conf, serverInfo) - - if err := c.Dial(); err != nil { - return nil, err - } - - return c, nil -} - -// Dial dials the given ETCD. -func (c *Client) Dial() error { - cli, err := clientv3.New(clientv3.Config{ - Endpoints: c.config.Endpoints, - DialTimeout: c.config.ParseDialTimeout(), - DialOptions: []grpc.DialOption{grpc.WithBlock()}, - Username: c.config.Username, - Password: c.config.Password, - }) - if err != nil { - return fmt.Errorf("connect to etcd: %w", err) - } - - logging.DefaultLogger().Infof("etcd connected, URI: %s", c.config.Endpoints) - - c.client = cli - return nil -} - -// Close all resources of this client. -func (c *Client) Close() error { - c.cancelFunc() - - if err := c.removeServerInfo(context.Background()); err != nil { - logging.DefaultLogger().Error(err) - } - - for id := range c.clusterClientMap { - c.removeClusterClient(id) - } - - if err := c.client.Close(); err != nil { - return fmt.Errorf("close etcd client: %w", err) - } - - return nil -} diff --git a/server/backend/sync/etcd/client_test.go b/server/backend/sync/etcd/client_test.go deleted file mode 100644 index 4d9aa3602..000000000 --- a/server/backend/sync/etcd/client_test.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020 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 etcd_test - -import ( - "context" - "sync" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" -) - -func TestClient(t *testing.T) { - t.Run("dial timeout test", func(t *testing.T) { - var err error - - wg := sync.WaitGroup{} - wg.Add(1) - go func() { - defer wg.Done() - _, err = etcd.Dial(&etcd.Config{ - Endpoints: []string{"invalid-endpoint:2379"}, - DialTimeout: "1s", - }, nil) - }() - wg.Wait() - - assert.ErrorAs(t, err, &context.DeadlineExceeded) - }) -} - -func TestConfig_Validate(t *testing.T) { - scenarios := []*struct { - config *etcd.Config - expected error - }{ - {config: &etcd.Config{Endpoints: []string{}}, expected: etcd.ErrEmptyEndpoints}, - { - config: &etcd.Config{ - Endpoints: []string{"localhost:2379"}, - DialTimeout: "5s", - LockLeaseTime: "30s", - }, - expected: nil, - }, - } - for _, scenario := range scenarios { - assert.ErrorIs( - t, scenario.config.Validate(), scenario.expected, "provided config: %#v", scenario.config) - } -} diff --git a/server/backend/sync/etcd/config.go b/server/backend/sync/etcd/config.go deleted file mode 100644 index aba2241e5..000000000 --- a/server/backend/sync/etcd/config.go +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2021 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 etcd - -import ( - "errors" - "fmt" - "time" -) - -const ( - // DefaultDialTimeout is the default dial timeout of etcd connection. - DefaultDialTimeout = 5 * time.Second - - // DefaultLockLeaseTime is the default lease time of lock. - DefaultLockLeaseTime = 30 * time.Second -) - -var ( - //ErrEmptyEndpoints occurs when the endpoints in the config is empty. - ErrEmptyEndpoints = errors.New("length of etcd endpoints must be greater than 0") -) - -// Config is the configuration for creating a Client instance. -type Config struct { - Endpoints []string `yaml:"Endpoints"` - DialTimeout string `yaml:"DialTimeout"` - Username string `yaml:"Username"` - Password string `yaml:"Password"` - - LockLeaseTime string `yaml:"LockLeaseTime"` -} - -// Validate validates this config. -func (c *Config) Validate() error { - if len(c.Endpoints) == 0 { - return ErrEmptyEndpoints - } - - if _, err := time.ParseDuration(c.DialTimeout); err != nil { - return fmt.Errorf( - `invalid argument "%s" for "--etcd-dial-timeout" flag: %w`, - c.DialTimeout, - err, - ) - } - - if _, err := time.ParseDuration(c.LockLeaseTime); err != nil { - return fmt.Errorf( - `invalid argument "%s" for "--etcd-lock-lease-time" flag: %w`, - c.LockLeaseTime, - err, - ) - } - - return nil -} - -// ParseDialTimeout returns timeout for lock. -func (c *Config) ParseDialTimeout() time.Duration { - result, err := time.ParseDuration(c.DialTimeout) - if err != nil { - panic(err) - } - - return result -} - -// ParseLockLeaseTime returns lease time for lock. -func (c *Config) ParseLockLeaseTime() time.Duration { - result, err := time.ParseDuration(c.LockLeaseTime) - if err != nil { - panic(err) - } - - return result -} diff --git a/server/backend/sync/etcd/locker.go b/server/backend/sync/etcd/locker.go deleted file mode 100644 index f570bdc5e..000000000 --- a/server/backend/sync/etcd/locker.go +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2021 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 etcd - -import ( - "context" - "fmt" - - "go.etcd.io/etcd/client/v3/concurrency" - - "github.com/yorkie-team/yorkie/server/backend/sync" -) - -// NewLocker creates locker of the given key. -func (c *Client) NewLocker( - ctx context.Context, - key sync.Key, -) (sync.Locker, error) { - ttl := int(c.config.ParseLockLeaseTime().Seconds()) - session, err := concurrency.NewSession( - c.client, - concurrency.WithContext(ctx), - concurrency.WithTTL(ttl), - ) - if err != nil { - return nil, fmt.Errorf("create session: %w", err) - } - - return &internalLocker{ - session, - concurrency.NewMutex(session, key.String()), - }, nil -} - -type internalLocker struct { - session *concurrency.Session - mu *concurrency.Mutex -} - -// Lock locks the mutex with a cancelable context -func (il *internalLocker) Lock(ctx context.Context) error { - if err := il.mu.Lock(ctx); err != nil { - return fmt.Errorf("concurrent lock: %w", err) - } - - return nil -} - -// TryLock locks the mutex if not already locked by another session. -func (il *internalLocker) TryLock(ctx context.Context) error { - if err := il.mu.TryLock(ctx); err != nil { - if err == concurrency.ErrLocked { - return sync.ErrAlreadyLocked - } - return fmt.Errorf("try concurrent lock: %w", err) - } - - return nil -} - -// Unlock unlocks the mutex. -func (il *internalLocker) Unlock(ctx context.Context) error { - if err := il.mu.Unlock(ctx); err != nil { - return fmt.Errorf("concurrent unlock: %w", err) - } - - if err := il.session.Close(); err != nil { - return fmt.Errorf("close session: %w", err) - } - - return nil -} diff --git a/server/backend/sync/etcd/membermap.go b/server/backend/sync/etcd/membermap.go deleted file mode 100644 index 62732ed16..000000000 --- a/server/backend/sync/etcd/membermap.go +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright 2021 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 etcd - -import ( - "context" - "encoding/json" - "fmt" - "path" - "time" - - "go.etcd.io/etcd/api/v3/mvccpb" - clientv3 "go.etcd.io/etcd/client/v3" - - "github.com/yorkie-team/yorkie/server/backend/sync" - "github.com/yorkie-team/yorkie/server/logging" -) - -const ( - serversPath = "/servers" - putServerInfoPeriod = 5 * time.Second - serverValueTTL = 7 * time.Second -) - -// Initialize put this server to etcd with TTL periodically. -func (c *Client) Initialize() error { - ctx := context.Background() - if err := c.putServerInfo(ctx); err != nil { - return err - } - if err := c.initializeMemberMap(ctx); err != nil { - return err - } - - go c.syncServerInfos() - go c.putServerPeriodically() - - return nil -} - -// Members returns the members of this cluster. -func (c *Client) Members() map[string]*sync.ServerInfo { - c.memberMapMu.RLock() - defer c.memberMapMu.RUnlock() - - memberMap := make(map[string]*sync.ServerInfo) - for _, member := range c.memberMap { - memberMap[member.ID] = &sync.ServerInfo{ - ID: member.ID, - Hostname: member.Hostname, - ClusterAddr: member.ClusterAddr, - UpdatedAt: member.UpdatedAt, - } - } - - return memberMap -} - -// initializeMemberMap initializes the local member map by loading data from etcd. -func (c *Client) initializeMemberMap(ctx context.Context) error { - getResponse, err := c.client.Get(ctx, serversPath, clientv3.WithPrefix()) - if err != nil { - return fmt.Errorf("get %s: %w", serversPath, err) - } - - for _, kv := range getResponse.Kvs { - var info sync.ServerInfo - if err := json.Unmarshal(kv.Value, &info); err != nil { - return fmt.Errorf("unmarshal %s: %w", kv.Key, err) - } - - c.setServerInfo(string(kv.Key), info) - } - return nil -} - -// putServerPeriodically puts the local server in etcd periodically. -func (c *Client) putServerPeriodically() { - for { - if err := c.putServerInfo(c.ctx); err != nil { - logging.DefaultLogger().Error(err) - } - - select { - case <-time.After(putServerInfoPeriod): - case <-c.ctx.Done(): - return - } - } -} - -// putServerInfo puts the local server in etcd. -func (c *Client) putServerInfo(ctx context.Context) error { - grantResponse, err := c.client.Grant(ctx, int64(serverValueTTL.Seconds())) - if err != nil { - return fmt.Errorf("grant %s: %w", c.serverInfo.ID, err) - } - - serverInfo := *c.serverInfo - serverInfo.UpdatedAt = time.Now() - bytes, err := json.Marshal(serverInfo) - if err != nil { - return fmt.Errorf("marshal %s: %w", c.serverInfo.ID, err) - } - - k := path.Join(serversPath, c.serverInfo.ID) - _, err = c.client.Put(ctx, k, string(bytes), clientv3.WithLease(grantResponse.ID)) - if err != nil { - return fmt.Errorf("put %s: %w", k, err) - } - return nil -} - -// removeServerInfo removes the local server in etcd. -func (c *Client) removeServerInfo(ctx context.Context) error { - k := path.Join(serversPath, c.serverInfo.ID) - _, err := c.client.Delete(ctx, k) - if err != nil { - return fmt.Errorf("remove %s: %w", k, err) - } - return nil -} - -// syncServerInfos syncs the local member map with etcd. -func (c *Client) syncServerInfos() { - // TODO(hackerwins): When the network is recovered, check if we need to - // recover the channels watched in the situation. - watchCh := c.client.Watch(c.ctx, serversPath, clientv3.WithPrefix()) - for { - select { - case watchResponse := <-watchCh: - for _, event := range watchResponse.Events { - k := string(event.Kv.Key) - switch event.Type { - case mvccpb.PUT: - var info sync.ServerInfo - if err := json.Unmarshal(event.Kv.Value, &info); err != nil { - logging.DefaultLogger().Error(err) - continue - } - c.setServerInfo(k, info) - case mvccpb.DELETE: - c.deleteServerInfo(k) - c.removeClusterClient(k) - } - } - case <-c.ctx.Done(): - return - } - } -} - -// setServerInfo sets the given serverInfo to the local member map. -func (c *Client) setServerInfo(key string, value sync.ServerInfo) { - c.memberMapMu.Lock() - defer c.memberMapMu.Unlock() - - c.memberMap[key] = &value -} - -// deleteServerInfo removes the given serverInfo from the local member map. -func (c *Client) deleteServerInfo(id string) { - c.memberMapMu.Lock() - defer c.memberMapMu.Unlock() - - delete(c.memberMap, id) -} diff --git a/server/backend/sync/etcd/pubsub.go b/server/backend/sync/etcd/pubsub.go deleted file mode 100644 index fe821cedb..000000000 --- a/server/backend/sync/etcd/pubsub.go +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2021 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 etcd - -import ( - "context" - "fmt" - "path" - - clientv3 "go.etcd.io/etcd/client/v3" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - - "github.com/yorkie-team/yorkie/api/converter" - "github.com/yorkie-team/yorkie/api/types" - api "github.com/yorkie-team/yorkie/api/yorkie/v1" - "github.com/yorkie-team/yorkie/pkg/document/time" - "github.com/yorkie-team/yorkie/server/backend/sync" - "github.com/yorkie-team/yorkie/server/logging" -) - -const ( - subscriptionsPath = "/subscriptions" -) - -// Subscribe subscribes to the given keys. -func (c *Client) Subscribe( - ctx context.Context, - subscriber types.Client, - documentID types.ID, -) (*sync.Subscription, []types.Client, error) { - sub, err := c.localPubSub.Subscribe(ctx, subscriber, documentID) - if err != nil { - return nil, nil, err - } - - // TODO(hackerwins): If the server is not stopped gracefully, there may - // be garbage subscriptions left. Consider introducing a TTL and - // updating it periodically. - if err := c.putSubscriptions(ctx, documentID, sub); err != nil { - return nil, nil, err - } - - peers, err := c.pullSubscriptions(ctx, documentID) - if err != nil { - return nil, nil, err - } - return sub, peers, nil -} - -// Unsubscribe unsubscribes the given keys. -func (c *Client) Unsubscribe( - ctx context.Context, - documentID types.ID, - sub *sync.Subscription, -) error { - c.localPubSub.Unsubscribe(ctx, documentID, sub) - return c.removeSubscriptions(ctx, documentID, sub) -} - -// Publish publishes the given event. -func (c *Client) Publish( - ctx context.Context, - publisherID *time.ActorID, - event sync.DocEvent, -) { - c.localPubSub.Publish(ctx, publisherID, event) - c.broadcastToMembers(ctx, event) -} - -// PublishToLocal publishes the given event. -func (c *Client) PublishToLocal( - ctx context.Context, - publisherID *time.ActorID, - event sync.DocEvent, -) { - c.localPubSub.Publish(ctx, publisherID, event) -} - -// UpdatePresence updates the presence of the given client. -func (c *Client) UpdatePresence( - ctx context.Context, - publisher *types.Client, - documentID types.ID, -) error { - if sub := c.localPubSub.UpdatePresence(publisher, documentID); sub != nil { - if err := c.putSubscriptions(ctx, documentID, sub); err != nil { - return err - } - } - - return nil -} - -// broadcastToMembers broadcasts the given event to all members. -func (c *Client) broadcastToMembers(ctx context.Context, event sync.DocEvent) { - for _, member := range c.Members() { - memberAddr := member.ClusterAddr - if memberAddr == c.serverInfo.ClusterAddr { - continue - } - - clientInfo, err := c.ensureClusterClient(member) - if err != nil { - continue - } - - if err := c.publishToMember( - ctx, - clientInfo, - event.Publisher.ID, - event, - ); err != nil { - continue - } - } -} - -// ensureClusterClient return the cluster client from the cache or creates it. -func (c *Client) ensureClusterClient( - member *sync.ServerInfo, -) (*clusterClientInfo, error) { - c.clusterClientMapMu.Lock() - defer c.clusterClientMapMu.Unlock() - - // TODO(hackerwins): If the connection is disconnected, the client should - // be removed from clusterClientMap. - - if _, ok := c.clusterClientMap[member.ID]; !ok { - conn, err := grpc.Dial(member.ClusterAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) - if err != nil { - return nil, fmt.Errorf("dial to %s: %w", member.ClusterAddr, err) - } - - c.clusterClientMap[member.ID] = &clusterClientInfo{ - client: api.NewClusterServiceClient(conn), - conn: conn, - } - } - - return c.clusterClientMap[member.ID], nil -} - -// removeClusterClient removes the cluster client of the given ID. -func (c *Client) removeClusterClient(id string) { - c.clusterClientMapMu.Lock() - defer c.clusterClientMapMu.Unlock() - - if info, ok := c.clusterClientMap[id]; ok { - if err := info.conn.Close(); err != nil { - logging.DefaultLogger().Error(err) - } - - delete(c.clusterClientMap, id) - } -} - -// publishToMember publishes events to other servers. -func (c *Client) publishToMember( - ctx context.Context, - clientInfo *clusterClientInfo, - publisherID *time.ActorID, - event sync.DocEvent, -) error { - docEvent, err := converter.ToDocEvent(event) - if err != nil { - logging.From(ctx).Error(err) - return err - } - - if _, err := clientInfo.client.BroadcastEvent(ctx, &api.BroadcastEventRequest{ - PublisherId: publisherID.Bytes(), - Event: docEvent, - }); err != nil { - logging.From(ctx).Error(err) - return err - } - - return nil -} - -// putSubscriptions puts the given subscriptions in etcd. -func (c *Client) putSubscriptions( - ctx context.Context, - id types.ID, - sub *sync.Subscription, -) error { - cli := sub.Subscriber() - encoded, err := cli.Marshal() - if err != nil { - return fmt.Errorf("marshal %s: %w", sub.ID(), err) - } - - k := path.Join(subscriptionsPath, id.String(), sub.ID()) - if _, err = c.client.Put(ctx, k, encoded); err != nil { - logging.From(ctx).Error(err) - return fmt.Errorf("put %s: %w", k, err) - } - - return nil -} - -// pullSubscriptions pulls the subscriptions of the given document key. -func (c *Client) pullSubscriptions( - ctx context.Context, - k types.ID, -) ([]types.Client, error) { - getResponse, err := c.client.Get( - ctx, - path.Join(subscriptionsPath, k.String()), - clientv3.WithPrefix(), - ) - if err != nil { - logging.From(ctx).Error(err) - return nil, fmt.Errorf("get %s: %w", k, err) - } - - var clients []types.Client - for _, kv := range getResponse.Kvs { - cli, err := types.NewClient(kv.Value) - if err != nil { - return nil, err - } - clients = append(clients, *cli) - } - - return clients, nil -} - -// removeSubscriptions removes the given subscription in etcd. -func (c *Client) removeSubscriptions( - ctx context.Context, - id types.ID, - sub *sync.Subscription, -) error { - k := path.Join(subscriptionsPath, id.String(), sub.ID()) - if _, err := c.client.Delete(ctx, k); err != nil { - logging.From(ctx).Error(err) - return fmt.Errorf("delete %s: %w", k, err) - } - - return nil -} diff --git a/server/config.go b/server/config.go index 87d4364ae..bcbf41a9b 100644 --- a/server/config.go +++ b/server/config.go @@ -28,7 +28,6 @@ import ( "github.com/yorkie-team/yorkie/server/backend" "github.com/yorkie-team/yorkie/server/backend/database/mongo" "github.com/yorkie-team/yorkie/server/backend/housekeeping" - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" "github.com/yorkie-team/yorkie/server/profiling" "github.com/yorkie-team/yorkie/server/rpc" ) @@ -77,7 +76,6 @@ type Config struct { Housekeeping *housekeeping.Config `yaml:"Housekeeping"` Backend *backend.Config `yaml:"Backend"` Mongo *mongo.Config `yaml:"Mongo"` - ETCD *etcd.Config `yaml:"ETCD"` } // NewConfig returns a Config struct that contains reasonable defaults @@ -140,9 +138,6 @@ func (c *Config) Validate() error { } } - if c.ETCD != nil { - return c.ETCD.Validate() - } return nil } @@ -230,16 +225,6 @@ func (c *Config) ensureDefaultValue() { c.Mongo.PingTimeout = DefaultMongoPingTimeout.String() } } - - if c.ETCD != nil { - if c.ETCD.DialTimeout == "" { - c.ETCD.DialTimeout = etcd.DefaultDialTimeout.String() - } - - if c.ETCD.LockLeaseTime == "" { - c.ETCD.LockLeaseTime = etcd.DefaultLockLeaseTime.String() - } - } } func newConfig(port int, profilingPort int) *Config { diff --git a/server/config.sample.yml b/server/config.sample.yml index c69231205..0561712f4 100644 --- a/server/config.sample.yml +++ b/server/config.sample.yml @@ -88,20 +88,3 @@ Mongo: # PingTimeout is the timeout for pinging MongoDB. PingTimeout: "5s" - -# ETCD is the configuration for the etcd client (Optional). -ETCD: - # Endpoints is the list of endpoints to connect to for etcd. - Endpoints: [ "localhost:2379" ] - - # DialTimeout is the timeout for connecting to etcd. - DialTimeout: "5s" - - # Username is the username to use for etcd. - Username: "" - - # Password is the password to use for etcd. - Password: "" - - # LockLeaseTime is the lease time for locks. - LockLeaseTime: "30s" diff --git a/server/config_test.go b/server/config_test.go index d01e20c15..eb0cb9661 100644 --- a/server/config_test.go +++ b/server/config_test.go @@ -24,7 +24,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/yorkie-team/yorkie/server" - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" ) func TestNewConfigFromFile(t *testing.T) { @@ -39,8 +38,6 @@ func TestNewConfigFromFile(t *testing.T) { assert.Equal(t, conf.Backend.SnapshotThreshold, int64(server.DefaultSnapshotThreshold)) assert.Equal(t, conf.Backend.SnapshotInterval, int64(server.DefaultSnapshotInterval)) - - assert.Nil(t, conf.ETCD) }) t.Run("read config file test", func(t *testing.T) { @@ -80,14 +77,5 @@ func TestNewConfigFromFile(t *testing.T) { authWebhookCacheUnauthTTL, err := time.ParseDuration(conf.Backend.AuthWebhookCacheUnauthTTL) assert.NoError(t, err) assert.Equal(t, authWebhookCacheUnauthTTL, server.DefaultAuthWebhookCacheUnauthTTL) - - assert.NotNil(t, conf.ETCD) - etcdDialTimeout, err := time.ParseDuration(conf.ETCD.DialTimeout) - assert.NoError(t, err) - assert.Equal(t, etcdDialTimeout, etcd.DefaultDialTimeout) - - lockLeaseTime, err := time.ParseDuration(conf.ETCD.LockLeaseTime) - assert.NoError(t, err) - assert.Equal(t, lockLeaseTime, etcd.DefaultLockLeaseTime) }) } diff --git a/server/rpc/interceptors/context.go b/server/rpc/interceptors/context.go index e88d95edf..5e8deb333 100644 --- a/server/rpc/interceptors/context.go +++ b/server/rpc/interceptors/context.go @@ -19,7 +19,6 @@ package interceptors import ( "context" - "strings" grpcmiddleware "github.com/grpc-ecosystem/go-grpc-middleware" "google.golang.org/grpc" @@ -54,12 +53,6 @@ func (i *ContextInterceptor) Unary() grpc.UnaryServerInterceptor { info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (resp interface{}, err error) { - // TODO(hackerwins): We need to remove this condition after - // extracting cluster service from this server. - if !isRPCService(info.FullMethod) { - return handler(ctx, req) - } - ctx, err = i.buildContext(ctx) if err != nil { return nil, err @@ -91,12 +84,6 @@ func (i *ContextInterceptor) Stream() grpc.StreamServerInterceptor { info *grpc.StreamServerInfo, handler grpc.StreamHandler, ) error { - // TODO(hackerwins): We need to remove this condition after - // extracting cluster service from this server. - if !isRPCService(info.FullMethod) { - return handler(srv, ss) - } - ctx := ss.Context() ctx, err := i.buildContext(ctx) if err != nil { @@ -123,10 +110,6 @@ func (i *ContextInterceptor) Stream() grpc.StreamServerInterceptor { } } -func isRPCService(method string) bool { - return strings.HasPrefix(method, "/yorkie.v1.YorkieService/") -} - // buildContext builds a context data for RPC. It includes the metadata of the // request and the project information. func (i *ContextInterceptor) buildContext(ctx context.Context) (context.Context, error) { diff --git a/server/rpc/server_test.go b/server/rpc/server_test.go index 828341756..7b4d9e043 100644 --- a/server/rpc/server_test.go +++ b/server/rpc/server_test.go @@ -36,7 +36,6 @@ import ( "github.com/yorkie-team/yorkie/server/backend/database" "github.com/yorkie-team/yorkie/server/backend/database/mongo" "github.com/yorkie-team/yorkie/server/backend/housekeeping" - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" "github.com/yorkie-team/yorkie/server/profiling/prometheus" "github.com/yorkie-team/yorkie/server/rpc" "github.com/yorkie-team/yorkie/test/helper" @@ -49,7 +48,6 @@ var ( testRPCServer *rpc.Server testRPCAddr = fmt.Sprintf("localhost:%d", helper.RPCPort) - testAdminAddr = fmt.Sprintf("localhost:%d", helper.AdminPort) testClient api.YorkieServiceClient invalidChangePack = &api.ChangePack{ @@ -75,14 +73,10 @@ func TestMain(m *testing.M) { YorkieDatabase: helper.TestDBName(), ConnectionTimeout: helper.MongoConnectionTimeout, PingTimeout: helper.MongoPingTimeout, - }, &etcd.Config{ - Endpoints: helper.ETCDEndpoints, - DialTimeout: helper.ETCDDialTimeout.String(), - LockLeaseTime: helper.ETCDLockLeaseTime.String(), }, &housekeeping.Config{ Interval: helper.HousekeepingInterval.String(), CandidatesLimitPerProject: helper.HousekeepingCandidatesLimitPerProject, - }, testAdminAddr, met) + }, met) if err != nil { log.Fatal(err) } @@ -171,7 +165,7 @@ func TestRPCServerBackend(t *testing.T) { assert.NoError(t, err) packWithNoChanges := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, } @@ -292,12 +286,12 @@ func TestRPCServerBackend(t *testing.T) { assert.NoError(t, err) packWithNoChanges := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, } packWithRemoveRequest := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, IsRemoved: true, } @@ -356,13 +350,13 @@ func TestRPCServerBackend(t *testing.T) { t.Run("push/pull changes test", func(t *testing.T) { packWithNoChanges := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, } activateResp, err := testClient.ActivateClient( context.Background(), - &api.ActivateClientRequest{ClientKey: helper.TestDocKey(t)}, + &api.ActivateClientRequest{ClientKey: helper.TestDocKey(t).String()}, ) assert.NoError(t, err) @@ -371,7 +365,7 @@ func TestRPCServerBackend(t *testing.T) { &api.AttachDocumentRequest{ ClientId: activateResp.ClientId, ChangePack: &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 1}, Changes: []*api.Change{{ Id: &api.ChangeID{ @@ -391,7 +385,7 @@ func TestRPCServerBackend(t *testing.T) { ClientId: activateResp.ClientId, DocumentId: resPack.DocumentId, ChangePack: &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 2}, Changes: []*api.Change{{ Id: &api.ChangeID{ @@ -411,7 +405,7 @@ func TestRPCServerBackend(t *testing.T) { ClientId: activateResp.ClientId, DocumentId: resPack.DocumentId, ChangePack: &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 3}, Changes: []*api.Change{{ Id: &api.ChangeID{ @@ -467,19 +461,19 @@ func TestRPCServerBackend(t *testing.T) { t.Run("push/pull on removed document test", func(t *testing.T) { packWithNoChanges := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, } packWithRemoveRequest := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, IsRemoved: true, } activateResp, err := testClient.ActivateClient( context.Background(), - &api.ActivateClientRequest{ClientKey: helper.TestDocKey(t)}, + &api.ActivateClientRequest{ClientKey: helper.TestDocKey(t).String()}, ) assert.NoError(t, err) @@ -522,12 +516,12 @@ func TestRPCServerBackend(t *testing.T) { assert.NoError(t, err) packWithNoChanges := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, } packWithRemoveRequest := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, IsRemoved: true, } @@ -571,12 +565,12 @@ func TestRPCServerBackend(t *testing.T) { assert.NoError(t, err) packWithNoChanges := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, } packWithRemoveRequest := &api.ChangePack{ - DocumentKey: helper.TestDocKey(t), + DocumentKey: helper.TestDocKey(t).String(), Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, IsRemoved: true, } diff --git a/server/server.go b/server/server.go index 1e58bfa3f..843f9811f 100644 --- a/server/server.go +++ b/server/server.go @@ -60,9 +60,7 @@ func New(conf *Config) (*Yorkie, error) { be, err := backend.New( conf.Backend, conf.Mongo, - conf.ETCD, conf.Housekeeping, - conf.AdminAddr(), metrics, ) if err != nil { diff --git a/test/bench/sync_bench_test.go b/test/bench/sync_bench_test.go index ab24fbda7..8de5c3eb9 100644 --- a/test/bench/sync_bench_test.go +++ b/test/bench/sync_bench_test.go @@ -23,29 +23,13 @@ import ( gosync "sync" "testing" - "github.com/rs/xid" "github.com/stretchr/testify/assert" "github.com/yorkie-team/yorkie/server/backend/sync" - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" "github.com/yorkie-team/yorkie/server/backend/sync/memory" - "github.com/yorkie-team/yorkie/test/helper" ) func BenchmarkSync(b *testing.B) { - cli, err := etcd.Dial(&etcd.Config{ - Endpoints: helper.ETCDEndpoints, - DialTimeout: helper.ETCDDialTimeout.String(), - LockLeaseTime: helper.ETCDLockLeaseTime.String(), - }, &sync.ServerInfo{ - ID: xid.New().String(), - }) - assert.NoError(b, err) - defer func() { - err := cli.Close() - assert.NoError(b, err) - }() - b.Run("memory sync 10 test", func(b *testing.B) { benchmarkMemorySync(10, b) }) @@ -61,10 +45,6 @@ func BenchmarkSync(b *testing.B) { b.Run("memory sync 10000 test", func(b *testing.B) { benchmarkMemorySync(10000, b) }) - - b.Run("etcd sync 100 test", func(t *testing.B) { - benchmarkETCDSync(100, b, cli) - }) } func benchmarkMemorySync(cnt int, b *testing.B) { @@ -90,25 +70,3 @@ func benchmarkMemorySync(cnt int, b *testing.B) { assert.Equal(b, cnt, sum) } } - -func benchmarkETCDSync(cnt int, b *testing.B, cli *etcd.Client) { - for i := 0; i < b.N; i++ { - sum := 0 - var wg gosync.WaitGroup - for i := 0; i < cnt; i++ { - wg.Add(1) - go func() { - defer wg.Done() - - ctx := context.Background() - locker, err := cli.NewLocker(ctx, sync.Key(b.Name())) - assert.NoError(b, err) - assert.NoError(b, locker.Lock(ctx)) - sum += 1 - assert.NoError(b, locker.Unlock(ctx)) - }() - } - wg.Wait() - assert.Equal(b, cnt, sum) - } -} diff --git a/test/helper/helper.go b/test/helper/helper.go index 6a34a2484..8e8b4fe8b 100644 --- a/test/helper/helper.go +++ b/test/helper/helper.go @@ -37,7 +37,6 @@ import ( "github.com/yorkie-team/yorkie/server/backend" "github.com/yorkie-team/yorkie/server/backend/database/mongo" "github.com/yorkie-team/yorkie/server/backend/housekeeping" - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" "github.com/yorkie-team/yorkie/server/profiling" "github.com/yorkie-team/yorkie/server/rpc" ) @@ -69,10 +68,6 @@ var ( MongoConnectionURI = "mongodb://localhost:27017" MongoConnectionTimeout = "5s" MongoPingTimeout = "5s" - - ETCDEndpoints = []string{"localhost:2379"} - ETCDDialTimeout = 5 * gotime.Second - ETCDLockLeaseTime = 30 * gotime.Second ) func init() { @@ -151,11 +146,6 @@ func TestConfig() *server.Config { PingTimeout: MongoPingTimeout, YorkieDatabase: TestDBName(), }, - ETCD: &etcd.Config{ - Endpoints: ETCDEndpoints, - DialTimeout: ETCDDialTimeout.String(), - LockLeaseTime: ETCDLockLeaseTime.String(), - }, } } @@ -169,10 +159,10 @@ func TestServer() *server.Yorkie { } // TestDocKey returns a new instance of document key for testing. -func TestDocKey(t testing.TB) string { +func TestDocKey(t testing.TB) key.Key { name := t.Name() if err := key.Key(name).Validate(); err == nil { - return name + return key.Key(name) } if len(name) > 60 { @@ -192,7 +182,7 @@ func TestDocKey(t testing.TB) string { } } - return sb.String() + return key.Key(sb.String()) } // NewRangeSlice returns a slice of integers from start to end. diff --git a/test/integration/agent_test.go b/test/integration/agent_test.go index fe56611c2..5b0138451 100644 --- a/test/integration/agent_test.go +++ b/test/integration/agent_test.go @@ -30,7 +30,6 @@ import ( "github.com/yorkie-team/yorkie/client" "github.com/yorkie-team/yorkie/pkg/document" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/test/helper" ) @@ -44,7 +43,7 @@ func TestServer(t *testing.T) { assert.NoError(t, err) assert.NoError(t, cli.Activate(ctx)) - doc := document.New(key.Key(helper.TestDocKey(t))) + doc := document.New(helper.TestDocKey(t)) assert.NoError(t, cli.Attach(ctx, doc)) wg := sync.WaitGroup{} diff --git a/test/integration/array_test.go b/test/integration/array_test.go index 54a2bbfe2..5d8568ae0 100644 --- a/test/integration/array_test.go +++ b/test/integration/array_test.go @@ -26,18 +26,17 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/test/helper" ) func TestArray(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("causal nested array test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -49,7 +48,7 @@ func TestArray(t *testing.T) { }, "nested update by c1") assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -58,7 +57,7 @@ func TestArray(t *testing.T) { t.Run("concurrent array add/delete simple test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -71,7 +70,7 @@ func TestArray(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -92,7 +91,7 @@ func TestArray(t *testing.T) { t.Run("concurrent array add/delete test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -104,7 +103,7 @@ func TestArray(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -126,7 +125,7 @@ func TestArray(t *testing.T) { t.Run("concurrent array delete test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -138,7 +137,7 @@ func TestArray(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -165,7 +164,7 @@ func TestArray(t *testing.T) { t.Run("concurrent array move test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -178,7 +177,7 @@ func TestArray(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -205,7 +204,7 @@ func TestArray(t *testing.T) { t.Run("concurrent array move with the same position test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) assert.NoError(t, c1.Attach(ctx, d1)) assert.NoError(t, d1.Update(func(root *json.Object) error { root.SetNewArray("k1").AddInteger(0, 1, 2) @@ -213,7 +212,7 @@ func TestArray(t *testing.T) { return nil })) assert.NoError(t, c1.Sync(ctx)) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) assert.NoError(t, c2.Attach(ctx, d2)) assert.NoError(t, d1.Update(func(root *json.Object) error { diff --git a/test/integration/auth_webhook_test.go b/test/integration/auth_webhook_test.go index 044964ef4..4e4c51c28 100644 --- a/test/integration/auth_webhook_test.go +++ b/test/integration/auth_webhook_test.go @@ -34,7 +34,6 @@ import ( "github.com/yorkie-team/yorkie/client" "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/server" "github.com/yorkie-team/yorkie/test/helper" ) @@ -116,7 +115,7 @@ func TestProjectAuthWebhook(t *testing.T) { assert.NoError(t, cli.Activate(ctx)) defer func() { assert.NoError(t, cli.Deactivate(ctx)) }() - doc := document.New(key.Key(helper.TestDocKey(t))) + doc := document.New(helper.TestDocKey(t)) assert.NoError(t, cli.Attach(ctx, doc)) // client without token @@ -172,7 +171,7 @@ func TestProjectAuthWebhook(t *testing.T) { err = cli.Activate(ctx) assert.NoError(t, err) - doc := document.New(key.Key(helper.TestDocKey(t))) + doc := document.New(helper.TestDocKey(t)) err = cli.Attach(ctx, doc) assert.Equal(t, codes.Unauthenticated, status.Convert(err).Code()) @@ -222,7 +221,7 @@ func TestAuthWebhook(t *testing.T) { err = cli.Activate(ctx) assert.NoError(t, err) - doc := document.New(key.Key(helper.TestDocKey(t))) + doc := document.New(helper.TestDocKey(t)) err = cli.Attach(ctx, doc) assert.NoError(t, err) }) @@ -317,7 +316,7 @@ func TestAuthWebhook(t *testing.T) { err = cli.Activate(ctx) assert.NoError(t, err) - doc := document.New(key.Key(helper.TestDocKey(t))) + doc := document.New(helper.TestDocKey(t)) err = cli.Attach(ctx, doc) assert.NoError(t, err) diff --git a/test/integration/cluster_mode_test.go b/test/integration/cluster_mode_test.go deleted file mode 100644 index b65f7d467..000000000 --- a/test/integration/cluster_mode_test.go +++ /dev/null @@ -1,205 +0,0 @@ -//go:build integration - -/* - * Copyright 2021 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 integration - -import ( - "context" - "io" - "sort" - gosync "sync" - "testing" - "time" - - "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/json" - "github.com/yorkie-team/yorkie/pkg/document/key" - "github.com/yorkie-team/yorkie/server/backend/sync" - "github.com/yorkie-team/yorkie/test/helper" -) - -func keysFromServers(m map[string]*sync.ServerInfo) []string { - keys := make([]string, 0, len(m)) - for k := range m { - keys = append(keys, k) - } - - sort.Strings(keys) - - return keys -} - -func withTwoClientsAndDocsInClusterMode( - t *testing.T, - fn func(t *testing.T, c1, c2 *client.Client, d1, d2 *document.Document), -) { - ctx := context.Background() - - // creates two servers - svr1 := helper.TestServer() - svr2 := helper.TestServer() - assert.NoError(t, svr1.Start()) - assert.NoError(t, svr2.Start()) - defer func() { - assert.NoError(t, svr1.Shutdown(true)) - assert.NoError(t, svr2.Shutdown(true)) - }() - - // creates two clients, each connecting to the two servers - client1, err := client.Dial( - svr1.RPCAddr(), - client.WithPresence(types.Presence{"name": "client1"}), - ) - assert.NoError(t, err) - client2, err := client.Dial( - svr2.RPCAddr(), - client.WithPresence(types.Presence{"name": "client2"}), - ) - assert.NoError(t, err) - assert.NoError(t, client1.Activate(ctx)) - assert.NoError(t, client2.Activate(ctx)) - defer func() { - assert.NoError(t, client1.Close()) - assert.NoError(t, client2.Close()) - }() - - doc1 := document.New(key.Key(helper.TestDocKey(t))) - doc2 := document.New(key.Key(helper.TestDocKey(t))) - - assert.NoError(t, client1.Attach(ctx, doc1)) - assert.NoError(t, client2.Attach(ctx, doc2)) - defer func() { assert.NoError(t, client1.Detach(ctx, doc1)) }() - defer func() { assert.NoError(t, client2.Detach(ctx, doc2)) }() - - fn(t, client1, client2, doc1, doc2) -} - -func TestClusterMode(t *testing.T) { - t.Run("member list test", func(t *testing.T) { - svrA := helper.TestServer() - svrB := helper.TestServer() - - assert.NoError(t, svrA.Start()) - assert.NoError(t, svrB.Start()) - time.Sleep(100 * time.Millisecond) - assert.Equal(t, keysFromServers(svrA.Members()), keysFromServers(svrB.Members())) - assert.Len(t, defaultServer.Members(), 3) - - assert.NoError(t, svrA.Shutdown(true)) - time.Sleep(100 * time.Millisecond) - assert.Len(t, defaultServer.Members(), 2) - - assert.NoError(t, svrB.Shutdown(true)) - time.Sleep(100 * time.Millisecond) - assert.Len(t, defaultServer.Members(), 1) - }) - - t.Run("watch document across servers test", func(t *testing.T) { - withTwoClientsAndDocsInClusterMode(t, func( - t *testing.T, - c1, c2 *client.Client, - d1, d2 *document.Document, - ) { - ctx := context.Background() - - var expected []watchResponsePair - var responsePairs []watchResponsePair - - wg := gosync.WaitGroup{} - wg.Add(1) - - // starting to watch a document - watch1Ctx, cancel1 := context.WithCancel(ctx) - defer cancel1() - wrch, err := c1.Watch(watch1Ctx, d1) - assert.NoError(t, err) - go func() { - defer wg.Done() - - for { - select { - case wr := <-wrch: - if wr.Err == io.EOF { - return - } - assert.NoError(t, wr.Err) - - if wr.Type == client.PeersChanged { - peers := wr.PeersMapByDoc[d1.Key()] - responsePairs = append(responsePairs, watchResponsePair{ - Type: wr.Type, - Peers: peers, - }) - } else if wr.Type == client.DocumentsChanged { - assert.NoError(t, c1.Sync(ctx, wr.Key)) - } - case <-time.After(time.Second): - return - } - } - }() - - // 01. PeersChanged is triggered when another client watches the document - expected = append(expected, watchResponsePair{ - Type: client.PeersChanged, - Peers: map[string]types.Presence{ - c1.ID().String(): c1.Presence(), - c2.ID().String(): c2.Presence(), - }, - }) - - watch2Ctx, cancel2 := context.WithCancel(ctx) - _, err = c2.Watch(watch2Ctx, d2) - assert.NoError(t, err) - - // 02. PeersChanged is triggered when another client updates its presence - assert.NoError(t, c2.UpdatePresence(ctx, "updated", "true")) - expected = append(expected, watchResponsePair{ - Type: client.PeersChanged, - Peers: map[string]types.Presence{ - c1.ID().String(): c1.Presence(), - c2.ID().String(): c2.Presence(), - }, - }) - - // 03. PeersChanged is triggered when another client closes the watch - expected = append(expected, watchResponsePair{ - Type: client.PeersChanged, - Peers: map[string]types.Presence{ - c1.ID().String(): c1.Presence(), - }, - }) - cancel2() - - assert.NoError(t, d2.Update(func(root *json.Object) error { - root.SetString("hello", "world") - return nil - })) - assert.NoError(t, c2.Sync(ctx)) - - wg.Wait() - - assert.Equal(t, d1.Marshal(), d2.Marshal()) - assert.Equal(t, expected, responsePairs) - }) - }) -} diff --git a/test/integration/counter_test.go b/test/integration/counter_test.go index 4ad2650d4..06c601581 100644 --- a/test/integration/counter_test.go +++ b/test/integration/counter_test.go @@ -28,18 +28,17 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/crdt" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/test/helper" ) func TestCounter(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("causal counter.increase test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -54,7 +53,7 @@ func TestCounter(t *testing.T) { }, "nested update by c1") assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -63,7 +62,7 @@ func TestCounter(t *testing.T) { t.Run("concurrent counter increase test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -77,7 +76,7 @@ func TestCounter(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) diff --git a/test/integration/document_test.go b/test/integration/document_test.go index 208423c8e..36efa2ca4 100644 --- a/test/integration/document_test.go +++ b/test/integration/document_test.go @@ -37,11 +37,11 @@ import ( func TestDocument(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("attach/detach test", func(t *testing.T) { ctx := context.Background() - doc := document.New(key.Key(helper.TestDocKey(t))) + doc := document.New(helper.TestDocKey(t)) err := doc.Update(func(root *json.Object) error { root.SetString("k1", "v1") return nil @@ -56,7 +56,7 @@ func TestDocument(t *testing.T) { assert.NoError(t, err) assert.False(t, doc.IsAttached()) - doc2 := document.New(key.Key(helper.TestDocKey(t))) + doc2 := document.New(helper.TestDocKey(t)) err = doc2.Update(func(root *json.Object) error { root.SetString("k1", "v2") return nil @@ -74,11 +74,11 @@ func TestDocument(t *testing.T) { t.Run("concurrent complex test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -112,11 +112,11 @@ func TestDocument(t *testing.T) { t.Run("watch document changed event test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -163,7 +163,7 @@ func TestDocument(t *testing.T) { t.Run("document tombstone test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := d1.Update(func(root *json.Object) error { root.SetNewArray("k1").AddInteger(1, 2) return nil @@ -173,7 +173,7 @@ func TestDocument(t *testing.T) { err = c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -206,7 +206,7 @@ func TestDocument(t *testing.T) { defer func() { assert.NoError(t, cli.Close()) }() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) // 01. client is not activated. assert.ErrorIs(t, cli.Remove(ctx, d1), client.ErrClientNotActivated) @@ -234,7 +234,7 @@ func TestDocument(t *testing.T) { ctx := context.Background() // 01. cli1 creates d1 and removes it. - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := d1.Update(func(root *json.Object) error { root.SetString("k1", "v1") return nil @@ -244,11 +244,11 @@ func TestDocument(t *testing.T) { assert.NoError(t, c1.Remove(ctx, d1)) // 02. cli2 creates d2 with the same key. - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) assert.NoError(t, c2.Attach(ctx, d2)) // 03. cli1 creates d3 with the same key. - d3 := document.New(key.Key(helper.TestDocKey(t))) + d3 := document.New(helper.TestDocKey(t)) assert.NoError(t, c1.Attach(ctx, d3)) syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d3}, {c2, d2}}) }) @@ -257,7 +257,7 @@ func TestDocument(t *testing.T) { ctx := context.Background() // 01. cli1 creates d1 and cli2 syncs. - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := d1.Update(func(root *json.Object) error { root.SetString("k1", "v1") return nil @@ -265,7 +265,7 @@ func TestDocument(t *testing.T) { assert.NoError(t, err) assert.NoError(t, c1.Attach(ctx, d1)) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) assert.NoError(t, c2.Attach(ctx, d2)) syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}}) @@ -288,14 +288,14 @@ func TestDocument(t *testing.T) { ctx := context.Background() // 01. cli1 creates d1 and cli2 syncs. - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := d1.Update(func(root *json.Object) error { root.SetString("k1", "v1") return nil }) assert.NoError(t, err) assert.NoError(t, c1.Attach(ctx, d1)) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) assert.NoError(t, c2.Attach(ctx, d2)) syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}}) @@ -310,14 +310,14 @@ func TestDocument(t *testing.T) { ctx := context.Background() // 01. cli1 creates d1 and cli2 syncs. - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := d1.Update(func(root *json.Object) error { root.SetString("k1", "v1") return nil }) assert.NoError(t, err) assert.NoError(t, c1.Attach(ctx, d1)) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) assert.NoError(t, c2.Attach(ctx, d2)) syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}}) @@ -345,7 +345,7 @@ func TestDocument(t *testing.T) { }() // 01. abnormal behavior on detached state - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) assert.ErrorIs(t, cli.Detach(ctx, d1), client.ErrDocumentNotAttached) assert.ErrorIs(t, cli.Sync(ctx, d1.Key()), client.ErrDocumentNotAttached) assert.ErrorIs(t, cli.Remove(ctx, d1), client.ErrDocumentNotAttached) @@ -367,7 +367,7 @@ func TestDocument(t *testing.T) { defer cancel() // 01. c1 creates d1 without attaching. - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) _, err := c1.Watch(watchCtx, d1) assert.ErrorIs(t, err, client.ErrDocumentNotAttached) @@ -423,7 +423,7 @@ func TestDocumentWithProjects(t *testing.T) { wg := sync.WaitGroup{} wg.Add(1) - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err = c1.Attach(ctx, d1) assert.NoError(t, err) watch1Ctx, cancel1 := context.WithCancel(ctx) @@ -469,7 +469,7 @@ func TestDocumentWithProjects(t *testing.T) { c2.ID().String(): nil, }, }) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) assert.NoError(t, c2.Attach(ctx, d2)) watch2Ctx, cancel2 := context.WithCancel(ctx) defer cancel2() @@ -486,7 +486,7 @@ func TestDocumentWithProjects(t *testing.T) { })) // d3 is in another project, so c1 and c2 should not receive events. - d3 := document.New(key.Key(helper.TestDocKey(t))) + d3 := document.New(helper.TestDocKey(t)) assert.NoError(t, c3.Attach(ctx, d3)) watch3Ctx, cancel3 := context.WithCancel(ctx) defer cancel3() diff --git a/test/integration/etcd_test.go b/test/integration/etcd_test.go deleted file mode 100644 index e27eae3a6..000000000 --- a/test/integration/etcd_test.go +++ /dev/null @@ -1,48 +0,0 @@ -//go:build integration - -/* - * Copyright 2021 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 integration - -import ( - "testing" - - "github.com/rs/xid" - "github.com/stretchr/testify/assert" - - "github.com/yorkie-team/yorkie/server/backend/sync" - "github.com/yorkie-team/yorkie/server/backend/sync/etcd" - "github.com/yorkie-team/yorkie/test/helper" -) - -func TestETCD(t *testing.T) { - t.Run("new and close test", func(t *testing.T) { - cli, err := etcd.Dial(&etcd.Config{ - Endpoints: helper.ETCDEndpoints, - DialTimeout: helper.ETCDDialTimeout.String(), - LockLeaseTime: helper.ETCDLockLeaseTime.String(), - }, &sync.ServerInfo{ - ID: xid.New().String(), - }) - assert.NoError(t, err) - - defer func() { - err := cli.Close() - assert.NoError(t, err) - }() - }) -} diff --git a/test/integration/gc_test.go b/test/integration/gc_test.go index 2cc2ccf76..4d39b1487 100644 --- a/test/integration/gc_test.go +++ b/test/integration/gc_test.go @@ -26,22 +26,21 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/test/helper" ) func TestGarbageCollection(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("garbage collection for container type test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -104,11 +103,11 @@ func TestGarbageCollection(t *testing.T) { t.Run("garbage collection for text type test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -176,11 +175,11 @@ func TestGarbageCollection(t *testing.T) { t.Run("garbage collection with detached document test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) diff --git a/test/integration/history_test.go b/test/integration/history_test.go index e6236bdbe..a2fb27ccb 100644 --- a/test/integration/history_test.go +++ b/test/integration/history_test.go @@ -26,21 +26,20 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/test/helper" ) func TestHistory(t *testing.T) { clients := activeClients(t, 1) cli := clients[0] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) adminCli := helper.CreateAdminCli(t, defaultServer.AdminAddr()) defer func() { assert.NoError(t, adminCli.Close()) }() t.Run("history test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) assert.NoError(t, cli.Attach(ctx, d1)) defer func() { assert.NoError(t, cli.Detach(ctx, d1)) }() diff --git a/test/integration/main_test.go b/test/integration/main_test.go index 63277ed84..e217e6e7d 100644 --- a/test/integration/main_test.go +++ b/test/integration/main_test.go @@ -103,7 +103,7 @@ func clientConn() (*grpc.ClientConn, error) { return conn, nil } -// activeClient is a helper function to create active clients. +// activeClients creates and activates the given number of clients. func activeClients(t *testing.T, n int) (clients []*client.Client) { for i := 0; i < n; i++ { c, err := client.Dial( @@ -111,17 +111,15 @@ func activeClients(t *testing.T, n int) (clients []*client.Client) { client.WithPresence(types.Presence{"name": fmt.Sprintf("name-%d", i)}), ) assert.NoError(t, err) - - err = c.Activate(context.Background()) - assert.NoError(t, err) + assert.NoError(t, c.Activate(context.Background())) clients = append(clients, c) } return } -// cleanupClients is a helper function to clean up clients. -func cleanupClients(t *testing.T, clients []*client.Client) { +// deactivateAndCloseClients deactivates and closes the given clients. +func deactivateAndCloseClients(t *testing.T, clients []*client.Client) { for _, c := range clients { assert.NoError(t, c.Deactivate(context.Background())) assert.NoError(t, c.Close()) diff --git a/test/integration/object_test.go b/test/integration/object_test.go index 0d8225fda..33a158c3c 100644 --- a/test/integration/object_test.go +++ b/test/integration/object_test.go @@ -26,23 +26,22 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/test/helper" ) func TestObject(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("causal object.set/delete test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -71,7 +70,7 @@ func TestObject(t *testing.T) { t.Run("concurrent object set/delete simple test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -84,7 +83,7 @@ func TestObject(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -108,11 +107,11 @@ func TestObject(t *testing.T) { t.Run("concurrent object.set test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) diff --git a/test/integration/peer_awareness_test.go b/test/integration/peer_awareness_test.go index 01ea5109f..65cd882da 100644 --- a/test/integration/peer_awareness_test.go +++ b/test/integration/peer_awareness_test.go @@ -36,12 +36,12 @@ import ( func TestPeerAwareness(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("WatchStarted and PeersChanged event test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) + d2 := document.New(helper.TestDocKey(t)) assert.NoError(t, c1.Attach(ctx, d1)) defer func() { assert.NoError(t, c1.Detach(ctx, d1)) }() assert.NoError(t, c2.Attach(ctx, d2)) @@ -126,8 +126,8 @@ func TestPeerAwareness(t *testing.T) { t.Run("Watch multiple documents test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) + d2 := document.New(helper.TestDocKey(t)) d3 := document.New(key.Key(helper.TestDocKey(t) + "2")) assert.NoError(t, c1.Attach(ctx, d1)) defer func() { assert.NoError(t, c1.Detach(ctx, d1)) }() diff --git a/test/integration/primitive_test.go b/test/integration/primitive_test.go index 4020597e2..24f2e8303 100644 --- a/test/integration/primitive_test.go +++ b/test/integration/primitive_test.go @@ -27,18 +27,17 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/test/helper" ) func TestPrimitive(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("causal primitive data test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -65,7 +64,7 @@ func TestPrimitive(t *testing.T) { }, "nested update by c1") assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) diff --git a/test/integration/retention_test.go b/test/integration/retention_test.go index 09022c16c..64efa0048 100644 --- a/test/integration/retention_test.go +++ b/test/integration/retention_test.go @@ -33,7 +33,6 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/change" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/server" "github.com/yorkie-team/yorkie/server/backend/background" "github.com/yorkie-team/yorkie/server/backend/database/mongo" @@ -84,7 +83,7 @@ func TestRetention(t *testing.T) { ctx := context.Background() - doc := document.New(key.Key(helper.TestDocKey(t))) + doc := document.New(helper.TestDocKey(t)) assert.NoError(t, cli.Attach(ctx, doc)) defer func() { assert.NoError(t, cli.Detach(ctx, doc)) }() @@ -146,7 +145,7 @@ func TestRetention(t *testing.T) { }() ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) assert.NoError(t, cli1.Attach(ctx, d1)) defer func() { assert.NoError(t, cli1.Detach(ctx, d1)) }() @@ -221,7 +220,7 @@ func TestRetention(t *testing.T) { assert.NoError(t, cli2.Close()) }() - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) assert.NoError(t, cli2.Attach(ctx, d2)) defer func() { assert.NoError(t, cli2.Detach(ctx, d2)) }() diff --git a/test/integration/snapshot_test.go b/test/integration/snapshot_test.go index 30bc188f8..a4f03ca2b 100644 --- a/test/integration/snapshot_test.go +++ b/test/integration/snapshot_test.go @@ -30,7 +30,6 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/server/backend/background" "github.com/yorkie-team/yorkie/test/helper" ) @@ -51,16 +50,16 @@ func TestSnapshot(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("snapshot test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -92,7 +91,7 @@ func TestSnapshot(t *testing.T) { t.Run("text snapshot test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -126,7 +125,7 @@ func TestSnapshot(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -137,7 +136,7 @@ func TestSnapshot(t *testing.T) { t.Run("text snapshot with concurrent local change test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -149,7 +148,7 @@ func TestSnapshot(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) diff --git a/test/integration/text_test.go b/test/integration/text_test.go index 459df83a0..c7e39dc0a 100644 --- a/test/integration/text_test.go +++ b/test/integration/text_test.go @@ -26,18 +26,17 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/test/helper" ) func TestText(t *testing.T) { clients := activeClients(t, 2) c1, c2 := clients[0], clients[1] - defer cleanupClients(t, clients) + defer deactivateAndCloseClients(t, clients) t.Run("text test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -49,7 +48,7 @@ func TestText(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -98,7 +97,7 @@ func TestText(t *testing.T) { t.Run("rich text test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -110,7 +109,7 @@ func TestText(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -133,7 +132,7 @@ func TestText(t *testing.T) { t.Run("concurrent block deletions test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -145,7 +144,7 @@ func TestText(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err) @@ -179,7 +178,7 @@ func TestText(t *testing.T) { t.Run("new creation then concurrent deletion test", func(t *testing.T) { ctx := context.Background() - d1 := document.New(key.Key(helper.TestDocKey(t))) + d1 := document.New(helper.TestDocKey(t)) err := c1.Attach(ctx, d1) assert.NoError(t, err) @@ -191,7 +190,7 @@ func TestText(t *testing.T) { err = c1.Sync(ctx) assert.NoError(t, err) - d2 := document.New(key.Key(helper.TestDocKey(t))) + d2 := document.New(helper.TestDocKey(t)) err = c2.Attach(ctx, d2) assert.NoError(t, err)