From 31cc753279683bd4b612ad9c804d1a429ec84981 Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Wed, 16 Oct 2024 16:15:26 +0900 Subject: [PATCH 1/8] Detach documents when client is deactivated --- api/docs/yorkie/v1/admin.openapi.yaml | 603 +++++++++++----------- api/docs/yorkie/v1/resources.openapi.yaml | 419 ++++++++------- api/docs/yorkie/v1/system.openapi.yaml | 125 +++++ api/docs/yorkie/v1/yorkie.openapi.yaml | 463 +++++++++-------- api/yorkie/v1/system.pb.go | 256 +++++++++ api/yorkie/v1/system.proto | 38 ++ api/yorkie/v1/v1connect/system.connect.go | 120 +++++ api/yorkie/v1/yorkie.proto | 2 +- pkg/document/document.go | 4 + pkg/document/internal_document.go | 7 + server/backend/database/client_info.go | 11 + server/backend/database/mongo/client.go | 32 +- server/clients/clients.go | 60 ++- server/clients/housekeeping.go | 31 +- server/rpc/server.go | 1 + server/rpc/system_server.go | 137 +++++ server/rpc/yorkie_server.go | 2 +- server/server.go | 2 +- system/client.go | 161 ++++++ 19 files changed, 1664 insertions(+), 810 deletions(-) create mode 100644 api/docs/yorkie/v1/system.openapi.yaml create mode 100644 api/yorkie/v1/system.pb.go create mode 100644 api/yorkie/v1/system.proto create mode 100644 api/yorkie/v1/v1connect/system.connect.go create mode 100644 server/rpc/system_server.go create mode 100644 system/client.go diff --git a/api/docs/yorkie/v1/admin.openapi.yaml b/api/docs/yorkie/v1/admin.openapi.yaml index e3672c9f2..536d71435 100644 --- a/api/docs/yorkie/v1/admin.openapi.yaml +++ b/api/docs/yorkie/v1/admin.openapi.yaml @@ -1,532 +1,531 @@ openapi: 3.1.0 info: - description: - Yorkie is an open source document store for building collaborative + description: Yorkie is an open source document store for building collaborative editing applications. title: Yorkie version: v0.5.1 servers: - - description: Production server - url: https://api.yorkie.dev - - description: Local server - url: http://localhost:8080 +- description: Production server + url: https://api.yorkie.dev +- description: Local server + url: http://localhost:8080 paths: /yorkie.v1.AdminService/ChangePassword: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/CreateProject: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.CreateProject.yorkie.v1.CreateProjectRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.CreateProject.yorkie.v1.CreateProjectRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.CreateProject.yorkie.v1.CreateProjectResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.CreateProject.yorkie.v1.CreateProjectResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/DeleteAccount: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/GetDocument: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.GetDocument.yorkie.v1.GetDocumentRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.GetDocument.yorkie.v1.GetDocumentRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.GetDocument.yorkie.v1.GetDocumentResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.GetDocument.yorkie.v1.GetDocumentResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/GetDocuments: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.GetDocuments.yorkie.v1.GetDocumentsRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.GetDocuments.yorkie.v1.GetDocumentsRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.GetDocuments.yorkie.v1.GetDocumentsResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.GetDocuments.yorkie.v1.GetDocumentsResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/GetProject: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.GetProject.yorkie.v1.GetProjectRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.GetProject.yorkie.v1.GetProjectRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.GetProject.yorkie.v1.GetProjectResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.GetProject.yorkie.v1.GetProjectResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/GetServerVersion: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.GetServerVersion.yorkie.v1.GetServerVersionRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.GetServerVersion.yorkie.v1.GetServerVersionRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.GetServerVersion.yorkie.v1.GetServerVersionResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.GetServerVersion.yorkie.v1.GetServerVersionResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/GetSnapshotMeta: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.GetSnapshotMeta.yorkie.v1.GetSnapshotMetaRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.GetSnapshotMeta.yorkie.v1.GetSnapshotMetaRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.GetSnapshotMeta.yorkie.v1.GetSnapshotMetaResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.GetSnapshotMeta.yorkie.v1.GetSnapshotMetaResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/ListChanges: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.ListChanges.yorkie.v1.ListChangesRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.ListChanges.yorkie.v1.ListChangesRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.ListChanges.yorkie.v1.ListChangesResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.ListChanges.yorkie.v1.ListChangesResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/ListDocuments: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.ListDocuments.yorkie.v1.ListDocumentsRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.ListDocuments.yorkie.v1.ListDocumentsRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.ListDocuments.yorkie.v1.ListDocumentsResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.ListDocuments.yorkie.v1.ListDocumentsResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/ListProjects: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.ListProjects.yorkie.v1.ListProjectsRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.ListProjects.yorkie.v1.ListProjectsRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.ListProjects.yorkie.v1.ListProjectsResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.ListProjects.yorkie.v1.ListProjectsResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/LogIn: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.LogIn.yorkie.v1.LogInRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.LogIn.yorkie.v1.LogInRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.LogIn.yorkie.v1.LogInResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.LogIn.yorkie.v1.LogInResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/RemoveDocumentByAdmin: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.RemoveDocumentByAdmin.yorkie.v1.RemoveDocumentByAdminRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.RemoveDocumentByAdmin.yorkie.v1.RemoveDocumentByAdminRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.RemoveDocumentByAdmin.yorkie.v1.RemoveDocumentByAdminResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.RemoveDocumentByAdmin.yorkie.v1.RemoveDocumentByAdminResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/SearchDocuments: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.SearchDocuments.yorkie.v1.SearchDocumentsRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.SearchDocuments.yorkie.v1.SearchDocumentsRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.SearchDocuments.yorkie.v1.SearchDocumentsResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.SearchDocuments.yorkie.v1.SearchDocumentsResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/SignUp: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.SignUp.yorkie.v1.SignUpRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.SignUp.yorkie.v1.SignUpRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.SignUp.yorkie.v1.SignUpResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.SignUp.yorkie.v1.SignUpResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService /yorkie.v1.AdminService/UpdateProject: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.AdminService.UpdateProject.yorkie.v1.UpdateProjectRequest" + $ref: '#/components/requestBodies/yorkie.v1.AdminService.UpdateProject.yorkie.v1.UpdateProjectRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.AdminService.UpdateProject.yorkie.v1.UpdateProjectResponse" + $ref: '#/components/responses/yorkie.v1.AdminService.UpdateProject.yorkie.v1.UpdateProjectResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.AdminService + - yorkie.v1.AdminService components: requestBodies: yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ChangePasswordRequest" + $ref: '#/components/schemas/yorkie.v1.ChangePasswordRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ChangePasswordRequest" + $ref: '#/components/schemas/yorkie.v1.ChangePasswordRequest' required: true yorkie.v1.AdminService.CreateProject.yorkie.v1.CreateProjectRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.CreateProjectRequest" + $ref: '#/components/schemas/yorkie.v1.CreateProjectRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.CreateProjectRequest" + $ref: '#/components/schemas/yorkie.v1.CreateProjectRequest' required: true yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.DeleteAccountRequest" + $ref: '#/components/schemas/yorkie.v1.DeleteAccountRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.DeleteAccountRequest" + $ref: '#/components/schemas/yorkie.v1.DeleteAccountRequest' required: true yorkie.v1.AdminService.GetDocument.yorkie.v1.GetDocumentRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetDocumentRequest" + $ref: '#/components/schemas/yorkie.v1.GetDocumentRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetDocumentRequest" + $ref: '#/components/schemas/yorkie.v1.GetDocumentRequest' required: true yorkie.v1.AdminService.GetDocuments.yorkie.v1.GetDocumentsRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetDocumentsRequest" + $ref: '#/components/schemas/yorkie.v1.GetDocumentsRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetDocumentsRequest" + $ref: '#/components/schemas/yorkie.v1.GetDocumentsRequest' required: true yorkie.v1.AdminService.GetProject.yorkie.v1.GetProjectRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetProjectRequest" + $ref: '#/components/schemas/yorkie.v1.GetProjectRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetProjectRequest" + $ref: '#/components/schemas/yorkie.v1.GetProjectRequest' required: true yorkie.v1.AdminService.GetServerVersion.yorkie.v1.GetServerVersionRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetServerVersionRequest" + $ref: '#/components/schemas/yorkie.v1.GetServerVersionRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetServerVersionRequest" + $ref: '#/components/schemas/yorkie.v1.GetServerVersionRequest' required: true yorkie.v1.AdminService.GetSnapshotMeta.yorkie.v1.GetSnapshotMetaRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetSnapshotMetaRequest" + $ref: '#/components/schemas/yorkie.v1.GetSnapshotMetaRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetSnapshotMetaRequest" + $ref: '#/components/schemas/yorkie.v1.GetSnapshotMetaRequest' required: true yorkie.v1.AdminService.ListChanges.yorkie.v1.ListChangesRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ListChangesRequest" + $ref: '#/components/schemas/yorkie.v1.ListChangesRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ListChangesRequest" + $ref: '#/components/schemas/yorkie.v1.ListChangesRequest' required: true yorkie.v1.AdminService.ListDocuments.yorkie.v1.ListDocumentsRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ListDocumentsRequest" + $ref: '#/components/schemas/yorkie.v1.ListDocumentsRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ListDocumentsRequest" + $ref: '#/components/schemas/yorkie.v1.ListDocumentsRequest' required: true yorkie.v1.AdminService.ListProjects.yorkie.v1.ListProjectsRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ListProjectsRequest" + $ref: '#/components/schemas/yorkie.v1.ListProjectsRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ListProjectsRequest" + $ref: '#/components/schemas/yorkie.v1.ListProjectsRequest' required: true yorkie.v1.AdminService.LogIn.yorkie.v1.LogInRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.LogInRequest" + $ref: '#/components/schemas/yorkie.v1.LogInRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.LogInRequest" + $ref: '#/components/schemas/yorkie.v1.LogInRequest' required: true yorkie.v1.AdminService.RemoveDocumentByAdmin.yorkie.v1.RemoveDocumentByAdminRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.RemoveDocumentByAdminRequest" + $ref: '#/components/schemas/yorkie.v1.RemoveDocumentByAdminRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.RemoveDocumentByAdminRequest" + $ref: '#/components/schemas/yorkie.v1.RemoveDocumentByAdminRequest' required: true yorkie.v1.AdminService.SearchDocuments.yorkie.v1.SearchDocumentsRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.SearchDocumentsRequest" + $ref: '#/components/schemas/yorkie.v1.SearchDocumentsRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.SearchDocumentsRequest" + $ref: '#/components/schemas/yorkie.v1.SearchDocumentsRequest' required: true yorkie.v1.AdminService.SignUp.yorkie.v1.SignUpRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.SignUpRequest" + $ref: '#/components/schemas/yorkie.v1.SignUpRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.SignUpRequest" + $ref: '#/components/schemas/yorkie.v1.SignUpRequest' required: true yorkie.v1.AdminService.UpdateProject.yorkie.v1.UpdateProjectRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.UpdateProjectRequest" + $ref: '#/components/schemas/yorkie.v1.UpdateProjectRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.UpdateProjectRequest" + $ref: '#/components/schemas/yorkie.v1.UpdateProjectRequest' required: true responses: connect.error: content: application/json: schema: - $ref: "#/components/schemas/connect.error" + $ref: '#/components/schemas/connect.error' application/proto: schema: - $ref: "#/components/schemas/connect.error" + $ref: '#/components/schemas/connect.error' description: "" yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ChangePasswordResponse" + $ref: '#/components/schemas/yorkie.v1.ChangePasswordResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ChangePasswordResponse" + $ref: '#/components/schemas/yorkie.v1.ChangePasswordResponse' description: "" yorkie.v1.AdminService.CreateProject.yorkie.v1.CreateProjectResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.CreateProjectResponse" + $ref: '#/components/schemas/yorkie.v1.CreateProjectResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.CreateProjectResponse" + $ref: '#/components/schemas/yorkie.v1.CreateProjectResponse' description: "" yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.DeleteAccountResponse" + $ref: '#/components/schemas/yorkie.v1.DeleteAccountResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.DeleteAccountResponse" + $ref: '#/components/schemas/yorkie.v1.DeleteAccountResponse' description: "" yorkie.v1.AdminService.GetDocument.yorkie.v1.GetDocumentResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetDocumentResponse" + $ref: '#/components/schemas/yorkie.v1.GetDocumentResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetDocumentResponse" + $ref: '#/components/schemas/yorkie.v1.GetDocumentResponse' description: "" yorkie.v1.AdminService.GetDocuments.yorkie.v1.GetDocumentsResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetDocumentsResponse" + $ref: '#/components/schemas/yorkie.v1.GetDocumentsResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetDocumentsResponse" + $ref: '#/components/schemas/yorkie.v1.GetDocumentsResponse' description: "" yorkie.v1.AdminService.GetProject.yorkie.v1.GetProjectResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetProjectResponse" + $ref: '#/components/schemas/yorkie.v1.GetProjectResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetProjectResponse" + $ref: '#/components/schemas/yorkie.v1.GetProjectResponse' description: "" yorkie.v1.AdminService.GetServerVersion.yorkie.v1.GetServerVersionResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetServerVersionResponse" + $ref: '#/components/schemas/yorkie.v1.GetServerVersionResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetServerVersionResponse" + $ref: '#/components/schemas/yorkie.v1.GetServerVersionResponse' description: "" yorkie.v1.AdminService.GetSnapshotMeta.yorkie.v1.GetSnapshotMetaResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.GetSnapshotMetaResponse" + $ref: '#/components/schemas/yorkie.v1.GetSnapshotMetaResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.GetSnapshotMetaResponse" + $ref: '#/components/schemas/yorkie.v1.GetSnapshotMetaResponse' description: "" yorkie.v1.AdminService.ListChanges.yorkie.v1.ListChangesResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ListChangesResponse" + $ref: '#/components/schemas/yorkie.v1.ListChangesResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ListChangesResponse" + $ref: '#/components/schemas/yorkie.v1.ListChangesResponse' description: "" yorkie.v1.AdminService.ListDocuments.yorkie.v1.ListDocumentsResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ListDocumentsResponse" + $ref: '#/components/schemas/yorkie.v1.ListDocumentsResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ListDocumentsResponse" + $ref: '#/components/schemas/yorkie.v1.ListDocumentsResponse' description: "" yorkie.v1.AdminService.ListProjects.yorkie.v1.ListProjectsResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ListProjectsResponse" + $ref: '#/components/schemas/yorkie.v1.ListProjectsResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ListProjectsResponse" + $ref: '#/components/schemas/yorkie.v1.ListProjectsResponse' description: "" yorkie.v1.AdminService.LogIn.yorkie.v1.LogInResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.LogInResponse" + $ref: '#/components/schemas/yorkie.v1.LogInResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.LogInResponse" + $ref: '#/components/schemas/yorkie.v1.LogInResponse' description: "" yorkie.v1.AdminService.RemoveDocumentByAdmin.yorkie.v1.RemoveDocumentByAdminResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.RemoveDocumentByAdminResponse" + $ref: '#/components/schemas/yorkie.v1.RemoveDocumentByAdminResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.RemoveDocumentByAdminResponse" + $ref: '#/components/schemas/yorkie.v1.RemoveDocumentByAdminResponse' description: "" yorkie.v1.AdminService.SearchDocuments.yorkie.v1.SearchDocumentsResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.SearchDocumentsResponse" + $ref: '#/components/schemas/yorkie.v1.SearchDocumentsResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.SearchDocumentsResponse" + $ref: '#/components/schemas/yorkie.v1.SearchDocumentsResponse' description: "" yorkie.v1.AdminService.SignUp.yorkie.v1.SignUpResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.SignUpResponse" + $ref: '#/components/schemas/yorkie.v1.SignUpResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.SignUpResponse" + $ref: '#/components/schemas/yorkie.v1.SignUpResponse' description: "" yorkie.v1.AdminService.UpdateProject.yorkie.v1.UpdateProjectResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.UpdateProjectResponse" + $ref: '#/components/schemas/yorkie.v1.UpdateProjectResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.UpdateProjectResponse" + $ref: '#/components/schemas/yorkie.v1.UpdateProjectResponse' description: "" schemas: connect.error: additionalProperties: false - description: "Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation" + description: 'Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation' properties: code: enum: - - CodeCanceled - - CodeUnknown - - CodeInvalidArgument - - CodeDeadlineExceeded - - CodeNotFound - - CodeAlreadyExists - - CodePermissionDenied - - CodeResourceExhausted - - CodeFailedPrecondition - - CodeAborted - - CodeOutOfRange - - CodeInternal - - CodeUnavailable - - CodeDataLoss - - CodeUnauthenticated + - CodeCanceled + - CodeUnknown + - CodeInvalidArgument + - CodeDeadlineExceeded + - CodeNotFound + - CodeAlreadyExists + - CodePermissionDenied + - CodeResourceExhausted + - CodeFailedPrecondition + - CodeAborted + - CodeOutOfRange + - CodeInternal + - CodeUnavailable + - CodeDataLoss + - CodeUnauthenticated examples: - - CodeNotFound + - CodeNotFound type: string message: type: string @@ -645,7 +644,7 @@ components: description: "" properties: id: - $ref: "#/components/schemas/yorkie.v1.ChangeID" + $ref: '#/components/schemas/yorkie.v1.ChangeID' additionalProperties: false description: "" title: id @@ -659,12 +658,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.Operation" + $ref: '#/components/schemas/yorkie.v1.Operation' type: object title: operations type: array presenceChange: - $ref: "#/components/schemas/yorkie.v1.PresenceChange" + $ref: '#/components/schemas/yorkie.v1.PresenceChange' additionalProperties: false description: "" title: presence_change @@ -690,15 +689,15 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: lamport serverSeq: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: server_seq title: ChangeID type: object @@ -744,7 +743,7 @@ components: description: "" properties: project: - $ref: "#/components/schemas/yorkie.v1.Project" + $ref: '#/components/schemas/yorkie.v1.Project' additionalProperties: false description: "" title: project @@ -777,13 +776,13 @@ components: description: "" properties: accessedAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: accessed_at type: object createdAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: created_at @@ -804,7 +803,7 @@ components: title: snapshot type: string updatedAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: updated_at @@ -832,7 +831,7 @@ components: description: "" properties: document: - $ref: "#/components/schemas/yorkie.v1.DocumentSummary" + $ref: '#/components/schemas/yorkie.v1.DocumentSummary' additionalProperties: false description: "" title: document @@ -870,7 +869,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.DocumentSummary" + $ref: '#/components/schemas/yorkie.v1.DocumentSummary' type: object title: documents type: array @@ -892,7 +891,7 @@ components: description: "" properties: project: - $ref: "#/components/schemas/yorkie.v1.Project" + $ref: '#/components/schemas/yorkie.v1.Project' additionalProperties: false description: "" title: project @@ -943,8 +942,8 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: server_seq title: GetSnapshotMetaRequest type: object @@ -956,8 +955,8 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: lamport snapshot: additionalProperties: false @@ -972,25 +971,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at type: object type: - $ref: "#/components/schemas/yorkie.v1.ValueType" + $ref: '#/components/schemas/yorkie.v1.ValueType' additionalProperties: false description: "" title: type @@ -1025,8 +1024,8 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: previous_seq projectName: additionalProperties: false @@ -1043,7 +1042,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.Change" + $ref: '#/components/schemas/yorkie.v1.Change' type: object title: changes type: array @@ -1088,7 +1087,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.DocumentSummary" + $ref: '#/components/schemas/yorkie.v1.DocumentSummary' type: object title: documents type: array @@ -1107,7 +1106,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.Project" + $ref: '#/components/schemas/yorkie.v1.Project' type: object title: projects type: array @@ -1150,7 +1149,7 @@ components: title: is_removed type: boolean updatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: updated_at @@ -1167,67 +1166,67 @@ components: description: "" properties: add: - $ref: "#/components/schemas/yorkie.v1.Operation.Add" + $ref: '#/components/schemas/yorkie.v1.Operation.Add' additionalProperties: false description: "" title: add type: object arraySet: - $ref: "#/components/schemas/yorkie.v1.Operation.ArraySet" + $ref: '#/components/schemas/yorkie.v1.Operation.ArraySet' additionalProperties: false description: "" title: array_set type: object edit: - $ref: "#/components/schemas/yorkie.v1.Operation.Edit" + $ref: '#/components/schemas/yorkie.v1.Operation.Edit' additionalProperties: false description: "" title: edit type: object increase: - $ref: "#/components/schemas/yorkie.v1.Operation.Increase" + $ref: '#/components/schemas/yorkie.v1.Operation.Increase' additionalProperties: false description: "" title: increase type: object move: - $ref: "#/components/schemas/yorkie.v1.Operation.Move" + $ref: '#/components/schemas/yorkie.v1.Operation.Move' additionalProperties: false description: "" title: move type: object remove: - $ref: "#/components/schemas/yorkie.v1.Operation.Remove" + $ref: '#/components/schemas/yorkie.v1.Operation.Remove' additionalProperties: false description: "" title: remove type: object select: - $ref: "#/components/schemas/yorkie.v1.Operation.Select" + $ref: '#/components/schemas/yorkie.v1.Operation.Select' additionalProperties: false description: "" title: select type: object set: - $ref: "#/components/schemas/yorkie.v1.Operation.Set" + $ref: '#/components/schemas/yorkie.v1.Operation.Set' additionalProperties: false description: "" title: set type: object style: - $ref: "#/components/schemas/yorkie.v1.Operation.Style" + $ref: '#/components/schemas/yorkie.v1.Operation.Style' additionalProperties: false description: "" title: style type: object treeEdit: - $ref: "#/components/schemas/yorkie.v1.Operation.TreeEdit" + $ref: '#/components/schemas/yorkie.v1.Operation.TreeEdit' additionalProperties: false description: "" title: tree_edit type: object treeStyle: - $ref: "#/components/schemas/yorkie.v1.Operation.TreeStyle" + $ref: '#/components/schemas/yorkie.v1.Operation.TreeStyle' additionalProperties: false description: "" title: tree_style @@ -1239,25 +1238,25 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object prevCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: prev_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -1269,25 +1268,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -1314,25 +1313,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -1365,7 +1364,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1377,19 +1376,19 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -1401,25 +1400,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object prevCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: prev_created_at @@ -1431,19 +1430,19 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at @@ -1459,25 +1458,25 @@ components: compatibility purposes. properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -1489,7 +1488,7 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at @@ -1500,13 +1499,13 @@ components: title: key type: string parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -1528,25 +1527,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -1579,7 +1578,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1594,7 +1593,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.TreeNodes" + $ref: '#/components/schemas/yorkie.v1.TreeNodes' type: object title: contents type: array @@ -1604,19 +1603,19 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at @@ -1627,7 +1626,7 @@ components: title: split_level type: integer to: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: to @@ -1644,7 +1643,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1673,25 +1672,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: to @@ -1724,7 +1723,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1763,13 +1762,13 @@ components: description: "" properties: presence: - $ref: "#/components/schemas/yorkie.v1.Presence" + $ref: '#/components/schemas/yorkie.v1.Presence' additionalProperties: false description: "" title: presence type: object type: - $ref: "#/components/schemas/yorkie.v1.PresenceChange.ChangeType" + $ref: '#/components/schemas/yorkie.v1.PresenceChange.ChangeType' additionalProperties: false description: "" title: type @@ -1778,14 +1777,14 @@ components: yorkie.v1.PresenceChange.ChangeType: description: "" enum: - - - CHANGE_TYPE_UNSPECIFIED - - 0 - - CHANGE_TYPE_PUT - - 1 - - CHANGE_TYPE_DELETE - - 2 - - CHANGE_TYPE_CLEAR - - 3 + - - CHANGE_TYPE_UNSPECIFIED + - 0 + - CHANGE_TYPE_PUT + - 1 + - CHANGE_TYPE_DELETE + - 2 + - CHANGE_TYPE_CLEAR + - 3 title: ChangeType type: string yorkie.v1.Project: @@ -1810,7 +1809,7 @@ components: title: client_deactivate_threshold type: string createdAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: created_at @@ -1836,7 +1835,7 @@ components: title: secret_key type: string updatedAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: updated_at @@ -1898,7 +1897,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.DocumentSummary" + $ref: '#/components/schemas/yorkie.v1.DocumentSummary' type: object title: documents type: array @@ -1930,7 +1929,7 @@ components: description: "" properties: user: - $ref: "#/components/schemas/yorkie.v1.User" + $ref: '#/components/schemas/yorkie.v1.User' additionalProperties: false description: "" title: user @@ -1942,7 +1941,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at @@ -1978,8 +1977,8 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: lamport title: TimeTicket type: object @@ -1998,25 +1997,25 @@ components: title: depth type: integer id: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: id type: object insNextId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: ins_next_id type: object insPrevId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: ins_prev_id type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at @@ -2043,7 +2042,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.NodeAttr" + $ref: '#/components/schemas/yorkie.v1.NodeAttr' additionalProperties: false description: "" title: value @@ -2055,7 +2054,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at @@ -2075,7 +2074,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.TreeNode" + $ref: '#/components/schemas/yorkie.v1.TreeNode' type: object title: content type: array @@ -2086,13 +2085,13 @@ components: description: "" properties: leftSiblingId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: left_sibling_id type: object parentId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: parent_id @@ -2104,25 +2103,25 @@ components: description: "" properties: authWebhookMethods: - $ref: "#/components/schemas/yorkie.v1.UpdatableProjectFields.AuthWebhookMethods" + $ref: '#/components/schemas/yorkie.v1.UpdatableProjectFields.AuthWebhookMethods' additionalProperties: false description: "" title: auth_webhook_methods type: object authWebhookUrl: - $ref: "#/components/schemas/google.protobuf.StringValue" + $ref: '#/components/schemas/google.protobuf.StringValue' additionalProperties: false description: "" title: auth_webhook_url type: object clientDeactivateThreshold: - $ref: "#/components/schemas/google.protobuf.StringValue" + $ref: '#/components/schemas/google.protobuf.StringValue' additionalProperties: false description: "" title: client_deactivate_threshold type: object name: - $ref: "#/components/schemas/google.protobuf.StringValue" + $ref: '#/components/schemas/google.protobuf.StringValue' additionalProperties: false description: "" title: name @@ -2147,7 +2146,7 @@ components: description: "" properties: fields: - $ref: "#/components/schemas/yorkie.v1.UpdatableProjectFields" + $ref: '#/components/schemas/yorkie.v1.UpdatableProjectFields' additionalProperties: false description: "" title: fields @@ -2164,7 +2163,7 @@ components: description: "" properties: project: - $ref: "#/components/schemas/yorkie.v1.Project" + $ref: '#/components/schemas/yorkie.v1.Project' additionalProperties: false description: "" title: project @@ -2176,7 +2175,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: created_at @@ -2196,34 +2195,34 @@ components: yorkie.v1.ValueType: description: "" enum: - - - VALUE_TYPE_NULL - - 0 - - VALUE_TYPE_BOOLEAN - - 1 - - VALUE_TYPE_INTEGER - - 2 - - VALUE_TYPE_LONG - - 3 - - VALUE_TYPE_DOUBLE - - 4 - - VALUE_TYPE_STRING - - 5 - - VALUE_TYPE_BYTES - - 6 - - VALUE_TYPE_DATE - - 7 - - VALUE_TYPE_JSON_OBJECT - - 8 - - VALUE_TYPE_JSON_ARRAY - - 9 - - VALUE_TYPE_TEXT - - 10 - - VALUE_TYPE_INTEGER_CNT - - 11 - - VALUE_TYPE_LONG_CNT - - 12 - - VALUE_TYPE_TREE - - 13 + - - VALUE_TYPE_NULL + - 0 + - VALUE_TYPE_BOOLEAN + - 1 + - VALUE_TYPE_INTEGER + - 2 + - VALUE_TYPE_LONG + - 3 + - VALUE_TYPE_DOUBLE + - 4 + - VALUE_TYPE_STRING + - 5 + - VALUE_TYPE_BYTES + - 6 + - VALUE_TYPE_DATE + - 7 + - VALUE_TYPE_JSON_OBJECT + - 8 + - VALUE_TYPE_JSON_ARRAY + - 9 + - VALUE_TYPE_TEXT + - 10 + - VALUE_TYPE_INTEGER_CNT + - 11 + - VALUE_TYPE_LONG_CNT + - 12 + - VALUE_TYPE_TREE + - 13 title: ValueType type: string securitySchemes: @@ -2232,7 +2231,7 @@ components: name: Authorization type: apiKey security: - - ApiKeyAuth: [] +- ApiKeyAuth: [] tags: - - description: Admin is a service that provides a API for Admin. - name: yorkie.v1.AdminService +- description: Admin is a service that provides a API for Admin. + name: yorkie.v1.AdminService diff --git a/api/docs/yorkie/v1/resources.openapi.yaml b/api/docs/yorkie/v1/resources.openapi.yaml index 4252c0593..3ffb27254 100644 --- a/api/docs/yorkie/v1/resources.openapi.yaml +++ b/api/docs/yorkie/v1/resources.openapi.yaml @@ -1,15 +1,14 @@ openapi: 3.1.0 info: - description: - Yorkie is an open source document store for building collaborative + description: Yorkie is an open source document store for building collaborative editing applications. title: Yorkie version: v0.5.1 servers: - - description: Production server - url: https://api.yorkie.dev - - description: Local server - url: http://localhost:8080 +- description: Production server + url: https://api.yorkie.dev +- description: Local server + url: http://localhost:8080 paths: {} components: responses: @@ -17,35 +16,35 @@ components: content: application/json: schema: - $ref: "#/components/schemas/connect.error" + $ref: '#/components/schemas/connect.error' application/proto: schema: - $ref: "#/components/schemas/connect.error" + $ref: '#/components/schemas/connect.error' description: "" schemas: connect.error: additionalProperties: false - description: "Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation" + description: 'Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation' properties: code: enum: - - CodeCanceled - - CodeUnknown - - CodeInvalidArgument - - CodeDeadlineExceeded - - CodeNotFound - - CodeAlreadyExists - - CodePermissionDenied - - CodeResourceExhausted - - CodeFailedPrecondition - - CodeAborted - - CodeOutOfRange - - CodeInternal - - CodeUnavailable - - CodeDataLoss - - CodeUnauthenticated + - CodeCanceled + - CodeUnknown + - CodeInvalidArgument + - CodeDeadlineExceeded + - CodeNotFound + - CodeAlreadyExists + - CodePermissionDenied + - CodeResourceExhausted + - CodeFailedPrecondition + - CodeAborted + - CodeOutOfRange + - CodeInternal + - CodeUnavailable + - CodeDataLoss + - CodeUnauthenticated examples: - - CodeNotFound + - CodeNotFound type: string message: type: string @@ -164,7 +163,7 @@ components: description: "" properties: id: - $ref: "#/components/schemas/yorkie.v1.ChangeID" + $ref: '#/components/schemas/yorkie.v1.ChangeID' additionalProperties: false description: "" title: id @@ -178,12 +177,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.Operation" + $ref: '#/components/schemas/yorkie.v1.Operation' type: object title: operations type: array presenceChange: - $ref: "#/components/schemas/yorkie.v1.PresenceChange" + $ref: '#/components/schemas/yorkie.v1.PresenceChange' additionalProperties: false description: "" title: presence_change @@ -209,15 +208,15 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: lamport serverSeq: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: server_seq title: ChangeID type: object @@ -231,12 +230,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.Change" + $ref: '#/components/schemas/yorkie.v1.Change' type: object title: changes type: array checkpoint: - $ref: "#/components/schemas/yorkie.v1.Checkpoint" + $ref: '#/components/schemas/yorkie.v1.Checkpoint' additionalProperties: false description: "" title: checkpoint @@ -252,7 +251,7 @@ components: title: is_removed type: boolean minSyncedTicket: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: min_synced_ticket @@ -278,8 +277,8 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: server_seq title: Checkpoint type: object @@ -288,7 +287,7 @@ components: description: "" properties: body: - $ref: "#/components/schemas/yorkie.v1.DocEventBody" + $ref: '#/components/schemas/yorkie.v1.DocEventBody' additionalProperties: false description: "" title: body @@ -299,7 +298,7 @@ components: title: publisher type: string type: - $ref: "#/components/schemas/yorkie.v1.DocEventType" + $ref: '#/components/schemas/yorkie.v1.DocEventType' additionalProperties: false description: "" title: type @@ -325,14 +324,14 @@ components: yorkie.v1.DocEventType: description: "" enum: - - - DOC_EVENT_TYPE_DOCUMENT_CHANGED - - 0 - - DOC_EVENT_TYPE_DOCUMENT_WATCHED - - 1 - - DOC_EVENT_TYPE_DOCUMENT_UNWATCHED - - 2 - - DOC_EVENT_TYPE_DOCUMENT_BROADCAST - - 3 + - - DOC_EVENT_TYPE_DOCUMENT_CHANGED + - 0 + - DOC_EVENT_TYPE_DOCUMENT_WATCHED + - 1 + - DOC_EVENT_TYPE_DOCUMENT_UNWATCHED + - 2 + - DOC_EVENT_TYPE_DOCUMENT_BROADCAST + - 3 title: DocEventType type: string yorkie.v1.DocumentSummary: @@ -340,13 +339,13 @@ components: description: "" properties: accessedAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: accessed_at type: object createdAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: created_at @@ -367,7 +366,7 @@ components: title: snapshot type: string updatedAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: updated_at @@ -379,37 +378,37 @@ components: description: "" properties: counter: - $ref: "#/components/schemas/yorkie.v1.JSONElement.Counter" + $ref: '#/components/schemas/yorkie.v1.JSONElement.Counter' additionalProperties: false description: "" title: counter type: object jsonArray: - $ref: "#/components/schemas/yorkie.v1.JSONElement.JSONArray" + $ref: '#/components/schemas/yorkie.v1.JSONElement.JSONArray' additionalProperties: false description: "" title: json_array type: object jsonObject: - $ref: "#/components/schemas/yorkie.v1.JSONElement.JSONObject" + $ref: '#/components/schemas/yorkie.v1.JSONElement.JSONObject' additionalProperties: false description: "" title: json_object type: object primitive: - $ref: "#/components/schemas/yorkie.v1.JSONElement.Primitive" + $ref: '#/components/schemas/yorkie.v1.JSONElement.Primitive' additionalProperties: false description: "" title: primitive type: object text: - $ref: "#/components/schemas/yorkie.v1.JSONElement.Text" + $ref: '#/components/schemas/yorkie.v1.JSONElement.Text' additionalProperties: false description: "" title: text type: object tree: - $ref: "#/components/schemas/yorkie.v1.JSONElement.Tree" + $ref: '#/components/schemas/yorkie.v1.JSONElement.Tree' additionalProperties: false description: "" title: tree @@ -421,25 +420,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at type: object type: - $ref: "#/components/schemas/yorkie.v1.ValueType" + $ref: '#/components/schemas/yorkie.v1.ValueType' additionalProperties: false description: "" title: type @@ -456,13 +455,13 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at @@ -471,12 +470,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.RGANode" + $ref: '#/components/schemas/yorkie.v1.RGANode' type: object title: nodes type: array removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at @@ -488,13 +487,13 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at @@ -503,12 +502,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.RHTNode" + $ref: '#/components/schemas/yorkie.v1.RHTNode' type: object title: nodes type: array removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at @@ -520,25 +519,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at type: object type: - $ref: "#/components/schemas/yorkie.v1.ValueType" + $ref: '#/components/schemas/yorkie.v1.ValueType' additionalProperties: false description: "" title: type @@ -555,13 +554,13 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at @@ -570,12 +569,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.TextNode" + $ref: '#/components/schemas/yorkie.v1.TextNode' type: object title: nodes type: array removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at @@ -587,13 +586,13 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at @@ -602,12 +601,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.TreeNode" + $ref: '#/components/schemas/yorkie.v1.TreeNode' type: object title: nodes type: array removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at @@ -619,25 +618,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at type: object type: - $ref: "#/components/schemas/yorkie.v1.ValueType" + $ref: '#/components/schemas/yorkie.v1.ValueType' additionalProperties: false description: "" title: type @@ -659,7 +658,7 @@ components: title: is_removed type: boolean updatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: updated_at @@ -676,67 +675,67 @@ components: description: "" properties: add: - $ref: "#/components/schemas/yorkie.v1.Operation.Add" + $ref: '#/components/schemas/yorkie.v1.Operation.Add' additionalProperties: false description: "" title: add type: object arraySet: - $ref: "#/components/schemas/yorkie.v1.Operation.ArraySet" + $ref: '#/components/schemas/yorkie.v1.Operation.ArraySet' additionalProperties: false description: "" title: array_set type: object edit: - $ref: "#/components/schemas/yorkie.v1.Operation.Edit" + $ref: '#/components/schemas/yorkie.v1.Operation.Edit' additionalProperties: false description: "" title: edit type: object increase: - $ref: "#/components/schemas/yorkie.v1.Operation.Increase" + $ref: '#/components/schemas/yorkie.v1.Operation.Increase' additionalProperties: false description: "" title: increase type: object move: - $ref: "#/components/schemas/yorkie.v1.Operation.Move" + $ref: '#/components/schemas/yorkie.v1.Operation.Move' additionalProperties: false description: "" title: move type: object remove: - $ref: "#/components/schemas/yorkie.v1.Operation.Remove" + $ref: '#/components/schemas/yorkie.v1.Operation.Remove' additionalProperties: false description: "" title: remove type: object select: - $ref: "#/components/schemas/yorkie.v1.Operation.Select" + $ref: '#/components/schemas/yorkie.v1.Operation.Select' additionalProperties: false description: "" title: select type: object set: - $ref: "#/components/schemas/yorkie.v1.Operation.Set" + $ref: '#/components/schemas/yorkie.v1.Operation.Set' additionalProperties: false description: "" title: set type: object style: - $ref: "#/components/schemas/yorkie.v1.Operation.Style" + $ref: '#/components/schemas/yorkie.v1.Operation.Style' additionalProperties: false description: "" title: style type: object treeEdit: - $ref: "#/components/schemas/yorkie.v1.Operation.TreeEdit" + $ref: '#/components/schemas/yorkie.v1.Operation.TreeEdit' additionalProperties: false description: "" title: tree_edit type: object treeStyle: - $ref: "#/components/schemas/yorkie.v1.Operation.TreeStyle" + $ref: '#/components/schemas/yorkie.v1.Operation.TreeStyle' additionalProperties: false description: "" title: tree_style @@ -748,25 +747,25 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object prevCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: prev_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -778,25 +777,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -823,25 +822,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -874,7 +873,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -886,19 +885,19 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -910,25 +909,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object prevCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: prev_created_at @@ -940,19 +939,19 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at @@ -968,25 +967,25 @@ components: compatibility purposes. properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -998,7 +997,7 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at @@ -1009,13 +1008,13 @@ components: title: key type: string parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -1037,25 +1036,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -1088,7 +1087,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1103,7 +1102,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.TreeNodes" + $ref: '#/components/schemas/yorkie.v1.TreeNodes' type: object title: contents type: array @@ -1113,19 +1112,19 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at @@ -1136,7 +1135,7 @@ components: title: split_level type: integer to: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: to @@ -1153,7 +1152,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1182,25 +1181,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: to @@ -1233,7 +1232,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1272,13 +1271,13 @@ components: description: "" properties: presence: - $ref: "#/components/schemas/yorkie.v1.Presence" + $ref: '#/components/schemas/yorkie.v1.Presence' additionalProperties: false description: "" title: presence type: object type: - $ref: "#/components/schemas/yorkie.v1.PresenceChange.ChangeType" + $ref: '#/components/schemas/yorkie.v1.PresenceChange.ChangeType' additionalProperties: false description: "" title: type @@ -1287,14 +1286,14 @@ components: yorkie.v1.PresenceChange.ChangeType: description: "" enum: - - - CHANGE_TYPE_UNSPECIFIED - - 0 - - CHANGE_TYPE_PUT - - 1 - - CHANGE_TYPE_DELETE - - 2 - - CHANGE_TYPE_CLEAR - - 3 + - - CHANGE_TYPE_UNSPECIFIED + - 0 + - CHANGE_TYPE_PUT + - 1 + - CHANGE_TYPE_DELETE + - 2 + - CHANGE_TYPE_CLEAR + - 3 title: ChangeType type: string yorkie.v1.Project: @@ -1319,7 +1318,7 @@ components: title: client_deactivate_threshold type: string createdAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: created_at @@ -1345,7 +1344,7 @@ components: title: secret_key type: string updatedAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: updated_at @@ -1357,13 +1356,13 @@ components: description: "" properties: element: - $ref: "#/components/schemas/yorkie.v1.JSONElement" + $ref: '#/components/schemas/yorkie.v1.JSONElement' additionalProperties: false description: "" title: element type: object next: - $ref: "#/components/schemas/yorkie.v1.RGANode" + $ref: '#/components/schemas/yorkie.v1.RGANode' additionalProperties: false description: "" title: next @@ -1375,7 +1374,7 @@ components: description: "" properties: element: - $ref: "#/components/schemas/yorkie.v1.JSONElement" + $ref: '#/components/schemas/yorkie.v1.JSONElement' additionalProperties: false description: "" title: element @@ -1400,7 +1399,7 @@ components: title: presences type: object root: - $ref: "#/components/schemas/yorkie.v1.JSONElement" + $ref: '#/components/schemas/yorkie.v1.JSONElement' additionalProperties: false description: "" title: root @@ -1417,7 +1416,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.Presence" + $ref: '#/components/schemas/yorkie.v1.Presence' additionalProperties: false description: "" title: value @@ -1434,19 +1433,19 @@ components: title: attributes type: object id: - $ref: "#/components/schemas/yorkie.v1.TextNodeID" + $ref: '#/components/schemas/yorkie.v1.TextNodeID' additionalProperties: false description: "" title: id type: object insPrevId: - $ref: "#/components/schemas/yorkie.v1.TextNodeID" + $ref: '#/components/schemas/yorkie.v1.TextNodeID' additionalProperties: false description: "" title: ins_prev_id type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at @@ -1468,7 +1467,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.NodeAttr" + $ref: '#/components/schemas/yorkie.v1.NodeAttr' additionalProperties: false description: "" title: value @@ -1480,7 +1479,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at @@ -1497,7 +1496,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at @@ -1533,8 +1532,8 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: lamport title: TimeTicket type: object @@ -1553,25 +1552,25 @@ components: title: depth type: integer id: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: id type: object insNextId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: ins_next_id type: object insPrevId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: ins_prev_id type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at @@ -1598,7 +1597,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.NodeAttr" + $ref: '#/components/schemas/yorkie.v1.NodeAttr' additionalProperties: false description: "" title: value @@ -1610,7 +1609,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at @@ -1630,7 +1629,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.TreeNode" + $ref: '#/components/schemas/yorkie.v1.TreeNode' type: object title: content type: array @@ -1641,13 +1640,13 @@ components: description: "" properties: leftSiblingId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: left_sibling_id type: object parentId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: parent_id @@ -1659,25 +1658,25 @@ components: description: "" properties: authWebhookMethods: - $ref: "#/components/schemas/yorkie.v1.UpdatableProjectFields.AuthWebhookMethods" + $ref: '#/components/schemas/yorkie.v1.UpdatableProjectFields.AuthWebhookMethods' additionalProperties: false description: "" title: auth_webhook_methods type: object authWebhookUrl: - $ref: "#/components/schemas/google.protobuf.StringValue" + $ref: '#/components/schemas/google.protobuf.StringValue' additionalProperties: false description: "" title: auth_webhook_url type: object clientDeactivateThreshold: - $ref: "#/components/schemas/google.protobuf.StringValue" + $ref: '#/components/schemas/google.protobuf.StringValue' additionalProperties: false description: "" title: client_deactivate_threshold type: object name: - $ref: "#/components/schemas/google.protobuf.StringValue" + $ref: '#/components/schemas/google.protobuf.StringValue' additionalProperties: false description: "" title: name @@ -1702,7 +1701,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/google.protobuf.Timestamp" + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" title: created_at @@ -1722,34 +1721,34 @@ components: yorkie.v1.ValueType: description: "" enum: - - - VALUE_TYPE_NULL - - 0 - - VALUE_TYPE_BOOLEAN - - 1 - - VALUE_TYPE_INTEGER - - 2 - - VALUE_TYPE_LONG - - 3 - - VALUE_TYPE_DOUBLE - - 4 - - VALUE_TYPE_STRING - - 5 - - VALUE_TYPE_BYTES - - 6 - - VALUE_TYPE_DATE - - 7 - - VALUE_TYPE_JSON_OBJECT - - 8 - - VALUE_TYPE_JSON_ARRAY - - 9 - - VALUE_TYPE_TEXT - - 10 - - VALUE_TYPE_INTEGER_CNT - - 11 - - VALUE_TYPE_LONG_CNT - - 12 - - VALUE_TYPE_TREE - - 13 + - - VALUE_TYPE_NULL + - 0 + - VALUE_TYPE_BOOLEAN + - 1 + - VALUE_TYPE_INTEGER + - 2 + - VALUE_TYPE_LONG + - 3 + - VALUE_TYPE_DOUBLE + - 4 + - VALUE_TYPE_STRING + - 5 + - VALUE_TYPE_BYTES + - 6 + - VALUE_TYPE_DATE + - 7 + - VALUE_TYPE_JSON_OBJECT + - 8 + - VALUE_TYPE_JSON_ARRAY + - 9 + - VALUE_TYPE_TEXT + - 10 + - VALUE_TYPE_INTEGER_CNT + - 11 + - VALUE_TYPE_LONG_CNT + - 12 + - VALUE_TYPE_TREE + - 13 title: ValueType type: string securitySchemes: @@ -1758,4 +1757,4 @@ components: name: Authorization type: apiKey security: - - ApiKeyAuth: [] +- ApiKeyAuth: [] diff --git a/api/docs/yorkie/v1/system.openapi.yaml b/api/docs/yorkie/v1/system.openapi.yaml new file mode 100644 index 000000000..6f3b92d2f --- /dev/null +++ b/api/docs/yorkie/v1/system.openapi.yaml @@ -0,0 +1,125 @@ +openapi: 3.1.0 +info: + description: Yorkie is an open source document store for building collaborative + editing applications. + title: Yorkie + version: v0.5.1 +servers: +- description: Production server + url: https://api.yorkie.dev +- description: Local server + url: http://localhost:8080 +paths: + /yorkie.v1.SystemService/DetachDocument: + post: + description: "" + requestBody: + $ref: '#/components/requestBodies/yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentRequestBySystem' + responses: + "200": + $ref: '#/components/responses/yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentResponseBySystem' + default: + $ref: '#/components/responses/connect.error' + tags: + - yorkie.v1.SystemService +components: + requestBodies: + yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentRequestBySystem: + content: + application/json: + schema: + $ref: '#/components/schemas/yorkie.v1.DetachDocumentRequestBySystem' + application/proto: + schema: + $ref: '#/components/schemas/yorkie.v1.DetachDocumentRequestBySystem' + required: true + responses: + connect.error: + content: + application/json: + schema: + $ref: '#/components/schemas/connect.error' + application/proto: + schema: + $ref: '#/components/schemas/connect.error' + description: "" + yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentResponseBySystem: + content: + application/json: + schema: + $ref: '#/components/schemas/yorkie.v1.DetachDocumentResponseBySystem' + application/proto: + schema: + $ref: '#/components/schemas/yorkie.v1.DetachDocumentResponseBySystem' + description: "" + schemas: + connect.error: + additionalProperties: false + description: 'Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation' + properties: + code: + enum: + - CodeCanceled + - CodeUnknown + - CodeInvalidArgument + - CodeDeadlineExceeded + - CodeNotFound + - CodeAlreadyExists + - CodePermissionDenied + - CodeResourceExhausted + - CodeFailedPrecondition + - CodeAborted + - CodeOutOfRange + - CodeInternal + - CodeUnavailable + - CodeDataLoss + - CodeUnauthenticated + examples: + - CodeNotFound + type: string + message: + type: string + title: Connect Error + type: object + yorkie.v1.DetachDocumentRequestBySystem: + additionalProperties: false + description: "" + properties: + clientId: + additionalProperties: false + description: "" + title: client_id + type: string + documentId: + additionalProperties: false + description: "" + title: document_id + type: string + documentKey: + additionalProperties: false + description: "" + title: document_key + type: string + projectId: + additionalProperties: false + description: 'TODO(hackerwins): Consider to replace this fields with types.Project, + types.Client, types.DocumentSummary' + title: project_id + type: string + title: DetachDocumentRequestBySystem + type: object + yorkie.v1.DetachDocumentResponseBySystem: + additionalProperties: false + description: "" + title: DetachDocumentResponseBySystem + type: object + securitySchemes: + ApiKeyAuth: + in: header + name: Authorization + type: apiKey +security: +- ApiKeyAuth: [] +tags: +- description: System is a service that provides an API for Cluster. + name: yorkie.v1.SystemService diff --git a/api/docs/yorkie/v1/yorkie.openapi.yaml b/api/docs/yorkie/v1/yorkie.openapi.yaml index bdd4bca49..540d0ad16 100644 --- a/api/docs/yorkie/v1/yorkie.openapi.yaml +++ b/api/docs/yorkie/v1/yorkie.openapi.yaml @@ -1,176 +1,175 @@ openapi: 3.1.0 info: - description: - Yorkie is an open source document store for building collaborative + description: Yorkie is an open source document store for building collaborative editing applications. title: Yorkie version: v0.5.1 servers: - - description: Production server - url: https://api.yorkie.dev - - description: Local server - url: http://localhost:8080 +- description: Production server + url: https://api.yorkie.dev +- description: Local server + url: http://localhost:8080 paths: /yorkie.v1.YorkieService/ActivateClient: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.YorkieService.ActivateClient.yorkie.v1.ActivateClientRequest" + $ref: '#/components/requestBodies/yorkie.v1.YorkieService.ActivateClient.yorkie.v1.ActivateClientRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.YorkieService.ActivateClient.yorkie.v1.ActivateClientResponse" + $ref: '#/components/responses/yorkie.v1.YorkieService.ActivateClient.yorkie.v1.ActivateClientResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.YorkieService + - yorkie.v1.YorkieService /yorkie.v1.YorkieService/AttachDocument: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.YorkieService.AttachDocument.yorkie.v1.AttachDocumentRequest" + $ref: '#/components/requestBodies/yorkie.v1.YorkieService.AttachDocument.yorkie.v1.AttachDocumentRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.YorkieService.AttachDocument.yorkie.v1.AttachDocumentResponse" + $ref: '#/components/responses/yorkie.v1.YorkieService.AttachDocument.yorkie.v1.AttachDocumentResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.YorkieService + - yorkie.v1.YorkieService /yorkie.v1.YorkieService/Broadcast: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.YorkieService.Broadcast.yorkie.v1.BroadcastRequest" + $ref: '#/components/requestBodies/yorkie.v1.YorkieService.Broadcast.yorkie.v1.BroadcastRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.YorkieService.Broadcast.yorkie.v1.BroadcastResponse" + $ref: '#/components/responses/yorkie.v1.YorkieService.Broadcast.yorkie.v1.BroadcastResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.YorkieService + - yorkie.v1.YorkieService /yorkie.v1.YorkieService/DeactivateClient: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.YorkieService.DeactivateClient.yorkie.v1.DeactivateClientRequest" + $ref: '#/components/requestBodies/yorkie.v1.YorkieService.DeactivateClient.yorkie.v1.DeactivateClientRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.YorkieService.DeactivateClient.yorkie.v1.DeactivateClientResponse" + $ref: '#/components/responses/yorkie.v1.YorkieService.DeactivateClient.yorkie.v1.DeactivateClientResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.YorkieService + - yorkie.v1.YorkieService /yorkie.v1.YorkieService/DetachDocument: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.YorkieService.DetachDocument.yorkie.v1.DetachDocumentRequest" + $ref: '#/components/requestBodies/yorkie.v1.YorkieService.DetachDocument.yorkie.v1.DetachDocumentRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.YorkieService.DetachDocument.yorkie.v1.DetachDocumentResponse" + $ref: '#/components/responses/yorkie.v1.YorkieService.DetachDocument.yorkie.v1.DetachDocumentResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.YorkieService + - yorkie.v1.YorkieService /yorkie.v1.YorkieService/PushPullChanges: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.YorkieService.PushPullChanges.yorkie.v1.PushPullChangesRequest" + $ref: '#/components/requestBodies/yorkie.v1.YorkieService.PushPullChanges.yorkie.v1.PushPullChangesRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.YorkieService.PushPullChanges.yorkie.v1.PushPullChangesResponse" + $ref: '#/components/responses/yorkie.v1.YorkieService.PushPullChanges.yorkie.v1.PushPullChangesResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.YorkieService + - yorkie.v1.YorkieService /yorkie.v1.YorkieService/RemoveDocument: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.YorkieService.RemoveDocument.yorkie.v1.RemoveDocumentRequest" + $ref: '#/components/requestBodies/yorkie.v1.YorkieService.RemoveDocument.yorkie.v1.RemoveDocumentRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.YorkieService.RemoveDocument.yorkie.v1.RemoveDocumentResponse" + $ref: '#/components/responses/yorkie.v1.YorkieService.RemoveDocument.yorkie.v1.RemoveDocumentResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.YorkieService + - yorkie.v1.YorkieService /yorkie.v1.YorkieService/WatchDocument: post: description: "" requestBody: - $ref: "#/components/requestBodies/yorkie.v1.YorkieService.WatchDocument.yorkie.v1.WatchDocumentRequest" + $ref: '#/components/requestBodies/yorkie.v1.YorkieService.WatchDocument.yorkie.v1.WatchDocumentRequest' responses: "200": - $ref: "#/components/responses/yorkie.v1.YorkieService.WatchDocument.yorkie.v1.WatchDocumentResponse" + $ref: '#/components/responses/yorkie.v1.YorkieService.WatchDocument.yorkie.v1.WatchDocumentResponse' default: - $ref: "#/components/responses/connect.error" + $ref: '#/components/responses/connect.error' tags: - - yorkie.v1.YorkieService + - yorkie.v1.YorkieService components: requestBodies: yorkie.v1.YorkieService.ActivateClient.yorkie.v1.ActivateClientRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ActivateClientRequest" + $ref: '#/components/schemas/yorkie.v1.ActivateClientRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ActivateClientRequest" + $ref: '#/components/schemas/yorkie.v1.ActivateClientRequest' required: true yorkie.v1.YorkieService.AttachDocument.yorkie.v1.AttachDocumentRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.AttachDocumentRequest" + $ref: '#/components/schemas/yorkie.v1.AttachDocumentRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.AttachDocumentRequest" + $ref: '#/components/schemas/yorkie.v1.AttachDocumentRequest' required: true yorkie.v1.YorkieService.Broadcast.yorkie.v1.BroadcastRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.BroadcastRequest" + $ref: '#/components/schemas/yorkie.v1.BroadcastRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.BroadcastRequest" + $ref: '#/components/schemas/yorkie.v1.BroadcastRequest' required: true yorkie.v1.YorkieService.DeactivateClient.yorkie.v1.DeactivateClientRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.DeactivateClientRequest" + $ref: '#/components/schemas/yorkie.v1.DeactivateClientRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.DeactivateClientRequest" + $ref: '#/components/schemas/yorkie.v1.DeactivateClientRequest' required: true yorkie.v1.YorkieService.DetachDocument.yorkie.v1.DetachDocumentRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.DetachDocumentRequest" + $ref: '#/components/schemas/yorkie.v1.DetachDocumentRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.DetachDocumentRequest" + $ref: '#/components/schemas/yorkie.v1.DetachDocumentRequest' required: true yorkie.v1.YorkieService.PushPullChanges.yorkie.v1.PushPullChangesRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.PushPullChangesRequest" + $ref: '#/components/schemas/yorkie.v1.PushPullChangesRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.PushPullChangesRequest" + $ref: '#/components/schemas/yorkie.v1.PushPullChangesRequest' required: true yorkie.v1.YorkieService.RemoveDocument.yorkie.v1.RemoveDocumentRequest: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.RemoveDocumentRequest" + $ref: '#/components/schemas/yorkie.v1.RemoveDocumentRequest' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.RemoveDocumentRequest" + $ref: '#/components/schemas/yorkie.v1.RemoveDocumentRequest' required: true yorkie.v1.YorkieService.WatchDocument.yorkie.v1.WatchDocumentRequest: content: {} @@ -180,100 +179,100 @@ components: content: application/json: schema: - $ref: "#/components/schemas/connect.error" + $ref: '#/components/schemas/connect.error' application/proto: schema: - $ref: "#/components/schemas/connect.error" + $ref: '#/components/schemas/connect.error' description: "" yorkie.v1.YorkieService.ActivateClient.yorkie.v1.ActivateClientResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.ActivateClientResponse" + $ref: '#/components/schemas/yorkie.v1.ActivateClientResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.ActivateClientResponse" + $ref: '#/components/schemas/yorkie.v1.ActivateClientResponse' description: "" yorkie.v1.YorkieService.AttachDocument.yorkie.v1.AttachDocumentResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.AttachDocumentResponse" + $ref: '#/components/schemas/yorkie.v1.AttachDocumentResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.AttachDocumentResponse" + $ref: '#/components/schemas/yorkie.v1.AttachDocumentResponse' description: "" yorkie.v1.YorkieService.Broadcast.yorkie.v1.BroadcastResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.BroadcastResponse" + $ref: '#/components/schemas/yorkie.v1.BroadcastResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.BroadcastResponse" + $ref: '#/components/schemas/yorkie.v1.BroadcastResponse' description: "" yorkie.v1.YorkieService.DeactivateClient.yorkie.v1.DeactivateClientResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.DeactivateClientResponse" + $ref: '#/components/schemas/yorkie.v1.DeactivateClientResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.DeactivateClientResponse" + $ref: '#/components/schemas/yorkie.v1.DeactivateClientResponse' description: "" yorkie.v1.YorkieService.DetachDocument.yorkie.v1.DetachDocumentResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.DetachDocumentResponse" + $ref: '#/components/schemas/yorkie.v1.DetachDocumentResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.DetachDocumentResponse" + $ref: '#/components/schemas/yorkie.v1.DetachDocumentResponse' description: "" yorkie.v1.YorkieService.PushPullChanges.yorkie.v1.PushPullChangesResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.PushPullChangesResponse" + $ref: '#/components/schemas/yorkie.v1.PushPullChangesResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.PushPullChangesResponse" + $ref: '#/components/schemas/yorkie.v1.PushPullChangesResponse' description: "" yorkie.v1.YorkieService.RemoveDocument.yorkie.v1.RemoveDocumentResponse: content: application/json: schema: - $ref: "#/components/schemas/yorkie.v1.RemoveDocumentResponse" + $ref: '#/components/schemas/yorkie.v1.RemoveDocumentResponse' application/proto: schema: - $ref: "#/components/schemas/yorkie.v1.RemoveDocumentResponse" + $ref: '#/components/schemas/yorkie.v1.RemoveDocumentResponse' description: "" yorkie.v1.YorkieService.WatchDocument.yorkie.v1.WatchDocumentResponse: description: "" schemas: connect.error: additionalProperties: false - description: "Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation" + description: 'Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation' properties: code: enum: - - CodeCanceled - - CodeUnknown - - CodeInvalidArgument - - CodeDeadlineExceeded - - CodeNotFound - - CodeAlreadyExists - - CodePermissionDenied - - CodeResourceExhausted - - CodeFailedPrecondition - - CodeAborted - - CodeOutOfRange - - CodeInternal - - CodeUnavailable - - CodeDataLoss - - CodeUnauthenticated + - CodeCanceled + - CodeUnknown + - CodeInvalidArgument + - CodeDeadlineExceeded + - CodeNotFound + - CodeAlreadyExists + - CodePermissionDenied + - CodeResourceExhausted + - CodeFailedPrecondition + - CodeAborted + - CodeOutOfRange + - CodeInternal + - CodeUnavailable + - CodeDataLoss + - CodeUnauthenticated examples: - - CodeNotFound + - CodeNotFound type: string message: type: string @@ -306,7 +305,7 @@ components: description: "" properties: changePack: - $ref: "#/components/schemas/yorkie.v1.ChangePack" + $ref: '#/components/schemas/yorkie.v1.ChangePack' additionalProperties: false description: "" title: change_pack @@ -323,7 +322,7 @@ components: description: "" properties: changePack: - $ref: "#/components/schemas/yorkie.v1.ChangePack" + $ref: '#/components/schemas/yorkie.v1.ChangePack' additionalProperties: false description: "" title: change_pack @@ -372,7 +371,7 @@ components: description: "" properties: id: - $ref: "#/components/schemas/yorkie.v1.ChangeID" + $ref: '#/components/schemas/yorkie.v1.ChangeID' additionalProperties: false description: "" title: id @@ -386,12 +385,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.Operation" + $ref: '#/components/schemas/yorkie.v1.Operation' type: object title: operations type: array presenceChange: - $ref: "#/components/schemas/yorkie.v1.PresenceChange" + $ref: '#/components/schemas/yorkie.v1.PresenceChange' additionalProperties: false description: "" title: presence_change @@ -417,15 +416,15 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: lamport serverSeq: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: server_seq title: ChangeID type: object @@ -439,12 +438,12 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.Change" + $ref: '#/components/schemas/yorkie.v1.Change' type: object title: changes type: array checkpoint: - $ref: "#/components/schemas/yorkie.v1.Checkpoint" + $ref: '#/components/schemas/yorkie.v1.Checkpoint' additionalProperties: false description: "" title: checkpoint @@ -460,7 +459,7 @@ components: title: is_removed type: boolean minSyncedTicket: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: min_synced_ticket @@ -486,8 +485,8 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: server_seq title: Checkpoint type: object @@ -512,7 +511,7 @@ components: description: "" properties: changePack: - $ref: "#/components/schemas/yorkie.v1.ChangePack" + $ref: '#/components/schemas/yorkie.v1.ChangePack' additionalProperties: false description: "" title: change_pack @@ -539,7 +538,7 @@ components: description: "" properties: changePack: - $ref: "#/components/schemas/yorkie.v1.ChangePack" + $ref: '#/components/schemas/yorkie.v1.ChangePack' additionalProperties: false description: "" title: change_pack @@ -551,7 +550,7 @@ components: description: "" properties: body: - $ref: "#/components/schemas/yorkie.v1.DocEventBody" + $ref: '#/components/schemas/yorkie.v1.DocEventBody' additionalProperties: false description: "" title: body @@ -562,7 +561,7 @@ components: title: publisher type: string type: - $ref: "#/components/schemas/yorkie.v1.DocEventType" + $ref: '#/components/schemas/yorkie.v1.DocEventType' additionalProperties: false description: "" title: type @@ -588,14 +587,14 @@ components: yorkie.v1.DocEventType: description: "" enum: - - - DOC_EVENT_TYPE_DOCUMENT_CHANGED - - 0 - - DOC_EVENT_TYPE_DOCUMENT_WATCHED - - 1 - - DOC_EVENT_TYPE_DOCUMENT_UNWATCHED - - 2 - - DOC_EVENT_TYPE_DOCUMENT_BROADCAST - - 3 + - - DOC_EVENT_TYPE_DOCUMENT_CHANGED + - 0 + - DOC_EVENT_TYPE_DOCUMENT_WATCHED + - 1 + - DOC_EVENT_TYPE_DOCUMENT_UNWATCHED + - 2 + - DOC_EVENT_TYPE_DOCUMENT_BROADCAST + - 3 title: DocEventType type: string yorkie.v1.JSONElementSimple: @@ -603,25 +602,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object movedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: moved_at type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at type: object type: - $ref: "#/components/schemas/yorkie.v1.ValueType" + $ref: '#/components/schemas/yorkie.v1.ValueType' additionalProperties: false description: "" title: type @@ -643,7 +642,7 @@ components: title: is_removed type: boolean updatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: updated_at @@ -660,67 +659,67 @@ components: description: "" properties: add: - $ref: "#/components/schemas/yorkie.v1.Operation.Add" + $ref: '#/components/schemas/yorkie.v1.Operation.Add' additionalProperties: false description: "" title: add type: object arraySet: - $ref: "#/components/schemas/yorkie.v1.Operation.ArraySet" + $ref: '#/components/schemas/yorkie.v1.Operation.ArraySet' additionalProperties: false description: "" title: array_set type: object edit: - $ref: "#/components/schemas/yorkie.v1.Operation.Edit" + $ref: '#/components/schemas/yorkie.v1.Operation.Edit' additionalProperties: false description: "" title: edit type: object increase: - $ref: "#/components/schemas/yorkie.v1.Operation.Increase" + $ref: '#/components/schemas/yorkie.v1.Operation.Increase' additionalProperties: false description: "" title: increase type: object move: - $ref: "#/components/schemas/yorkie.v1.Operation.Move" + $ref: '#/components/schemas/yorkie.v1.Operation.Move' additionalProperties: false description: "" title: move type: object remove: - $ref: "#/components/schemas/yorkie.v1.Operation.Remove" + $ref: '#/components/schemas/yorkie.v1.Operation.Remove' additionalProperties: false description: "" title: remove type: object select: - $ref: "#/components/schemas/yorkie.v1.Operation.Select" + $ref: '#/components/schemas/yorkie.v1.Operation.Select' additionalProperties: false description: "" title: select type: object set: - $ref: "#/components/schemas/yorkie.v1.Operation.Set" + $ref: '#/components/schemas/yorkie.v1.Operation.Set' additionalProperties: false description: "" title: set type: object style: - $ref: "#/components/schemas/yorkie.v1.Operation.Style" + $ref: '#/components/schemas/yorkie.v1.Operation.Style' additionalProperties: false description: "" title: style type: object treeEdit: - $ref: "#/components/schemas/yorkie.v1.Operation.TreeEdit" + $ref: '#/components/schemas/yorkie.v1.Operation.TreeEdit' additionalProperties: false description: "" title: tree_edit type: object treeStyle: - $ref: "#/components/schemas/yorkie.v1.Operation.TreeStyle" + $ref: '#/components/schemas/yorkie.v1.Operation.TreeStyle' additionalProperties: false description: "" title: tree_style @@ -732,25 +731,25 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object prevCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: prev_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -762,25 +761,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -807,25 +806,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -858,7 +857,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -870,19 +869,19 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -894,25 +893,25 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object prevCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: prev_created_at @@ -924,19 +923,19 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at @@ -952,25 +951,25 @@ components: compatibility purposes. properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -982,7 +981,7 @@ components: description: "" properties: executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at @@ -993,13 +992,13 @@ components: title: key type: string parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object value: - $ref: "#/components/schemas/yorkie.v1.JSONElementSimple" + $ref: '#/components/schemas/yorkie.v1.JSONElementSimple' additionalProperties: false description: "" title: value @@ -1021,25 +1020,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TextNodePos" + $ref: '#/components/schemas/yorkie.v1.TextNodePos' additionalProperties: false description: "" title: to @@ -1072,7 +1071,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1087,7 +1086,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.TreeNodes" + $ref: '#/components/schemas/yorkie.v1.TreeNodes' type: object title: contents type: array @@ -1097,19 +1096,19 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at @@ -1120,7 +1119,7 @@ components: title: split_level type: integer to: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: to @@ -1137,7 +1136,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1166,25 +1165,25 @@ components: title: created_at_map_by_actor type: object executedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: executed_at type: object from: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: from type: object parentCreatedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: parent_created_at type: object to: - $ref: "#/components/schemas/yorkie.v1.TreePos" + $ref: '#/components/schemas/yorkie.v1.TreePos' additionalProperties: false description: "" title: to @@ -1217,7 +1216,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: value @@ -1256,13 +1255,13 @@ components: description: "" properties: presence: - $ref: "#/components/schemas/yorkie.v1.Presence" + $ref: '#/components/schemas/yorkie.v1.Presence' additionalProperties: false description: "" title: presence type: object type: - $ref: "#/components/schemas/yorkie.v1.PresenceChange.ChangeType" + $ref: '#/components/schemas/yorkie.v1.PresenceChange.ChangeType' additionalProperties: false description: "" title: type @@ -1271,14 +1270,14 @@ components: yorkie.v1.PresenceChange.ChangeType: description: "" enum: - - - CHANGE_TYPE_UNSPECIFIED - - 0 - - CHANGE_TYPE_PUT - - 1 - - CHANGE_TYPE_DELETE - - 2 - - CHANGE_TYPE_CLEAR - - 3 + - - CHANGE_TYPE_UNSPECIFIED + - 0 + - CHANGE_TYPE_PUT + - 1 + - CHANGE_TYPE_DELETE + - 2 + - CHANGE_TYPE_CLEAR + - 3 title: ChangeType type: string yorkie.v1.PushPullChangesRequest: @@ -1286,7 +1285,7 @@ components: description: "" properties: changePack: - $ref: "#/components/schemas/yorkie.v1.ChangePack" + $ref: '#/components/schemas/yorkie.v1.ChangePack' additionalProperties: false description: "" title: change_pack @@ -1313,7 +1312,7 @@ components: description: "" properties: changePack: - $ref: "#/components/schemas/yorkie.v1.ChangePack" + $ref: '#/components/schemas/yorkie.v1.ChangePack' additionalProperties: false description: "" title: change_pack @@ -1325,7 +1324,7 @@ components: description: "" properties: changePack: - $ref: "#/components/schemas/yorkie.v1.ChangePack" + $ref: '#/components/schemas/yorkie.v1.ChangePack' additionalProperties: false description: "" title: change_pack @@ -1347,7 +1346,7 @@ components: description: "" properties: changePack: - $ref: "#/components/schemas/yorkie.v1.ChangePack" + $ref: '#/components/schemas/yorkie.v1.ChangePack' additionalProperties: false description: "" title: change_pack @@ -1359,7 +1358,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at @@ -1395,8 +1394,8 @@ components: additionalProperties: false description: "" oneOf: - - type: string - - type: number + - type: string + - type: number title: lamport title: TimeTicket type: object @@ -1415,25 +1414,25 @@ components: title: depth type: integer id: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: id type: object insNextId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: ins_next_id type: object insPrevId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: ins_prev_id type: object removedAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: removed_at @@ -1460,7 +1459,7 @@ components: title: key type: string value: - $ref: "#/components/schemas/yorkie.v1.NodeAttr" + $ref: '#/components/schemas/yorkie.v1.NodeAttr' additionalProperties: false description: "" title: value @@ -1472,7 +1471,7 @@ components: description: "" properties: createdAt: - $ref: "#/components/schemas/yorkie.v1.TimeTicket" + $ref: '#/components/schemas/yorkie.v1.TimeTicket' additionalProperties: false description: "" title: created_at @@ -1492,7 +1491,7 @@ components: additionalProperties: false description: "" items: - $ref: "#/components/schemas/yorkie.v1.TreeNode" + $ref: '#/components/schemas/yorkie.v1.TreeNode' type: object title: content type: array @@ -1503,13 +1502,13 @@ components: description: "" properties: leftSiblingId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: left_sibling_id type: object parentId: - $ref: "#/components/schemas/yorkie.v1.TreeNodeID" + $ref: '#/components/schemas/yorkie.v1.TreeNodeID' additionalProperties: false description: "" title: parent_id @@ -1519,34 +1518,34 @@ components: yorkie.v1.ValueType: description: "" enum: - - - VALUE_TYPE_NULL - - 0 - - VALUE_TYPE_BOOLEAN - - 1 - - VALUE_TYPE_INTEGER - - 2 - - VALUE_TYPE_LONG - - 3 - - VALUE_TYPE_DOUBLE - - 4 - - VALUE_TYPE_STRING - - 5 - - VALUE_TYPE_BYTES - - 6 - - VALUE_TYPE_DATE - - 7 - - VALUE_TYPE_JSON_OBJECT - - 8 - - VALUE_TYPE_JSON_ARRAY - - 9 - - VALUE_TYPE_TEXT - - 10 - - VALUE_TYPE_INTEGER_CNT - - 11 - - VALUE_TYPE_LONG_CNT - - 12 - - VALUE_TYPE_TREE - - 13 + - - VALUE_TYPE_NULL + - 0 + - VALUE_TYPE_BOOLEAN + - 1 + - VALUE_TYPE_INTEGER + - 2 + - VALUE_TYPE_LONG + - 3 + - VALUE_TYPE_DOUBLE + - 4 + - VALUE_TYPE_STRING + - 5 + - VALUE_TYPE_BYTES + - 6 + - VALUE_TYPE_DATE + - 7 + - VALUE_TYPE_JSON_OBJECT + - 8 + - VALUE_TYPE_JSON_ARRAY + - 9 + - VALUE_TYPE_TEXT + - 10 + - VALUE_TYPE_INTEGER_CNT + - 11 + - VALUE_TYPE_LONG_CNT + - 12 + - VALUE_TYPE_TREE + - 13 title: ValueType type: string yorkie.v1.WatchDocumentRequest: @@ -1570,13 +1569,13 @@ components: description: "" properties: event: - $ref: "#/components/schemas/yorkie.v1.DocEvent" + $ref: '#/components/schemas/yorkie.v1.DocEvent' additionalProperties: false description: "" title: event type: object initialization: - $ref: "#/components/schemas/yorkie.v1.WatchDocumentResponse.Initialization" + $ref: '#/components/schemas/yorkie.v1.WatchDocumentResponse.Initialization' additionalProperties: false description: "" title: initialization @@ -1602,7 +1601,7 @@ components: name: Authorization type: apiKey security: - - ApiKeyAuth: [] +- ApiKeyAuth: [] tags: - - description: Yorkie is a service that provides a API for SDKs. - name: yorkie.v1.YorkieService +- description: Yorkie is a service that provides an API for SDKs. + name: yorkie.v1.YorkieService diff --git a/api/yorkie/v1/system.pb.go b/api/yorkie/v1/system.pb.go new file mode 100644 index 000000000..a99485a94 --- /dev/null +++ b/api/yorkie/v1/system.pb.go @@ -0,0 +1,256 @@ +// +// 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: yorkie/v1/system.proto + +package v1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type DetachDocumentRequestBySystem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // TODO(hackerwins): Consider to replace this fields with types.Project, types.Client, types.DocumentSummary + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + DocumentId string `protobuf:"bytes,3,opt,name=document_id,json=documentId,proto3" json:"document_id,omitempty"` + DocumentKey string `protobuf:"bytes,4,opt,name=document_key,json=documentKey,proto3" json:"document_key,omitempty"` +} + +func (x *DetachDocumentRequestBySystem) Reset() { + *x = DetachDocumentRequestBySystem{} + if protoimpl.UnsafeEnabled { + mi := &file_yorkie_v1_system_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DetachDocumentRequestBySystem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DetachDocumentRequestBySystem) ProtoMessage() {} + +func (x *DetachDocumentRequestBySystem) ProtoReflect() protoreflect.Message { + mi := &file_yorkie_v1_system_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DetachDocumentRequestBySystem.ProtoReflect.Descriptor instead. +func (*DetachDocumentRequestBySystem) Descriptor() ([]byte, []int) { + return file_yorkie_v1_system_proto_rawDescGZIP(), []int{0} +} + +func (x *DetachDocumentRequestBySystem) GetProjectId() string { + if x != nil { + return x.ProjectId + } + return "" +} + +func (x *DetachDocumentRequestBySystem) GetClientId() string { + if x != nil { + return x.ClientId + } + return "" +} + +func (x *DetachDocumentRequestBySystem) GetDocumentId() string { + if x != nil { + return x.DocumentId + } + return "" +} + +func (x *DetachDocumentRequestBySystem) GetDocumentKey() string { + if x != nil { + return x.DocumentKey + } + return "" +} + +type DetachDocumentResponseBySystem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DetachDocumentResponseBySystem) Reset() { + *x = DetachDocumentResponseBySystem{} + if protoimpl.UnsafeEnabled { + mi := &file_yorkie_v1_system_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DetachDocumentResponseBySystem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DetachDocumentResponseBySystem) ProtoMessage() {} + +func (x *DetachDocumentResponseBySystem) ProtoReflect() protoreflect.Message { + mi := &file_yorkie_v1_system_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DetachDocumentResponseBySystem.ProtoReflect.Descriptor instead. +func (*DetachDocumentResponseBySystem) Descriptor() ([]byte, []int) { + return file_yorkie_v1_system_proto_rawDescGZIP(), []int{1} +} + +var File_yorkie_v1_system_proto protoreflect.FileDescriptor + +var file_yorkie_v1_system_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, + 0x2e, 0x76, 0x31, 0x22, 0x9f, 0x01, 0x0a, 0x1d, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x79, 0x53, + 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x20, 0x0a, 0x1e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x79, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x32, 0x78, 0x0a, 0x0d, 0x53, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x67, 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, + 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x2e, 0x79, 0x6f, 0x72, + 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x79, 0x53, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x29, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x79, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x22, + 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x65, 0x61, 0x6d, + 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x79, 0x6f, 0x72, 0x6b, + 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_yorkie_v1_system_proto_rawDescOnce sync.Once + file_yorkie_v1_system_proto_rawDescData = file_yorkie_v1_system_proto_rawDesc +) + +func file_yorkie_v1_system_proto_rawDescGZIP() []byte { + file_yorkie_v1_system_proto_rawDescOnce.Do(func() { + file_yorkie_v1_system_proto_rawDescData = protoimpl.X.CompressGZIP(file_yorkie_v1_system_proto_rawDescData) + }) + return file_yorkie_v1_system_proto_rawDescData +} + +var file_yorkie_v1_system_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_yorkie_v1_system_proto_goTypes = []interface{}{ + (*DetachDocumentRequestBySystem)(nil), // 0: yorkie.v1.DetachDocumentRequestBySystem + (*DetachDocumentResponseBySystem)(nil), // 1: yorkie.v1.DetachDocumentResponseBySystem +} +var file_yorkie_v1_system_proto_depIdxs = []int32{ + 0, // 0: yorkie.v1.SystemService.DetachDocument:input_type -> yorkie.v1.DetachDocumentRequestBySystem + 1, // 1: yorkie.v1.SystemService.DetachDocument:output_type -> yorkie.v1.DetachDocumentResponseBySystem + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_yorkie_v1_system_proto_init() } +func file_yorkie_v1_system_proto_init() { + if File_yorkie_v1_system_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_yorkie_v1_system_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DetachDocumentRequestBySystem); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_yorkie_v1_system_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DetachDocumentResponseBySystem); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_yorkie_v1_system_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_yorkie_v1_system_proto_goTypes, + DependencyIndexes: file_yorkie_v1_system_proto_depIdxs, + MessageInfos: file_yorkie_v1_system_proto_msgTypes, + }.Build() + File_yorkie_v1_system_proto = out.File + file_yorkie_v1_system_proto_rawDesc = nil + file_yorkie_v1_system_proto_goTypes = nil + file_yorkie_v1_system_proto_depIdxs = nil +} diff --git a/api/yorkie/v1/system.proto b/api/yorkie/v1/system.proto new file mode 100644 index 000000000..c9cafc0ec --- /dev/null +++ b/api/yorkie/v1/system.proto @@ -0,0 +1,38 @@ +/* + * 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. + */ +syntax = "proto3"; + +package yorkie.v1; + +option go_package = "github.com/yorkie-team/yorkie/api/yorkie/v1;v1"; + +option java_multiple_files = true; +option java_package = "dev.yorkie.api.v1"; + +// System is a service that provides an API for Cluster. +service SystemService { + rpc DetachDocument (DetachDocumentRequestBySystem) returns (DetachDocumentResponseBySystem) {} +} + +message DetachDocumentRequestBySystem { + // TODO(hackerwins): Consider to replace this fields with types.Project, types.Client, types.DocumentSummary + string project_id = 1; + string client_id = 2; + string document_id = 3; + string document_key = 4; +} + +message DetachDocumentResponseBySystem {} \ No newline at end of file diff --git a/api/yorkie/v1/v1connect/system.connect.go b/api/yorkie/v1/v1connect/system.connect.go new file mode 100644 index 000000000..d633829f2 --- /dev/null +++ b/api/yorkie/v1/v1connect/system.connect.go @@ -0,0 +1,120 @@ +// +// 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. + +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: yorkie/v1/system.proto + +package v1connect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + v1 "github.com/yorkie-team/yorkie/api/yorkie/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion0_1_0 + +const ( + // SystemServiceName is the fully-qualified name of the SystemService service. + SystemServiceName = "yorkie.v1.SystemService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // SystemServiceDetachDocumentProcedure is the fully-qualified name of the SystemService's + // DetachDocument RPC. + SystemServiceDetachDocumentProcedure = "/yorkie.v1.SystemService/DetachDocument" +) + +// SystemServiceClient is a client for the yorkie.v1.SystemService service. +type SystemServiceClient interface { + DetachDocument(context.Context, *connect.Request[v1.DetachDocumentRequestBySystem]) (*connect.Response[v1.DetachDocumentResponseBySystem], error) +} + +// NewSystemServiceClient constructs a client for the yorkie.v1.SystemService service. By default, +// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and +// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() +// or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewSystemServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SystemServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &systemServiceClient{ + detachDocument: connect.NewClient[v1.DetachDocumentRequestBySystem, v1.DetachDocumentResponseBySystem]( + httpClient, + baseURL+SystemServiceDetachDocumentProcedure, + opts..., + ), + } +} + +// systemServiceClient implements SystemServiceClient. +type systemServiceClient struct { + detachDocument *connect.Client[v1.DetachDocumentRequestBySystem, v1.DetachDocumentResponseBySystem] +} + +// DetachDocument calls yorkie.v1.SystemService.DetachDocument. +func (c *systemServiceClient) DetachDocument(ctx context.Context, req *connect.Request[v1.DetachDocumentRequestBySystem]) (*connect.Response[v1.DetachDocumentResponseBySystem], error) { + return c.detachDocument.CallUnary(ctx, req) +} + +// SystemServiceHandler is an implementation of the yorkie.v1.SystemService service. +type SystemServiceHandler interface { + DetachDocument(context.Context, *connect.Request[v1.DetachDocumentRequestBySystem]) (*connect.Response[v1.DetachDocumentResponseBySystem], error) +} + +// NewSystemServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewSystemServiceHandler(svc SystemServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + systemServiceDetachDocumentHandler := connect.NewUnaryHandler( + SystemServiceDetachDocumentProcedure, + svc.DetachDocument, + opts..., + ) + return "/yorkie.v1.SystemService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case SystemServiceDetachDocumentProcedure: + systemServiceDetachDocumentHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedSystemServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedSystemServiceHandler struct{} + +func (UnimplementedSystemServiceHandler) DetachDocument(context.Context, *connect.Request[v1.DetachDocumentRequestBySystem]) (*connect.Response[v1.DetachDocumentResponseBySystem], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("yorkie.v1.SystemService.DetachDocument is not implemented")) +} diff --git a/api/yorkie/v1/yorkie.proto b/api/yorkie/v1/yorkie.proto index 8ca20e120..876dc066a 100644 --- a/api/yorkie/v1/yorkie.proto +++ b/api/yorkie/v1/yorkie.proto @@ -24,7 +24,7 @@ option go_package = "github.com/yorkie-team/yorkie/api/yorkie/v1;v1"; option java_multiple_files = true; option java_package = "dev.yorkie.api.v1"; -// Yorkie is a service that provides a API for SDKs. +// Yorkie is a service that provides an API for SDKs. service YorkieService { rpc ActivateClient (ActivateClientRequest) returns (ActivateClientResponse) {} rpc DeactivateClient (DeactivateClientRequest) returns (DeactivateClientResponse) {} diff --git a/pkg/document/document.go b/pkg/document/document.go index 00b0e0411..da34d265a 100644 --- a/pkg/document/document.go +++ b/pkg/document/document.go @@ -454,6 +454,10 @@ func (d *Document) BroadcastEventHandlers() map[string]func( return d.broadcastEventHandlers } +func (d *Document) setInternalDoc(internalDoc *InternalDocument) { + d.doc = internalDoc +} + func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { if len(msgAndArgs) == 0 { return "" diff --git a/pkg/document/internal_document.go b/pkg/document/internal_document.go index 40697b809..66f4cdca1 100644 --- a/pkg/document/internal_document.go +++ b/pkg/document/internal_document.go @@ -372,3 +372,10 @@ func (d *InternalDocument) AddOnlineClient(clientID string) { func (d *InternalDocument) RemoveOnlineClient(clientID string) { d.onlineClients.Delete(clientID) } + +// ToDocument converts this document to Document. +func (d *InternalDocument) ToDocument() *Document { + doc := New(d.key) + doc.setInternalDoc(d) + return doc +} diff --git a/server/backend/database/client_info.go b/server/backend/database/client_info.go index f61c81769..5143cb435 100644 --- a/server/backend/database/client_info.go +++ b/server/backend/database/client_info.go @@ -200,6 +200,17 @@ func (i *ClientInfo) UpdateCheckpoint( return nil } +// ServerSeq returns the server sequence of the given document. +func (i *ClientInfo) ServerSeq( + docID types.ID, +) (int64, error) { + if !i.hasDocument(docID) { + return 0, fmt.Errorf("document not found %s: %w", docID, ErrDocumentNotFound) + } + + return i.Documents[docID].ServerSeq, nil +} + // EnsureActivated ensures the client is activated. func (i *ClientInfo) EnsureActivated() error { if i.Status != ClientActivated { diff --git a/server/backend/database/mongo/client.go b/server/backend/database/mongo/client.go index 16ec85b63..fbf6cf527 100644 --- a/server/backend/database/mongo/client.go +++ b/server/backend/database/mongo/client.go @@ -554,34 +554,10 @@ func (c *Client) DeactivateClient(ctx context.Context, refKey types.ClientRefKey res := c.collection(ColClients).FindOneAndUpdate(ctx, bson.M{ "project_id": refKey.ProjectID, "_id": refKey.ClientID, - }, bson.A{ - bson.M{ - "$set": bson.M{ - "status": database.ClientDeactivated, - "updated_at": gotime.Now(), - "documents": bson.M{ - "$arrayToObject": bson.M{ - "$map": bson.M{ - "input": bson.M{"$objectToArray": "$documents"}, - "as": "doc", - "in": bson.M{ - "k": "$$doc.k", - "v": bson.M{ - "$cond": bson.M{ - "if": bson.M{"$eq": bson.A{"$$doc.v.status", database.DocumentAttached}}, - "then": bson.M{ - "client_seq": 0, - "server_seq": 0, - "status": database.DocumentDetached, - }, - "else": "$$doc.v", - }, - }, - }, - }, - }, - }, - }, + }, bson.M{ + "$set": bson.M{ + "status": database.ClientDeactivated, + "updated_at": gotime.Now(), }, }, options.FindOneAndUpdate().SetReturnDocument(options.After)) diff --git a/server/clients/clients.go b/server/clients/clients.go index 83049d54d..0721c4e9c 100644 --- a/server/clients/clients.go +++ b/server/clients/clients.go @@ -23,6 +23,7 @@ import ( "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/server/backend/database" + "github.com/yorkie-team/yorkie/system" ) var ( @@ -47,41 +48,50 @@ func Activate( func Deactivate( ctx context.Context, db database.Database, + project *types.Project, refKey types.ClientRefKey, ) (*database.ClientInfo, error) { - // TODO(hackerwins): We need to remove the presence of the client from the document. - // Be careful that housekeeping is executed by the leader. And documents are sharded - // by the servers in the cluster. So, we need to consider the case where the leader is - // not the same as the server that handles the document. - - // TODO(raararaara): When deactivating a client, we need to update three DB properties - // (ClientInfo.Status, ClientInfo.Documents, SyncedSeq) in DB. - // Updating the sub-properties of ClientInfo guarantees atomicity as it involves a single MongoDB document. - // However, SyncedSeqs are stored in separate documents, so we can't ensure atomic updates for both. - // Currently, if SyncedSeqs update fails, it mainly impacts GC efficiency without causing major issues. - // We need to consider implementing a correction logic to remove SyncedSeqs in the future. - clientInfo, err := db.DeactivateClient(ctx, refKey) + info, err := FindActiveClientInfo(ctx, db, refKey) + if err != nil { + return nil, err + } + + // TODO(hackerwins): Inject gatewayAddr + systemClient, err := system.Dial("localhost:8080") if err != nil { return nil, err } - // TODO(raararaara): We're currently updating SyncedSeq one by one. This approach is similar - // to n+1 query problem. We need to investigate if we can optimize this process by using a single query in the future. - for docID, clientDocInfo := range clientInfo.Documents { - if err := db.UpdateSyncedSeq( - ctx, - clientInfo, - types.DocRefKey{ - ProjectID: refKey.ProjectID, - DocID: docID, - }, - clientDocInfo.ServerSeq, - ); err != nil { + for docID, clientDocInfo := range info.Documents { + // TODO(hackerwins): Solve N+1 + if clientDocInfo.Status == database.DocumentDetached { + continue + } + + docInfo, err := db.FindDocInfoByRefKey(ctx, types.DocRefKey{ + ProjectID: project.ID, + DocID: docID, + }) + if err != nil { return nil, err } + + actorID, err := info.ID.ToActorID() + if err != nil { + return nil, err + } + + if err := systemClient.DetachDocument(ctx, project.ID, actorID, docID, project.PublicKey, docInfo.Key); err != nil { + return nil, err + } + } + + info, err = db.DeactivateClient(ctx, refKey) + if err != nil { + return nil, err } - return clientInfo, err + return info, err } // FindActiveClientInfo find the active client info by the given ref key. diff --git a/server/clients/housekeeping.go b/server/clients/housekeeping.go index 76ab28bd8..ed1b00254 100644 --- a/server/clients/housekeeping.go +++ b/server/clients/housekeeping.go @@ -68,8 +68,8 @@ func DeactivateInactives( } deactivatedCount := 0 - for _, clientInfo := range candidates { - if _, err := Deactivate(ctx, be.DB, clientInfo.RefKey()); err != nil { + for _, pair := range candidates { + if _, err := Deactivate(ctx, be.DB, pair.project.ToProject(), pair.client.RefKey()); err != nil { return database.DefaultProjectID, err } @@ -88,6 +88,12 @@ func DeactivateInactives( return lastProjectID, nil } +// CandidatePair represents a pair of project and client. +type CandidatePair struct { + project *database.ProjectInfo + client *database.ClientInfo +} + // FindDeactivateCandidates finds candidates to deactivate from the database. func FindDeactivateCandidates( ctx context.Context, @@ -95,27 +101,32 @@ func FindDeactivateCandidates( candidatesLimitPerProject int, projectFetchSize int, lastProjectID types.ID, -) (types.ID, []*database.ClientInfo, error) { - projects, err := be.DB.FindNextNCyclingProjectInfos(ctx, projectFetchSize, lastProjectID) +) (types.ID, []CandidatePair, error) { + projectInfos, err := be.DB.FindNextNCyclingProjectInfos(ctx, projectFetchSize, lastProjectID) if err != nil { return database.DefaultProjectID, nil, err } - var candidates []*database.ClientInfo - for _, project := range projects { - infos, err := be.DB.FindDeactivateCandidatesPerProject(ctx, project, candidatesLimitPerProject) + var candidates []CandidatePair + for _, projectInfo := range projectInfos { + infos, err := be.DB.FindDeactivateCandidatesPerProject(ctx, projectInfo, candidatesLimitPerProject) if err != nil { return database.DefaultProjectID, nil, err } - candidates = append(candidates, infos...) + for _, info := range infos { + candidates = append(candidates, CandidatePair{ + project: projectInfo, + client: info, + }) + } } var topProjectID types.ID - if len(projects) < projectFetchSize { + if len(projectInfos) < projectFetchSize { topProjectID = database.DefaultProjectID } else { - topProjectID = projects[len(projects)-1].ID + topProjectID = projectInfos[len(projectInfos)-1].ID } return topProjectID, candidates, nil diff --git a/server/rpc/server.go b/server/rpc/server.go index cfd06ad88..b204f4784 100644 --- a/server/rpc/server.go +++ b/server/rpc/server.go @@ -73,6 +73,7 @@ func NewServer(conf *Config, be *backend.Backend) (*Server, error) { mux := http.NewServeMux() mux.Handle(v1connect.NewYorkieServiceHandler(newYorkieServer(yorkieServiceCtx, be), opts...)) mux.Handle(v1connect.NewAdminServiceHandler(newAdminServer(be, tokenManager), opts...)) + mux.Handle(v1connect.NewSystemServiceHandler(newSystemServer(be))) mux.Handle(grpchealth.NewHandler(healthChecker)) mux.Handle(httphealth.NewHandler(healthChecker)) // TODO(hackerwins): We need to provide proper http server configuration. diff --git a/server/rpc/system_server.go b/server/rpc/system_server.go new file mode 100644 index 000000000..e209542b9 --- /dev/null +++ b/server/rpc/system_server.go @@ -0,0 +1,137 @@ +/* + * Copyright 2024 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 rpc + +import ( + "context" + + "connectrpc.com/connect" + + "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" + "github.com/yorkie-team/yorkie/pkg/document/json" + "github.com/yorkie-team/yorkie/pkg/document/key" + "github.com/yorkie-team/yorkie/pkg/document/presence" + "github.com/yorkie-team/yorkie/pkg/document/time" + "github.com/yorkie-team/yorkie/server/backend" + "github.com/yorkie-team/yorkie/server/clients" + "github.com/yorkie-team/yorkie/server/documents" + "github.com/yorkie-team/yorkie/server/logging" + "github.com/yorkie-team/yorkie/server/packs" +) + +type systemServer struct { + backend *backend.Backend +} + +// newSystemServer creates a new instance of systemServer. +func newSystemServer(backend *backend.Backend) *systemServer { + return &systemServer{ + backend: backend, + } +} + +// DetachDocument detaches the given document from the given client. +func (s *systemServer) DetachDocument( + ctx context.Context, + req *connect.Request[api.DetachDocumentRequestBySystem], +) (*connect.Response[api.DetachDocumentResponseBySystem], error) { + actorID, err := time.ActorIDFromHex(req.Msg.ClientId) + if err != nil { + return nil, err + } + + docID, err := converter.FromDocumentID(req.Msg.DocumentId) + if err != nil { + return nil, err + } + + info, err := s.backend.DB.FindProjectInfoByID(ctx, types.ID(req.Msg.ProjectId)) + if err != nil { + return nil, err + } + project := info.ToProject() + + locker, err := s.backend.Coordinator.NewLocker(ctx, packs.PushPullKey(project.ID, key.Key(req.Msg.DocumentKey))) + if err != nil { + return nil, err + } + + if err := locker.Lock(ctx); err != nil { + return nil, err + } + defer func() { + if err := locker.Unlock(ctx); err != nil { + logging.DefaultLogger().Error(err) + } + }() + + clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend.DB, types.ClientRefKey{ + ProjectID: project.ID, + ClientID: types.IDFromActorID(actorID), + }) + if err != nil { + return nil, err + } + + docRefKey := types.DocRefKey{ + ProjectID: project.ID, + DocID: docID, + } + + docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, docRefKey) + if err != nil { + return nil, err + } + + serverSeq, err := clientInfo.ServerSeq(docID) + if err != nil { + return nil, err + } + + internalDoc, err := packs.BuildDocumentForServerSeq(ctx, s.backend, docInfo, serverSeq) + if err != nil { + return nil, err + } + + doc := internalDoc.ToDocument() + if err := doc.Update(func(root *json.Object, p *presence.Presence) error { + p.Clear() + return nil + }); err != nil { + return nil, err + } + + if _, err := packs.PushPull( + ctx, + s.backend, + project, + clientInfo, + docInfo, + doc.CreateChangePack(), + packs.PushPullOptions{ + Mode: types.SyncModePushPull, + Status: document.StatusDetached, + }, + ); err != nil { + return nil, err + } + + return connect.NewResponse(&api.DetachDocumentResponseBySystem{}), nil +} diff --git a/server/rpc/yorkie_server.go b/server/rpc/yorkie_server.go index 6303e58ea..71eddb794 100644 --- a/server/rpc/yorkie_server.go +++ b/server/rpc/yorkie_server.go @@ -94,7 +94,7 @@ func (s *yorkieServer) DeactivateClient( } project := projects.From(ctx) - _, err = clients.Deactivate(ctx, s.backend.DB, types.ClientRefKey{ + _, err = clients.Deactivate(ctx, s.backend.DB, project, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) diff --git a/server/server.go b/server/server.go index 6a777f5d5..5475a26c0 100644 --- a/server/server.go +++ b/server/server.go @@ -150,7 +150,7 @@ func (r *Yorkie) DeactivateClient(ctx context.Context, c1 *client.Client) error return err } - _, err = clients.Deactivate(ctx, r.backend.DB, types.ClientRefKey{ + _, err = clients.Deactivate(ctx, r.backend.DB, project, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(c1.ID()), }) diff --git a/system/client.go b/system/client.go new file mode 100644 index 000000000..22e25e82a --- /dev/null +++ b/system/client.go @@ -0,0 +1,161 @@ +/* + * Copyright 2024 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 system is a package for the system service. +package system + +import ( + "context" + "crypto/tls" + "fmt" + "net/http" + "strings" + + "connectrpc.com/connect" + "go.uber.org/zap" + "golang.org/x/net/http2" + + "github.com/yorkie-team/yorkie/api/types" + api "github.com/yorkie-team/yorkie/api/yorkie/v1" + "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" + "github.com/yorkie-team/yorkie/pkg/document/key" + "github.com/yorkie-team/yorkie/pkg/document/time" +) + +// Option configures Options. +type Option func(*Options) + +// WithLogger configures the Logger of the client. +func WithLogger(logger *zap.Logger) Option { + return func(o *Options) { o.Logger = logger } +} + +// WithInsecure configures insecure option of the client. +func WithInsecure(isInsecure bool) Option { + return func(o *Options) { o.IsInsecure = isInsecure } +} + +// Options configures how we set up the client. +type Options struct { + // Logger is the Logger of the client. + Logger *zap.Logger + + // IsInsecure is whether to disable the TLS connection of the client. + IsInsecure bool +} + +// Client is a client for admin service. +type Client struct { + conn *http.Client + client v1connect.SystemServiceClient + logger *zap.Logger +} + +// New creates an instance of Client. +func New(opts ...Option) (*Client, error) { + var options Options + for _, opt := range opts { + opt(&options) + } + + conn := &http.Client{} + if !options.IsInsecure { + tlsConfig := &tls.Config{MinVersion: tls.VersionTLS12} + conn.Transport = &http2.Transport{TLSClientConfig: tlsConfig} + } + + logger := options.Logger + if logger == nil { + l, err := zap.NewProduction() + if err != nil { + return nil, fmt.Errorf("create logger: %w", err) + } + logger = l + } + + return &Client{ + conn: conn, + logger: logger, + }, nil +} + +// Dial creates an instance of Client and dials to the admin service. +func Dial(rpcAddr string, opts ...Option) (*Client, error) { + cli, err := New(opts...) + if err != nil { + return nil, err + } + + if err := cli.Dial(rpcAddr); err != nil { + return nil, err + } + + return cli, nil +} + +// Dial dials to the admin service. +func (c *Client) Dial(rpcAddr string) error { + if !strings.Contains(rpcAddr, "://") { + if c.conn.Transport == nil { + rpcAddr = "http://" + rpcAddr + } else { + rpcAddr = "https://" + rpcAddr + } + } + + c.client = v1connect.NewSystemServiceClient(c.conn, rpcAddr) + + return nil +} + +// Close closes the connection to the admin service. +func (c *Client) Close() { + c.conn.CloseIdleConnections() +} + +// DetachDocument detaches the given document from the client. +func (c *Client) DetachDocument( + ctx context.Context, + projectID types.ID, + clientID *time.ActorID, + docID types.ID, + apiKey string, + docKey key.Key, +) error { + _, err := c.client.DetachDocument( + ctx, + withShardKey(connect.NewRequest(&api.DetachDocumentRequestBySystem{ + ProjectId: projectID.String(), + ClientId: clientID.String(), + DocumentId: docID.String(), + DocumentKey: docKey.String(), + }, + ), apiKey, docKey.String())) + if err != nil { + return err + } + + return nil +} + +/** +* withShardKey returns a context with the given shard key in metadata. + */ +func withShardKey[T any](conn *connect.Request[T], keys ...string) *connect.Request[T] { + conn.Header().Add(types.ShardKey, strings.Join(keys, "/")) + + return conn +} From e1782a33a6909416254bd2aa77127b08a7de61fb Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Wed, 16 Oct 2024 16:49:16 +0900 Subject: [PATCH 2/8] Add gateway flag to server command --- api/docs/yorkie/v1/system.openapi.yaml | 24 ++-- api/yorkie/v1/system.pb.go | 104 +++++++++--------- api/yorkie/v1/system.proto | 6 +- api/yorkie/v1/v1connect/system.connect.go | 12 +- cmd/yorkie/server.go | 6 + pkg/document/internal_document.go | 12 ++ server/backend/config.go | 3 + .../backend/database/testcases/testcases.go | 50 --------- server/clients/clients.go | 25 +++-- server/clients/housekeeping.go | 12 +- server/config.go | 3 +- server/config.sample.yml | 3 + server/documents/documents.go | 8 +- server/packs/packs.go | 23 +++- server/packs/pushpull.go | 2 +- server/rpc/system_server.go | 14 +-- server/rpc/yorkie_server.go | 2 +- server/server.go | 2 +- system/client.go | 2 +- test/helper/helper.go | 1 + test/integration/housekeeping_test.go | 7 +- 21 files changed, 156 insertions(+), 165 deletions(-) diff --git a/api/docs/yorkie/v1/system.openapi.yaml b/api/docs/yorkie/v1/system.openapi.yaml index 6f3b92d2f..67c21694d 100644 --- a/api/docs/yorkie/v1/system.openapi.yaml +++ b/api/docs/yorkie/v1/system.openapi.yaml @@ -14,24 +14,24 @@ paths: post: description: "" requestBody: - $ref: '#/components/requestBodies/yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentRequestBySystem' + $ref: '#/components/requestBodies/yorkie.v1.SystemService.DetachDocument.yorkie.v1.SystemServiceDetachDocumentRequest' responses: "200": - $ref: '#/components/responses/yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentResponseBySystem' + $ref: '#/components/responses/yorkie.v1.SystemService.DetachDocument.yorkie.v1.SystemServiceDetachDocumentResponse' default: $ref: '#/components/responses/connect.error' tags: - yorkie.v1.SystemService components: requestBodies: - yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentRequestBySystem: + yorkie.v1.SystemService.DetachDocument.yorkie.v1.SystemServiceDetachDocumentRequest: content: application/json: schema: - $ref: '#/components/schemas/yorkie.v1.DetachDocumentRequestBySystem' + $ref: '#/components/schemas/yorkie.v1.SystemServiceDetachDocumentRequest' application/proto: schema: - $ref: '#/components/schemas/yorkie.v1.DetachDocumentRequestBySystem' + $ref: '#/components/schemas/yorkie.v1.SystemServiceDetachDocumentRequest' required: true responses: connect.error: @@ -43,14 +43,14 @@ components: schema: $ref: '#/components/schemas/connect.error' description: "" - yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentResponseBySystem: + yorkie.v1.SystemService.DetachDocument.yorkie.v1.SystemServiceDetachDocumentResponse: content: application/json: schema: - $ref: '#/components/schemas/yorkie.v1.DetachDocumentResponseBySystem' + $ref: '#/components/schemas/yorkie.v1.SystemServiceDetachDocumentResponse' application/proto: schema: - $ref: '#/components/schemas/yorkie.v1.DetachDocumentResponseBySystem' + $ref: '#/components/schemas/yorkie.v1.SystemServiceDetachDocumentResponse' description: "" schemas: connect.error: @@ -81,7 +81,7 @@ components: type: string title: Connect Error type: object - yorkie.v1.DetachDocumentRequestBySystem: + yorkie.v1.SystemServiceDetachDocumentRequest: additionalProperties: false description: "" properties: @@ -106,12 +106,12 @@ components: types.Client, types.DocumentSummary' title: project_id type: string - title: DetachDocumentRequestBySystem + title: SystemServiceDetachDocumentRequest type: object - yorkie.v1.DetachDocumentResponseBySystem: + yorkie.v1.SystemServiceDetachDocumentResponse: additionalProperties: false description: "" - title: DetachDocumentResponseBySystem + title: SystemServiceDetachDocumentResponse type: object securitySchemes: ApiKeyAuth: diff --git a/api/yorkie/v1/system.pb.go b/api/yorkie/v1/system.pb.go index a99485a94..6106f5200 100644 --- a/api/yorkie/v1/system.pb.go +++ b/api/yorkie/v1/system.pb.go @@ -35,7 +35,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type DetachDocumentRequestBySystem struct { +type SystemServiceDetachDocumentRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -47,8 +47,8 @@ type DetachDocumentRequestBySystem struct { DocumentKey string `protobuf:"bytes,4,opt,name=document_key,json=documentKey,proto3" json:"document_key,omitempty"` } -func (x *DetachDocumentRequestBySystem) Reset() { - *x = DetachDocumentRequestBySystem{} +func (x *SystemServiceDetachDocumentRequest) Reset() { + *x = SystemServiceDetachDocumentRequest{} if protoimpl.UnsafeEnabled { mi := &file_yorkie_v1_system_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -56,13 +56,13 @@ func (x *DetachDocumentRequestBySystem) Reset() { } } -func (x *DetachDocumentRequestBySystem) String() string { +func (x *SystemServiceDetachDocumentRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DetachDocumentRequestBySystem) ProtoMessage() {} +func (*SystemServiceDetachDocumentRequest) ProtoMessage() {} -func (x *DetachDocumentRequestBySystem) ProtoReflect() protoreflect.Message { +func (x *SystemServiceDetachDocumentRequest) ProtoReflect() protoreflect.Message { mi := &file_yorkie_v1_system_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -74,47 +74,47 @@ func (x *DetachDocumentRequestBySystem) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DetachDocumentRequestBySystem.ProtoReflect.Descriptor instead. -func (*DetachDocumentRequestBySystem) Descriptor() ([]byte, []int) { +// Deprecated: Use SystemServiceDetachDocumentRequest.ProtoReflect.Descriptor instead. +func (*SystemServiceDetachDocumentRequest) Descriptor() ([]byte, []int) { return file_yorkie_v1_system_proto_rawDescGZIP(), []int{0} } -func (x *DetachDocumentRequestBySystem) GetProjectId() string { +func (x *SystemServiceDetachDocumentRequest) GetProjectId() string { if x != nil { return x.ProjectId } return "" } -func (x *DetachDocumentRequestBySystem) GetClientId() string { +func (x *SystemServiceDetachDocumentRequest) GetClientId() string { if x != nil { return x.ClientId } return "" } -func (x *DetachDocumentRequestBySystem) GetDocumentId() string { +func (x *SystemServiceDetachDocumentRequest) GetDocumentId() string { if x != nil { return x.DocumentId } return "" } -func (x *DetachDocumentRequestBySystem) GetDocumentKey() string { +func (x *SystemServiceDetachDocumentRequest) GetDocumentKey() string { if x != nil { return x.DocumentKey } return "" } -type DetachDocumentResponseBySystem struct { +type SystemServiceDetachDocumentResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *DetachDocumentResponseBySystem) Reset() { - *x = DetachDocumentResponseBySystem{} +func (x *SystemServiceDetachDocumentResponse) Reset() { + *x = SystemServiceDetachDocumentResponse{} if protoimpl.UnsafeEnabled { mi := &file_yorkie_v1_system_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -122,13 +122,13 @@ func (x *DetachDocumentResponseBySystem) Reset() { } } -func (x *DetachDocumentResponseBySystem) String() string { +func (x *SystemServiceDetachDocumentResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DetachDocumentResponseBySystem) ProtoMessage() {} +func (*SystemServiceDetachDocumentResponse) ProtoMessage() {} -func (x *DetachDocumentResponseBySystem) ProtoReflect() protoreflect.Message { +func (x *SystemServiceDetachDocumentResponse) ProtoReflect() protoreflect.Message { mi := &file_yorkie_v1_system_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -140,8 +140,8 @@ func (x *DetachDocumentResponseBySystem) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DetachDocumentResponseBySystem.ProtoReflect.Descriptor instead. -func (*DetachDocumentResponseBySystem) Descriptor() ([]byte, []int) { +// Deprecated: Use SystemServiceDetachDocumentResponse.ProtoReflect.Descriptor instead. +func (*SystemServiceDetachDocumentResponse) Descriptor() ([]byte, []int) { return file_yorkie_v1_system_proto_rawDescGZIP(), []int{1} } @@ -150,31 +150,33 @@ var File_yorkie_v1_system_proto protoreflect.FileDescriptor var file_yorkie_v1_system_proto_rawDesc = []byte{ 0x0a, 0x16, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, - 0x2e, 0x76, 0x31, 0x22, 0x9f, 0x01, 0x0a, 0x1d, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x79, 0x53, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, - 0x63, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, - 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6b, - 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x20, 0x0a, 0x1e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, - 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, - 0x79, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x32, 0x78, 0x0a, 0x0d, 0x53, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x67, 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, - 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x2e, 0x79, 0x6f, 0x72, - 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x79, 0x53, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x29, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x79, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x22, - 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x65, 0x61, 0x6d, - 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x79, 0x6f, 0x72, 0x6b, - 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x76, 0x31, 0x22, 0xa4, 0x01, 0x0a, 0x22, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, + 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, + 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x25, 0x0a, 0x23, 0x53, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, + 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x32, 0x82, 0x01, 0x0a, 0x0d, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, + 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, + 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, + 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, + 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, + 0x2d, 0x74, 0x65, 0x61, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -191,12 +193,12 @@ func file_yorkie_v1_system_proto_rawDescGZIP() []byte { var file_yorkie_v1_system_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_yorkie_v1_system_proto_goTypes = []interface{}{ - (*DetachDocumentRequestBySystem)(nil), // 0: yorkie.v1.DetachDocumentRequestBySystem - (*DetachDocumentResponseBySystem)(nil), // 1: yorkie.v1.DetachDocumentResponseBySystem + (*SystemServiceDetachDocumentRequest)(nil), // 0: yorkie.v1.SystemServiceDetachDocumentRequest + (*SystemServiceDetachDocumentResponse)(nil), // 1: yorkie.v1.SystemServiceDetachDocumentResponse } var file_yorkie_v1_system_proto_depIdxs = []int32{ - 0, // 0: yorkie.v1.SystemService.DetachDocument:input_type -> yorkie.v1.DetachDocumentRequestBySystem - 1, // 1: yorkie.v1.SystemService.DetachDocument:output_type -> yorkie.v1.DetachDocumentResponseBySystem + 0, // 0: yorkie.v1.SystemService.DetachDocument:input_type -> yorkie.v1.SystemServiceDetachDocumentRequest + 1, // 1: yorkie.v1.SystemService.DetachDocument:output_type -> yorkie.v1.SystemServiceDetachDocumentResponse 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -211,7 +213,7 @@ func file_yorkie_v1_system_proto_init() { } if !protoimpl.UnsafeEnabled { file_yorkie_v1_system_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DetachDocumentRequestBySystem); i { + switch v := v.(*SystemServiceDetachDocumentRequest); i { case 0: return &v.state case 1: @@ -223,7 +225,7 @@ func file_yorkie_v1_system_proto_init() { } } file_yorkie_v1_system_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DetachDocumentResponseBySystem); i { + switch v := v.(*SystemServiceDetachDocumentResponse); i { case 0: return &v.state case 1: diff --git a/api/yorkie/v1/system.proto b/api/yorkie/v1/system.proto index c9cafc0ec..70ef8b989 100644 --- a/api/yorkie/v1/system.proto +++ b/api/yorkie/v1/system.proto @@ -24,10 +24,10 @@ option java_package = "dev.yorkie.api.v1"; // System is a service that provides an API for Cluster. service SystemService { - rpc DetachDocument (DetachDocumentRequestBySystem) returns (DetachDocumentResponseBySystem) {} + rpc DetachDocument (SystemServiceDetachDocumentRequest) returns (SystemServiceDetachDocumentResponse) {} } -message DetachDocumentRequestBySystem { +message SystemServiceDetachDocumentRequest { // TODO(hackerwins): Consider to replace this fields with types.Project, types.Client, types.DocumentSummary string project_id = 1; string client_id = 2; @@ -35,4 +35,4 @@ message DetachDocumentRequestBySystem { string document_key = 4; } -message DetachDocumentResponseBySystem {} \ No newline at end of file +message SystemServiceDetachDocumentResponse {} \ No newline at end of file diff --git a/api/yorkie/v1/v1connect/system.connect.go b/api/yorkie/v1/v1connect/system.connect.go index d633829f2..e8557036e 100644 --- a/api/yorkie/v1/v1connect/system.connect.go +++ b/api/yorkie/v1/v1connect/system.connect.go @@ -55,7 +55,7 @@ const ( // SystemServiceClient is a client for the yorkie.v1.SystemService service. type SystemServiceClient interface { - DetachDocument(context.Context, *connect.Request[v1.DetachDocumentRequestBySystem]) (*connect.Response[v1.DetachDocumentResponseBySystem], error) + DetachDocument(context.Context, *connect.Request[v1.SystemServiceDetachDocumentRequest]) (*connect.Response[v1.SystemServiceDetachDocumentResponse], error) } // NewSystemServiceClient constructs a client for the yorkie.v1.SystemService service. By default, @@ -68,7 +68,7 @@ type SystemServiceClient interface { func NewSystemServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SystemServiceClient { baseURL = strings.TrimRight(baseURL, "/") return &systemServiceClient{ - detachDocument: connect.NewClient[v1.DetachDocumentRequestBySystem, v1.DetachDocumentResponseBySystem]( + detachDocument: connect.NewClient[v1.SystemServiceDetachDocumentRequest, v1.SystemServiceDetachDocumentResponse]( httpClient, baseURL+SystemServiceDetachDocumentProcedure, opts..., @@ -78,17 +78,17 @@ func NewSystemServiceClient(httpClient connect.HTTPClient, baseURL string, opts // systemServiceClient implements SystemServiceClient. type systemServiceClient struct { - detachDocument *connect.Client[v1.DetachDocumentRequestBySystem, v1.DetachDocumentResponseBySystem] + detachDocument *connect.Client[v1.SystemServiceDetachDocumentRequest, v1.SystemServiceDetachDocumentResponse] } // DetachDocument calls yorkie.v1.SystemService.DetachDocument. -func (c *systemServiceClient) DetachDocument(ctx context.Context, req *connect.Request[v1.DetachDocumentRequestBySystem]) (*connect.Response[v1.DetachDocumentResponseBySystem], error) { +func (c *systemServiceClient) DetachDocument(ctx context.Context, req *connect.Request[v1.SystemServiceDetachDocumentRequest]) (*connect.Response[v1.SystemServiceDetachDocumentResponse], error) { return c.detachDocument.CallUnary(ctx, req) } // SystemServiceHandler is an implementation of the yorkie.v1.SystemService service. type SystemServiceHandler interface { - DetachDocument(context.Context, *connect.Request[v1.DetachDocumentRequestBySystem]) (*connect.Response[v1.DetachDocumentResponseBySystem], error) + DetachDocument(context.Context, *connect.Request[v1.SystemServiceDetachDocumentRequest]) (*connect.Response[v1.SystemServiceDetachDocumentResponse], error) } // NewSystemServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -115,6 +115,6 @@ func NewSystemServiceHandler(svc SystemServiceHandler, opts ...connect.HandlerOp // UnimplementedSystemServiceHandler returns CodeUnimplemented from all methods. type UnimplementedSystemServiceHandler struct{} -func (UnimplementedSystemServiceHandler) DetachDocument(context.Context, *connect.Request[v1.DetachDocumentRequestBySystem]) (*connect.Response[v1.DetachDocumentResponseBySystem], error) { +func (UnimplementedSystemServiceHandler) DetachDocument(context.Context, *connect.Request[v1.SystemServiceDetachDocumentRequest]) (*connect.Response[v1.SystemServiceDetachDocumentResponse], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("yorkie.v1.SystemService.DetachDocument is not implemented")) } diff --git a/cmd/yorkie/server.go b/cmd/yorkie/server.go index cca3b91d5..54ea63094 100644 --- a/cmd/yorkie/server.go +++ b/cmd/yorkie/server.go @@ -345,6 +345,12 @@ func init() { server.DefaultHostname, "Yorkie Server Hostname", ) + cmd.Flags().StringVar( + &conf.Backend.GatewayAddr, + "backend-gateway-addr", + server.DefaultGatewayAddr, + "Gateway address", + ) rootCmd.AddCommand(cmd) } diff --git a/pkg/document/internal_document.go b/pkg/document/internal_document.go index 66f4cdca1..296b5e642 100644 --- a/pkg/document/internal_document.go +++ b/pkg/document/internal_document.go @@ -136,6 +136,18 @@ func (d *InternalDocument) Checkpoint() change.Checkpoint { return d.checkpoint } +// SyncCheckpoint syncs the checkpoint and the changeID with the given serverSeq +// and clientSeq. +func (d *InternalDocument) SyncCheckpoint(serverSeq int64, clientSeq uint32) { + d.changeID = change.NewID( + clientSeq, + serverSeq, + d.changeID.Lamport(), + d.changeID.ActorID(), + ) + d.checkpoint = d.checkpoint.SyncClientSeq(clientSeq) +} + // HasLocalChanges returns whether this document has local changes or not. func (d *InternalDocument) HasLocalChanges() bool { return len(d.localChanges) > 0 diff --git a/server/backend/config.go b/server/backend/config.go index 38d87b2d3..8b5cbc511 100644 --- a/server/backend/config.go +++ b/server/backend/config.go @@ -81,6 +81,9 @@ type Config struct { // Hostname is yorkie server hostname. hostname is used by metrics. Hostname string `yaml:"Hostname"` + + // GatewayAddr is the address of the gateway server. + GatewayAddr string `yaml:"GatewayAddr"` } // Validate validates this config. diff --git a/server/backend/database/testcases/testcases.go b/server/backend/database/testcases/testcases.go index 2108f8c83..839bbc43f 100644 --- a/server/backend/database/testcases/testcases.go +++ b/server/backend/database/testcases/testcases.go @@ -676,56 +676,6 @@ func RunActivateClientDeactivateClientTest(t *testing.T, db database.Database, p assert.Equal(t, t.Name(), clientInfo.Key) assert.Equal(t, database.ClientDeactivated, clientInfo.Status) }) - - t.Run("ensure document detached when deactivate client test", func(t *testing.T) { - ctx := context.Background() - - // 01. Create a client - clientInfo, err := db.ActivateClient(ctx, projectID, t.Name()) - assert.NoError(t, err) - assert.Equal(t, t.Name(), clientInfo.Key) - assert.Equal(t, database.ClientActivated, clientInfo.Status) - - // 02. Create documents and attach them to the client - for i := 0; i < 3; i++ { - docInfo, _ := db.FindDocInfoByKeyAndOwner(ctx, clientInfo.RefKey(), helper.TestDocKey(t, i), true) - assert.NoError(t, clientInfo.AttachDocument(docInfo.ID, false)) - clientInfo.Documents[docInfo.ID].ServerSeq = 1 - clientInfo.Documents[docInfo.ID].ClientSeq = 1 - assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) - - result, err := db.FindClientInfoByRefKey(ctx, clientInfo.RefKey()) - assert.Equal(t, result.Documents[docInfo.ID].Status, database.DocumentAttached) - assert.Equal(t, result.Documents[docInfo.ID].ServerSeq, int64(1)) - assert.Equal(t, result.Documents[docInfo.ID].ClientSeq, uint32(1)) - assert.NoError(t, err) - } - - // 03. Remove one document - docInfo, err := db.FindDocInfoByKeyAndOwner(ctx, clientInfo.RefKey(), helper.TestDocKey(t, 2), true) - assert.NoError(t, err) - assert.NoError(t, clientInfo.RemoveDocument(docInfo.ID)) - assert.NoError(t, db.UpdateClientInfoAfterPushPull(ctx, clientInfo, docInfo)) - - // 04. Deactivate the client - result, err := db.DeactivateClient(ctx, types.ClientRefKey{ - ProjectID: projectID, - ClientID: clientInfo.ID, - }) - assert.NoError(t, err) - - // 05. Check whether doc.Status is reflected properly. - // If it was `DocumentAttached`, it should be changed to `DocumentDetached`. - for i := 0; i < 2; i++ { - docInfo, err := db.FindDocInfoByKeyAndOwner(ctx, clientInfo.RefKey(), helper.TestDocKey(t, i), true) - assert.NoError(t, err) - assert.Equal(t, result.Documents[docInfo.ID].Status, database.DocumentDetached) - } - // If it was `DocumentRemoved`, it should be remained `DocumentRemoved`. - docInfo, err = db.FindDocInfoByKeyAndOwner(ctx, clientInfo.RefKey(), helper.TestDocKey(t, 2), true) - assert.NoError(t, err) - assert.Equal(t, result.Documents[docInfo.ID].Status, database.DocumentRemoved) - }) } // RunUpdateProjectInfoTest runs the UpdateProjectInfo tests for the given db. diff --git a/server/clients/clients.go b/server/clients/clients.go index 0721c4e9c..045a7a21a 100644 --- a/server/clients/clients.go +++ b/server/clients/clients.go @@ -14,7 +14,7 @@ * limitations under the License. */ -// Package clients provides the client related business logic. +// Package clients provides the Client related business logic. package clients import ( @@ -22,19 +22,20 @@ import ( "errors" "github.com/yorkie-team/yorkie/api/types" + "github.com/yorkie-team/yorkie/server/backend" "github.com/yorkie-team/yorkie/server/backend/database" "github.com/yorkie-team/yorkie/system" ) var ( // ErrInvalidClientKey is returned when the given Key is not valid ClientKey. - ErrInvalidClientKey = errors.New("invalid client key") + ErrInvalidClientKey = errors.New("invalid Client key") // ErrInvalidClientID is returned when the given Key is not valid ClientID. - ErrInvalidClientID = errors.New("invalid client id") + ErrInvalidClientID = errors.New("invalid Client id") ) -// Activate activates the given client. +// Activate activates the given Client. func Activate( ctx context.Context, db database.Database, @@ -44,23 +45,23 @@ func Activate( return db.ActivateClient(ctx, project.ID, clientKey) } -// Deactivate deactivates the given client. +// Deactivate deactivates the given Client. func Deactivate( ctx context.Context, - db database.Database, + be *backend.Backend, project *types.Project, refKey types.ClientRefKey, ) (*database.ClientInfo, error) { - info, err := FindActiveClientInfo(ctx, db, refKey) + info, err := FindActiveClientInfo(ctx, be.DB, refKey) if err != nil { return nil, err } - // TODO(hackerwins): Inject gatewayAddr - systemClient, err := system.Dial("localhost:8080") + systemClient, err := system.Dial(be.Config.GatewayAddr, system.WithInsecure(true)) if err != nil { return nil, err } + defer systemClient.Close() for docID, clientDocInfo := range info.Documents { // TODO(hackerwins): Solve N+1 @@ -68,7 +69,7 @@ func Deactivate( continue } - docInfo, err := db.FindDocInfoByRefKey(ctx, types.DocRefKey{ + docInfo, err := be.DB.FindDocInfoByRefKey(ctx, types.DocRefKey{ ProjectID: project.ID, DocID: docID, }) @@ -86,7 +87,7 @@ func Deactivate( } } - info, err = db.DeactivateClient(ctx, refKey) + info, err = be.DB.DeactivateClient(ctx, refKey) if err != nil { return nil, err } @@ -94,7 +95,7 @@ func Deactivate( return info, err } -// FindActiveClientInfo find the active client info by the given ref key. +// FindActiveClientInfo find the active Client info by the given ref key. func FindActiveClientInfo( ctx context.Context, db database.Database, diff --git a/server/clients/housekeeping.go b/server/clients/housekeeping.go index ed1b00254..57a632ec7 100644 --- a/server/clients/housekeeping.go +++ b/server/clients/housekeeping.go @@ -69,7 +69,7 @@ func DeactivateInactives( deactivatedCount := 0 for _, pair := range candidates { - if _, err := Deactivate(ctx, be.DB, pair.project.ToProject(), pair.client.RefKey()); err != nil { + if _, err := Deactivate(ctx, be, pair.Project.ToProject(), pair.Client.RefKey()); err != nil { return database.DefaultProjectID, err } @@ -88,10 +88,10 @@ func DeactivateInactives( return lastProjectID, nil } -// CandidatePair represents a pair of project and client. +// CandidatePair represents a pair of Project and Client. type CandidatePair struct { - project *database.ProjectInfo - client *database.ClientInfo + Project *database.ProjectInfo + Client *database.ClientInfo } // FindDeactivateCandidates finds candidates to deactivate from the database. @@ -116,8 +116,8 @@ func FindDeactivateCandidates( for _, info := range infos { candidates = append(candidates, CandidatePair{ - project: projectInfo, - client: info, + Project: projectInfo, + Client: info, }) } } diff --git a/server/config.go b/server/config.go index eea4f3a25..118f63ea2 100644 --- a/server/config.go +++ b/server/config.go @@ -68,7 +68,8 @@ const ( DefaultProjectInfoCacheSize = 256 DefaultProjectInfoCacheTTL = 10 * time.Minute - DefaultHostname = "" + DefaultHostname = "" + DefaultGatewayAddr = "localhost:8080" ) // Config is the configuration for creating a Yorkie instance. diff --git a/server/config.sample.yml b/server/config.sample.yml index d5c72edbb..31497b197 100644 --- a/server/config.sample.yml +++ b/server/config.sample.yml @@ -87,6 +87,9 @@ Backend: # determined automatically by the OS (Optional, default: os.Hostname()). Hostname: "" + # GatewayAddr is the address of the gateway server. + GatewayAddr: "" + # Mongo is the MongoDB configuration (Optional). Mongo: # ConnectionTimeout is the timeout for connecting to MongoDB. diff --git a/server/documents/documents.go b/server/documents/documents.go index e73167e34..d10abe72a 100644 --- a/server/documents/documents.go +++ b/server/documents/documents.go @@ -71,7 +71,7 @@ func ListDocumentSummaries( } if includeSnapshot { - doc, err := packs.BuildDocumentForServerSeq(ctx, be, docInfo, docInfo.ServerSeq) + doc, err := packs.BuildInternalDocForServerSeq(ctx, be, docInfo, docInfo.ServerSeq) if err != nil { return nil, err } @@ -102,7 +102,7 @@ func GetDocumentSummary( return nil, err } - doc, err := packs.BuildDocumentForServerSeq(ctx, be, docInfo, docInfo.ServerSeq) + doc, err := packs.BuildInternalDocForServerSeq(ctx, be, docInfo, docInfo.ServerSeq) if err != nil { return nil, err } @@ -135,7 +135,7 @@ func GetDocumentSummaries( snapshot := "" if includeSnapshot { // TODO(hackerwins, kokodak): Resolve the N+1 problem. - doc, err := packs.BuildDocumentForServerSeq(ctx, be, docInfo, docInfo.ServerSeq) + doc, err := packs.BuildInternalDocForServerSeq(ctx, be, docInfo, docInfo.ServerSeq) if err != nil { return nil, err } @@ -179,7 +179,7 @@ func GetDocumentByServerSeq( return nil, err } - doc, err := packs.BuildDocumentForServerSeq(ctx, be, docInfo, serverSeq) + doc, err := packs.BuildInternalDocForServerSeq(ctx, be, docInfo, serverSeq) if err != nil { return nil, err } diff --git a/server/packs/packs.go b/server/packs/packs.go index 79425e572..de10a7d6a 100644 --- a/server/packs/packs.go +++ b/server/packs/packs.go @@ -30,6 +30,7 @@ import ( "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/change" "github.com/yorkie-team/yorkie/pkg/document/key" + "github.com/yorkie-team/yorkie/pkg/document/time" "github.com/yorkie-team/yorkie/pkg/units" "github.com/yorkie-team/yorkie/server/backend" "github.com/yorkie-team/yorkie/server/backend/database" @@ -211,8 +212,26 @@ func PushPull( return respPack, nil } -// BuildDocumentForServerSeq returns a new document for the given serverSeq. -func BuildDocumentForServerSeq( +// BuildDocForCheckpoint returns a new document for the given checkpoint. +func BuildDocForCheckpoint( + ctx context.Context, + be *backend.Backend, + docInfo *database.DocInfo, + cp change.Checkpoint, + actorID *time.ActorID, +) (*document.Document, error) { + internalDoc, err := BuildInternalDocForServerSeq(ctx, be, docInfo, cp.ServerSeq) + if err != nil { + return nil, err + } + + internalDoc.SetActor(actorID) + internalDoc.SyncCheckpoint(cp.ServerSeq, cp.ClientSeq) + return internalDoc.ToDocument(), nil +} + +// BuildInternalDocForServerSeq returns a new document for the given serverSeq. +func BuildInternalDocForServerSeq( ctx context.Context, be *backend.Backend, docInfo *database.DocInfo, diff --git a/server/packs/pushpull.go b/server/packs/pushpull.go index 20303689a..ebc2000d6 100644 --- a/server/packs/pushpull.go +++ b/server/packs/pushpull.go @@ -139,7 +139,7 @@ func pullSnapshot( initialServerSeq int64, ) (*ServerPack, error) { // Build document from DB if the size of changes for the response is greater than the snapshot threshold. - doc, err := BuildDocumentForServerSeq(ctx, be, docInfo, initialServerSeq) + doc, err := BuildInternalDocForServerSeq(ctx, be, docInfo, initialServerSeq) if err != nil { return nil, err } diff --git a/server/rpc/system_server.go b/server/rpc/system_server.go index e209542b9..f6ebddfa9 100644 --- a/server/rpc/system_server.go +++ b/server/rpc/system_server.go @@ -50,8 +50,8 @@ func newSystemServer(backend *backend.Backend) *systemServer { // DetachDocument detaches the given document from the given client. func (s *systemServer) DetachDocument( ctx context.Context, - req *connect.Request[api.DetachDocumentRequestBySystem], -) (*connect.Response[api.DetachDocumentResponseBySystem], error) { + req *connect.Request[api.SystemServiceDetachDocumentRequest], +) (*connect.Response[api.SystemServiceDetachDocumentResponse], error) { actorID, err := time.ActorIDFromHex(req.Msg.ClientId) if err != nil { return nil, err @@ -100,17 +100,11 @@ func (s *systemServer) DetachDocument( return nil, err } - serverSeq, err := clientInfo.ServerSeq(docID) + doc, err := packs.BuildDocForCheckpoint(ctx, s.backend, docInfo, clientInfo.Checkpoint(docID), actorID) if err != nil { return nil, err } - internalDoc, err := packs.BuildDocumentForServerSeq(ctx, s.backend, docInfo, serverSeq) - if err != nil { - return nil, err - } - - doc := internalDoc.ToDocument() if err := doc.Update(func(root *json.Object, p *presence.Presence) error { p.Clear() return nil @@ -133,5 +127,5 @@ func (s *systemServer) DetachDocument( return nil, err } - return connect.NewResponse(&api.DetachDocumentResponseBySystem{}), nil + return connect.NewResponse(&api.SystemServiceDetachDocumentResponse{}), nil } diff --git a/server/rpc/yorkie_server.go b/server/rpc/yorkie_server.go index 71eddb794..88a469448 100644 --- a/server/rpc/yorkie_server.go +++ b/server/rpc/yorkie_server.go @@ -94,7 +94,7 @@ func (s *yorkieServer) DeactivateClient( } project := projects.From(ctx) - _, err = clients.Deactivate(ctx, s.backend.DB, project, types.ClientRefKey{ + _, err = clients.Deactivate(ctx, s.backend, project, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) diff --git a/server/server.go b/server/server.go index 5475a26c0..fd14db3bf 100644 --- a/server/server.go +++ b/server/server.go @@ -150,7 +150,7 @@ func (r *Yorkie) DeactivateClient(ctx context.Context, c1 *client.Client) error return err } - _, err = clients.Deactivate(ctx, r.backend.DB, project, types.ClientRefKey{ + _, err = clients.Deactivate(ctx, r.backend, project, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(c1.ID()), }) diff --git a/system/client.go b/system/client.go index 22e25e82a..3d9ddb7f1 100644 --- a/system/client.go +++ b/system/client.go @@ -137,7 +137,7 @@ func (c *Client) DetachDocument( ) error { _, err := c.client.DetachDocument( ctx, - withShardKey(connect.NewRequest(&api.DetachDocumentRequestBySystem{ + withShardKey(connect.NewRequest(&api.SystemServiceDetachDocumentRequest{ ProjectId: projectID.String(), ClientId: clientID.String(), DocumentId: docID.String(), diff --git a/test/helper/helper.go b/test/helper/helper.go index 346074c52..5fb74fe4d 100644 --- a/test/helper/helper.go +++ b/test/helper/helper.go @@ -256,6 +256,7 @@ func TestConfig() *server.Config { AuthWebhookCacheUnauthTTL: AuthWebhookCacheUnauthTTL.String(), ProjectInfoCacheSize: ProjectInfoCacheSize, ProjectInfoCacheTTL: ProjectInfoCacheTTL.String(), + GatewayAddr: fmt.Sprintf("localhost:%d", RPCPort+portOffset), }, Mongo: &mongo.Config{ ConnectionURI: MongoConnectionURI, diff --git a/test/integration/housekeeping_test.go b/test/integration/housekeeping_test.go index add1a9a93..d28ecd198 100644 --- a/test/integration/housekeeping_test.go +++ b/test/integration/housekeeping_test.go @@ -123,7 +123,7 @@ func TestHousekeeping(t *testing.T) { log.Fatal(err) } - clientC, err := be.DB.ActivateClient(ctx, projects[0].ID, fmt.Sprintf("%s-C", t.Name())) + _, err := be.DB.ActivateClient(ctx, projects[0].ID, fmt.Sprintf("%s-C", t.Name())) assert.NoError(t, err) _, candidates, err := clients.FindDeactivateCandidates( @@ -136,9 +136,8 @@ func TestHousekeeping(t *testing.T) { assert.NoError(t, err) assert.Len(t, candidates, 2) - assert.Equal(t, candidates[0].ID, clientA.ID) - assert.Equal(t, candidates[1].ID, clientB.ID) - assert.NotContains(t, candidates, clientC) + assert.Equal(t, candidates[0].Client.ID, clientA.ID) + assert.Equal(t, candidates[1].Client.ID, clientB.ID) }) } From d97f66874ee81da39afc35c653642faa589657e0 Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Wed, 16 Oct 2024 17:33:06 +0900 Subject: [PATCH 3/8] Add gateway flag to yorkie-cluster chart --- api/yorkie/v1/system.proto | 4 ++-- .../yorkie-cluster/templates/yorkie/deployment.yaml | 2 ++ build/charts/yorkie-cluster/values.yaml | 2 ++ server/clients/clients.go | 12 ++++++------ test/complex/main_test.go | 1 + test/integration/housekeeping_test.go | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/api/yorkie/v1/system.proto b/api/yorkie/v1/system.proto index 70ef8b989..95247ccaf 100644 --- a/api/yorkie/v1/system.proto +++ b/api/yorkie/v1/system.proto @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Yorkie Authors. All rights reserved. + * Copyright 2024 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. @@ -35,4 +35,4 @@ message SystemServiceDetachDocumentRequest { string document_key = 4; } -message SystemServiceDetachDocumentResponse {} \ No newline at end of file +message SystemServiceDetachDocumentResponse {} diff --git a/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml b/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml index a07c01a10..15de6b065 100644 --- a/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml +++ b/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml @@ -45,6 +45,8 @@ spec: "{{ .Values.yorkie.ports.rpcPort }}", "--profiling-port", "{{ .Values.yorkie.ports.profilingPort }}", + "--backend-gateway-addr", + "{{ .Values.yorkie.gateway }}.{{ .Values.yorkie.namespace }}.svc.cluster.local", ] ports: - containerPort: {{ .Values.yorkie.ports.rpcPort }} diff --git a/build/charts/yorkie-cluster/values.yaml b/build/charts/yorkie-cluster/values.yaml index 204e58d18..cb82b11b0 100644 --- a/build/charts/yorkie-cluster/values.yaml +++ b/build/charts/yorkie-cluster/values.yaml @@ -3,6 +3,8 @@ yorkie: name: yorkie namespace: yorkie + gateway: yorkie-gateway + autoscaling: enabled: false replicaCount: 3 diff --git a/server/clients/clients.go b/server/clients/clients.go index 045a7a21a..17ee2ba1b 100644 --- a/server/clients/clients.go +++ b/server/clients/clients.go @@ -14,7 +14,7 @@ * limitations under the License. */ -// Package clients provides the Client related business logic. +// Package clients provides the client related business logic. package clients import ( @@ -29,13 +29,13 @@ import ( var ( // ErrInvalidClientKey is returned when the given Key is not valid ClientKey. - ErrInvalidClientKey = errors.New("invalid Client key") + ErrInvalidClientKey = errors.New("invalid client key") // ErrInvalidClientID is returned when the given Key is not valid ClientID. - ErrInvalidClientID = errors.New("invalid Client id") + ErrInvalidClientID = errors.New("invalid client id") ) -// Activate activates the given Client. +// Activate activates the given client. func Activate( ctx context.Context, db database.Database, @@ -45,7 +45,7 @@ func Activate( return db.ActivateClient(ctx, project.ID, clientKey) } -// Deactivate deactivates the given Client. +// Deactivate deactivates the given client. func Deactivate( ctx context.Context, be *backend.Backend, @@ -95,7 +95,7 @@ func Deactivate( return info, err } -// FindActiveClientInfo find the active Client info by the given ref key. +// FindActiveClientInfo find the active client info by the given ref key. func FindActiveClientInfo( ctx context.Context, db database.Database, diff --git a/test/complex/main_test.go b/test/complex/main_test.go index 9ce84b62d..557925c74 100644 --- a/test/complex/main_test.go +++ b/test/complex/main_test.go @@ -82,6 +82,7 @@ func TestMain(m *testing.M) { ProjectInfoCacheSize: helper.ProjectInfoCacheSize, ProjectInfoCacheTTL: helper.ProjectInfoCacheTTL.String(), AdminTokenDuration: helper.AdminTokenDuration, + GatewayAddr: fmt.Sprintf("localhost:%d", helper.RPCPort), }, &mongo.Config{ ConnectionURI: helper.MongoConnectionURI, YorkieDatabase: shardedDBNameForServer, diff --git a/test/integration/housekeeping_test.go b/test/integration/housekeeping_test.go index d28ecd198..504b3a737 100644 --- a/test/integration/housekeeping_test.go +++ b/test/integration/housekeeping_test.go @@ -123,7 +123,7 @@ func TestHousekeeping(t *testing.T) { log.Fatal(err) } - _, err := be.DB.ActivateClient(ctx, projects[0].ID, fmt.Sprintf("%s-C", t.Name())) + _, err = be.DB.ActivateClient(ctx, projects[0].ID, fmt.Sprintf("%s-C", t.Name())) assert.NoError(t, err) _, candidates, err := clients.FindDeactivateCandidates( From 2c225c7c302bb5999b81fab22ecd8bcb2887d3b6 Mon Sep 17 00:00:00 2001 From: raararaara Date: Wed, 16 Oct 2024 18:35:11 +0900 Subject: [PATCH 4/8] Fix proto to pass Project and DocumentSummary cleanly --- api/docs/yorkie/v1/system.openapi.yaml | 205 +++++++++++++++++++++++-- api/yorkie/v1/system.pb.go | 98 ++++++------ api/yorkie/v1/system.proto | 8 +- server/clients/clients.go | 2 +- server/rpc/system_server.go | 19 +-- system/client.go | 13 +- 6 files changed, 262 insertions(+), 83 deletions(-) diff --git a/api/docs/yorkie/v1/system.openapi.yaml b/api/docs/yorkie/v1/system.openapi.yaml index 67c21694d..f25bc0899 100644 --- a/api/docs/yorkie/v1/system.openapi.yaml +++ b/api/docs/yorkie/v1/system.openapi.yaml @@ -81,31 +81,216 @@ components: type: string title: Connect Error type: object - yorkie.v1.SystemServiceDetachDocumentRequest: + google.protobuf.Timestamp: + additionalProperties: false + description: |- + A Timestamp represents a point in time independent of any time zone or local + calendar, encoded as a count of seconds and fractions of seconds at + nanosecond resolution. The count is relative to an epoch at UTC midnight on + January 1, 1970, in the proleptic Gregorian calendar which extends the + Gregorian calendar backwards to year one. + + All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + second table is needed for interpretation, using a [24-hour linear + smear](https://developers.google.com/time/smear). + + The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + restricting to that range, we ensure that we can convert to and from [RFC + 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + + # Examples + + Example 1: Compute Timestamp from POSIX `time()`. + + Timestamp timestamp; + timestamp.set_seconds(time(NULL)); + timestamp.set_nanos(0); + + Example 2: Compute Timestamp from POSIX `gettimeofday()`. + + struct timeval tv; + gettimeofday(&tv, NULL); + + Timestamp timestamp; + timestamp.set_seconds(tv.tv_sec); + timestamp.set_nanos(tv.tv_usec * 1000); + + Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + + // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + Timestamp timestamp; + timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + + Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + + long millis = System.currentTimeMillis(); + + Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + .setNanos((int) ((millis % 1000) * 1000000)).build(); + + Example 5: Compute Timestamp from Java `Instant.now()`. + + Instant now = Instant.now(); + + Timestamp timestamp = + Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + .setNanos(now.getNano()).build(); + + Example 6: Compute Timestamp from current time in Python. + + timestamp = Timestamp() + timestamp.GetCurrentTime() + + # JSON Mapping + + In JSON format, the Timestamp type is encoded as a string in the + [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + where {year} is always expressed using four digits while {month}, {day}, + {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + is required. A proto3 JSON serializer should always use UTC (as indicated by + "Z") when printing the Timestamp type and a proto3 JSON parser should be + able to accept both UTC and other timezones (as indicated by an offset). + + For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + 01:30 UTC on January 15, 2017. + + In JavaScript, one can convert a Date object to this format using the + standard + [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + method. In Python, a standard `datetime.datetime` object can be converted + to this format using + [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + the Joda Time's [`ISODateTimeFormat.dateTime()`]( + http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime() + ) to obtain a formatter capable of generating timestamps in this format. + format: date-time + type: string + yorkie.v1.DocumentSummary: additionalProperties: false description: "" properties: - clientId: + accessedAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' additionalProperties: false description: "" - title: client_id + title: accessed_at + type: object + createdAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: created_at + type: object + id: + additionalProperties: false + description: "" + title: id + type: string + key: + additionalProperties: false + description: "" + title: key + type: string + snapshot: + additionalProperties: false + description: "" + title: snapshot type: string - documentId: + updatedAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: updated_at + type: object + title: DocumentSummary + type: object + yorkie.v1.Project: + additionalProperties: false + description: "" + properties: + authWebhookMethods: additionalProperties: false description: "" - title: document_id + items: + type: string + title: auth_webhook_methods + type: array + authWebhookUrl: + additionalProperties: false + description: "" + title: auth_webhook_url type: string - documentKey: + clientDeactivateThreshold: additionalProperties: false description: "" - title: document_key + title: client_deactivate_threshold type: string - projectId: + createdAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: created_at + type: object + id: + additionalProperties: false + description: "" + title: id + type: string + name: + additionalProperties: false + description: "" + title: name + type: string + publicKey: + additionalProperties: false + description: "" + title: public_key + type: string + secretKey: + additionalProperties: false + description: "" + title: secret_key + type: string + updatedAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: updated_at + type: object + title: Project + type: object + yorkie.v1.SystemServiceDetachDocumentRequest: + additionalProperties: false + description: "" + properties: + clientId: + additionalProperties: false + description: "" + title: client_id + type: string + documentSummary: + $ref: '#/components/schemas/yorkie.v1.DocumentSummary' + additionalProperties: false + description: "" + title: document_summary + type: object + project: + $ref: '#/components/schemas/yorkie.v1.Project' additionalProperties: false description: 'TODO(hackerwins): Consider to replace this fields with types.Project, types.Client, types.DocumentSummary' - title: project_id - type: string + title: project + type: object title: SystemServiceDetachDocumentRequest type: object yorkie.v1.SystemServiceDetachDocumentResponse: diff --git a/api/yorkie/v1/system.pb.go b/api/yorkie/v1/system.pb.go index 6106f5200..40631fd7c 100644 --- a/api/yorkie/v1/system.pb.go +++ b/api/yorkie/v1/system.pb.go @@ -41,10 +41,9 @@ type SystemServiceDetachDocumentRequest struct { unknownFields protoimpl.UnknownFields // TODO(hackerwins): Consider to replace this fields with types.Project, types.Client, types.DocumentSummary - ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` - ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - DocumentId string `protobuf:"bytes,3,opt,name=document_id,json=documentId,proto3" json:"document_id,omitempty"` - DocumentKey string `protobuf:"bytes,4,opt,name=document_key,json=documentKey,proto3" json:"document_key,omitempty"` + Project *Project `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` + ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + DocumentSummary *DocumentSummary `protobuf:"bytes,3,opt,name=document_summary,json=documentSummary,proto3" json:"document_summary,omitempty"` } func (x *SystemServiceDetachDocumentRequest) Reset() { @@ -79,11 +78,11 @@ func (*SystemServiceDetachDocumentRequest) Descriptor() ([]byte, []int) { return file_yorkie_v1_system_proto_rawDescGZIP(), []int{0} } -func (x *SystemServiceDetachDocumentRequest) GetProjectId() string { +func (x *SystemServiceDetachDocumentRequest) GetProject() *Project { if x != nil { - return x.ProjectId + return x.Project } - return "" + return nil } func (x *SystemServiceDetachDocumentRequest) GetClientId() string { @@ -93,18 +92,11 @@ func (x *SystemServiceDetachDocumentRequest) GetClientId() string { return "" } -func (x *SystemServiceDetachDocumentRequest) GetDocumentId() string { +func (x *SystemServiceDetachDocumentRequest) GetDocumentSummary() *DocumentSummary { if x != nil { - return x.DocumentId + return x.DocumentSummary } - return "" -} - -func (x *SystemServiceDetachDocumentRequest) GetDocumentKey() string { - if x != nil { - return x.DocumentKey - } - return "" + return nil } type SystemServiceDetachDocumentResponse struct { @@ -150,33 +142,36 @@ var File_yorkie_v1_system_proto protoreflect.FileDescriptor var file_yorkie_v1_system_proto_rawDesc = []byte{ 0x0a, 0x16, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, - 0x2e, 0x76, 0x31, 0x22, 0xa4, 0x01, 0x0a, 0x22, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, - 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, - 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x25, 0x0a, 0x23, 0x53, 0x79, + 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, + 0x01, 0x0a, 0x22, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, + 0x12, 0x45, 0x0a, 0x10, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x75, 0x6d, + 0x6d, 0x61, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x79, 0x6f, 0x72, + 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x53, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x0f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x25, 0x0a, 0x23, 0x53, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x82, + 0x01, 0x0a, 0x0d, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x71, 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, + 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x2e, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x32, 0x82, 0x01, 0x0a, 0x0d, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, - 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, - 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, - 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, - 0x2d, 0x74, 0x65, 0x61, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x22, 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, + 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x65, + 0x61, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x79, 0x6f, + 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -195,15 +190,19 @@ var file_yorkie_v1_system_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_yorkie_v1_system_proto_goTypes = []interface{}{ (*SystemServiceDetachDocumentRequest)(nil), // 0: yorkie.v1.SystemServiceDetachDocumentRequest (*SystemServiceDetachDocumentResponse)(nil), // 1: yorkie.v1.SystemServiceDetachDocumentResponse + (*Project)(nil), // 2: yorkie.v1.Project + (*DocumentSummary)(nil), // 3: yorkie.v1.DocumentSummary } var file_yorkie_v1_system_proto_depIdxs = []int32{ - 0, // 0: yorkie.v1.SystemService.DetachDocument:input_type -> yorkie.v1.SystemServiceDetachDocumentRequest - 1, // 1: yorkie.v1.SystemService.DetachDocument:output_type -> yorkie.v1.SystemServiceDetachDocumentResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 2, // 0: yorkie.v1.SystemServiceDetachDocumentRequest.project:type_name -> yorkie.v1.Project + 3, // 1: yorkie.v1.SystemServiceDetachDocumentRequest.document_summary:type_name -> yorkie.v1.DocumentSummary + 0, // 2: yorkie.v1.SystemService.DetachDocument:input_type -> yorkie.v1.SystemServiceDetachDocumentRequest + 1, // 3: yorkie.v1.SystemService.DetachDocument:output_type -> yorkie.v1.SystemServiceDetachDocumentResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_yorkie_v1_system_proto_init() } @@ -211,6 +210,7 @@ func file_yorkie_v1_system_proto_init() { if File_yorkie_v1_system_proto != nil { return } + file_yorkie_v1_resources_proto_init() if !protoimpl.UnsafeEnabled { file_yorkie_v1_system_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SystemServiceDetachDocumentRequest); i { diff --git a/api/yorkie/v1/system.proto b/api/yorkie/v1/system.proto index 95247ccaf..046a67f32 100644 --- a/api/yorkie/v1/system.proto +++ b/api/yorkie/v1/system.proto @@ -17,6 +17,8 @@ syntax = "proto3"; package yorkie.v1; +import "yorkie/v1/resources.proto"; + option go_package = "github.com/yorkie-team/yorkie/api/yorkie/v1;v1"; option java_multiple_files = true; @@ -28,11 +30,9 @@ service SystemService { } message SystemServiceDetachDocumentRequest { - // TODO(hackerwins): Consider to replace this fields with types.Project, types.Client, types.DocumentSummary - string project_id = 1; + Project project = 1; string client_id = 2; - string document_id = 3; - string document_key = 4; + DocumentSummary document_summary = 3; } message SystemServiceDetachDocumentResponse {} diff --git a/server/clients/clients.go b/server/clients/clients.go index 17ee2ba1b..e8a299b86 100644 --- a/server/clients/clients.go +++ b/server/clients/clients.go @@ -82,7 +82,7 @@ func Deactivate( return nil, err } - if err := systemClient.DetachDocument(ctx, project.ID, actorID, docID, project.PublicKey, docInfo.Key); err != nil { + if err := systemClient.DetachDocument(ctx, project, actorID, docID, project.PublicKey, docInfo.Key); err != nil { return nil, err } } diff --git a/server/rpc/system_server.go b/server/rpc/system_server.go index f6ebddfa9..40dc2ceb4 100644 --- a/server/rpc/system_server.go +++ b/server/rpc/system_server.go @@ -26,7 +26,6 @@ import ( api "github.com/yorkie-team/yorkie/api/yorkie/v1" "github.com/yorkie-team/yorkie/pkg/document" "github.com/yorkie-team/yorkie/pkg/document/json" - "github.com/yorkie-team/yorkie/pkg/document/key" "github.com/yorkie-team/yorkie/pkg/document/presence" "github.com/yorkie-team/yorkie/pkg/document/time" "github.com/yorkie-team/yorkie/server/backend" @@ -57,18 +56,10 @@ func (s *systemServer) DetachDocument( return nil, err } - docID, err := converter.FromDocumentID(req.Msg.DocumentId) - if err != nil { - return nil, err - } - - info, err := s.backend.DB.FindProjectInfoByID(ctx, types.ID(req.Msg.ProjectId)) - if err != nil { - return nil, err - } - project := info.ToProject() + documentSummary := converter.FromDocumentSummary(req.Msg.DocumentSummary) + project := converter.FromProject(req.Msg.Project) - locker, err := s.backend.Coordinator.NewLocker(ctx, packs.PushPullKey(project.ID, key.Key(req.Msg.DocumentKey))) + locker, err := s.backend.Coordinator.NewLocker(ctx, packs.PushPullKey(project.ID, documentSummary.Key)) if err != nil { return nil, err } @@ -92,7 +83,7 @@ func (s *systemServer) DetachDocument( docRefKey := types.DocRefKey{ ProjectID: project.ID, - DocID: docID, + DocID: documentSummary.ID, } docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, docRefKey) @@ -100,7 +91,7 @@ func (s *systemServer) DetachDocument( return nil, err } - doc, err := packs.BuildDocForCheckpoint(ctx, s.backend, docInfo, clientInfo.Checkpoint(docID), actorID) + doc, err := packs.BuildDocForCheckpoint(ctx, s.backend, docInfo, clientInfo.Checkpoint(documentSummary.ID), actorID) if err != nil { return nil, err } diff --git a/system/client.go b/system/client.go index 3d9ddb7f1..bffab98e6 100644 --- a/system/client.go +++ b/system/client.go @@ -28,6 +28,7 @@ import ( "go.uber.org/zap" "golang.org/x/net/http2" + "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/api/yorkie/v1/v1connect" @@ -129,7 +130,7 @@ func (c *Client) Close() { // DetachDocument detaches the given document from the client. func (c *Client) DetachDocument( ctx context.Context, - projectID types.ID, + project *types.Project, clientID *time.ActorID, docID types.ID, apiKey string, @@ -138,10 +139,12 @@ func (c *Client) DetachDocument( _, err := c.client.DetachDocument( ctx, withShardKey(connect.NewRequest(&api.SystemServiceDetachDocumentRequest{ - ProjectId: projectID.String(), - ClientId: clientID.String(), - DocumentId: docID.String(), - DocumentKey: docKey.String(), + Project: converter.ToProject(project), + ClientId: clientID.String(), + DocumentSummary: converter.ToDocumentSummary(&types.DocumentSummary{ + ID: docID, + Key: docKey, + }), }, ), apiKey, docKey.String())) if err != nil { From e0753b402ee78c5b38b99f71d991092570e5a51f Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Wed, 16 Oct 2024 18:46:27 +0900 Subject: [PATCH 5/8] Fix incorrect condition for skip detachment --- server/clients/clients.go | 4 ++-- server/rpc/server.go | 2 +- system/client.go | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/clients/clients.go b/server/clients/clients.go index e8a299b86..13244c168 100644 --- a/server/clients/clients.go +++ b/server/clients/clients.go @@ -64,11 +64,11 @@ func Deactivate( defer systemClient.Close() for docID, clientDocInfo := range info.Documents { - // TODO(hackerwins): Solve N+1 - if clientDocInfo.Status == database.DocumentDetached { + if clientDocInfo.Status != database.DocumentAttached { continue } + // TODO(hackerwins): Solve N+1 docInfo, err := be.DB.FindDocInfoByRefKey(ctx, types.DocRefKey{ ProjectID: project.ID, DocID: docID, diff --git a/server/rpc/server.go b/server/rpc/server.go index b204f4784..8031112ea 100644 --- a/server/rpc/server.go +++ b/server/rpc/server.go @@ -73,7 +73,7 @@ func NewServer(conf *Config, be *backend.Backend) (*Server, error) { mux := http.NewServeMux() mux.Handle(v1connect.NewYorkieServiceHandler(newYorkieServer(yorkieServiceCtx, be), opts...)) mux.Handle(v1connect.NewAdminServiceHandler(newAdminServer(be, tokenManager), opts...)) - mux.Handle(v1connect.NewSystemServiceHandler(newSystemServer(be))) + mux.Handle(v1connect.NewSystemServiceHandler(newSystemServer(be), opts...)) mux.Handle(grpchealth.NewHandler(healthChecker)) mux.Handle(httphealth.NewHandler(healthChecker)) // TODO(hackerwins): We need to provide proper http server configuration. diff --git a/system/client.go b/system/client.go index bffab98e6..ef14b8fa4 100644 --- a/system/client.go +++ b/system/client.go @@ -14,7 +14,8 @@ * limitations under the License. */ -// Package system is a package for the system service. +// Package system is a package for the system service for communication between +// nodes in the Yorkie cluster. package system import ( From daf0b91a8a849894649aded88da7a9318da8ee16 Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Thu, 17 Oct 2024 13:30:16 +0900 Subject: [PATCH 6/8] Reflect CodeRabbit's reviews --- admin/client.go | 4 +- api/docs/yorkie/v1/cluster.openapi.yaml | 309 ++++++++++++++++++ api/yorkie/v1/cluster.pb.go | 257 +++++++++++++++ api/yorkie/v1/{system.proto => cluster.proto} | 10 +- api/yorkie/v1/system.pb.go | 258 --------------- api/yorkie/v1/v1connect/cluster.connect.go | 120 +++++++ api/yorkie/v1/v1connect/system.connect.go | 120 ------- client/client.go | 2 +- {system => cluster}/client.go | 38 ++- server/clients/clients.go | 27 +- server/packs/packs_test.go | 6 +- .../{system_server.go => cluster_server.go} | 28 +- server/rpc/server.go | 2 +- server/rpc/yorkie_server.go | 14 +- 14 files changed, 753 insertions(+), 442 deletions(-) create mode 100644 api/docs/yorkie/v1/cluster.openapi.yaml create mode 100644 api/yorkie/v1/cluster.pb.go rename api/yorkie/v1/{system.proto => cluster.proto} (76%) delete mode 100644 api/yorkie/v1/system.pb.go create mode 100644 api/yorkie/v1/v1connect/cluster.connect.go delete mode 100644 api/yorkie/v1/v1connect/system.connect.go rename {system => cluster}/client.go (83%) rename server/rpc/{system_server.go => cluster_server.go} (75%) diff --git a/admin/client.go b/admin/client.go index 1883d032b..fc967be11 100644 --- a/admin/client.go +++ b/admin/client.go @@ -72,6 +72,7 @@ type Client struct { client v1connect.AdminServiceClient authInterceptor *AuthInterceptor logger *zap.Logger + isInsecure bool } // New creates an instance of Client. @@ -100,6 +101,7 @@ func New(opts ...Option) (*Client, error) { conn: conn, logger: logger, authInterceptor: NewAuthInterceptor(options.Token), + isInsecure: options.IsInsecure, }, nil } @@ -120,7 +122,7 @@ func Dial(rpcAddr string, opts ...Option) (*Client, error) { // Dial dials to the admin service. func (c *Client) Dial(rpcAddr string) error { if !strings.Contains(rpcAddr, "://") { - if c.conn.Transport == nil { + if c.isInsecure { rpcAddr = "http://" + rpcAddr } else { rpcAddr = "https://" + rpcAddr diff --git a/api/docs/yorkie/v1/cluster.openapi.yaml b/api/docs/yorkie/v1/cluster.openapi.yaml new file mode 100644 index 000000000..faa1132cd --- /dev/null +++ b/api/docs/yorkie/v1/cluster.openapi.yaml @@ -0,0 +1,309 @@ +openapi: 3.1.0 +info: + description: Yorkie is an open source document store for building collaborative + editing applications. + title: Yorkie + version: v0.5.1 +servers: +- description: Production server + url: https://api.yorkie.dev +- description: Local server + url: http://localhost:8080 +paths: + /yorkie.v1.ClusterService/DetachDocument: + post: + description: "" + requestBody: + $ref: '#/components/requestBodies/yorkie.v1.ClusterService.DetachDocument.yorkie.v1.ClusterServiceDetachDocumentRequest' + responses: + "200": + $ref: '#/components/responses/yorkie.v1.ClusterService.DetachDocument.yorkie.v1.ClusterServiceDetachDocumentResponse' + default: + $ref: '#/components/responses/connect.error' + tags: + - yorkie.v1.ClusterService +components: + requestBodies: + yorkie.v1.ClusterService.DetachDocument.yorkie.v1.ClusterServiceDetachDocumentRequest: + content: + application/json: + schema: + $ref: '#/components/schemas/yorkie.v1.ClusterServiceDetachDocumentRequest' + application/proto: + schema: + $ref: '#/components/schemas/yorkie.v1.ClusterServiceDetachDocumentRequest' + required: true + responses: + connect.error: + content: + application/json: + schema: + $ref: '#/components/schemas/connect.error' + application/proto: + schema: + $ref: '#/components/schemas/connect.error' + description: "" + yorkie.v1.ClusterService.DetachDocument.yorkie.v1.ClusterServiceDetachDocumentResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/yorkie.v1.ClusterServiceDetachDocumentResponse' + application/proto: + schema: + $ref: '#/components/schemas/yorkie.v1.ClusterServiceDetachDocumentResponse' + description: "" + schemas: + connect.error: + additionalProperties: false + description: 'Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation' + properties: + code: + enum: + - CodeCanceled + - CodeUnknown + - CodeInvalidArgument + - CodeDeadlineExceeded + - CodeNotFound + - CodeAlreadyExists + - CodePermissionDenied + - CodeResourceExhausted + - CodeFailedPrecondition + - CodeAborted + - CodeOutOfRange + - CodeInternal + - CodeUnavailable + - CodeDataLoss + - CodeUnauthenticated + examples: + - CodeNotFound + type: string + message: + type: string + title: Connect Error + type: object + google.protobuf.Timestamp: + additionalProperties: false + description: |- + A Timestamp represents a point in time independent of any time zone or local + calendar, encoded as a count of seconds and fractions of seconds at + nanosecond resolution. The count is relative to an epoch at UTC midnight on + January 1, 1970, in the proleptic Gregorian calendar which extends the + Gregorian calendar backwards to year one. + + All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + second table is needed for interpretation, using a [24-hour linear + smear](https://developers.google.com/time/smear). + + The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + restricting to that range, we ensure that we can convert to and from [RFC + 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + + # Examples + + Example 1: Compute Timestamp from POSIX `time()`. + + Timestamp timestamp; + timestamp.set_seconds(time(NULL)); + timestamp.set_nanos(0); + + Example 2: Compute Timestamp from POSIX `gettimeofday()`. + + struct timeval tv; + gettimeofday(&tv, NULL); + + Timestamp timestamp; + timestamp.set_seconds(tv.tv_sec); + timestamp.set_nanos(tv.tv_usec * 1000); + + Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + + // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + Timestamp timestamp; + timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + + Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + + long millis = System.currentTimeMillis(); + + Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + .setNanos((int) ((millis % 1000) * 1000000)).build(); + + Example 5: Compute Timestamp from Java `Instant.now()`. + + Instant now = Instant.now(); + + Timestamp timestamp = + Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + .setNanos(now.getNano()).build(); + + Example 6: Compute Timestamp from current time in Python. + + timestamp = Timestamp() + timestamp.GetCurrentTime() + + # JSON Mapping + + In JSON format, the Timestamp type is encoded as a string in the + [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + where {year} is always expressed using four digits while {month}, {day}, + {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + is required. A proto3 JSON serializer should always use UTC (as indicated by + "Z") when printing the Timestamp type and a proto3 JSON parser should be + able to accept both UTC and other timezones (as indicated by an offset). + + For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + 01:30 UTC on January 15, 2017. + + In JavaScript, one can convert a Date object to this format using the + standard + [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + method. In Python, a standard `datetime.datetime` object can be converted + to this format using + [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + the Joda Time's [`ISODateTimeFormat.dateTime()`]( + http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime() + ) to obtain a formatter capable of generating timestamps in this format. + format: date-time + type: string + yorkie.v1.ClusterServiceDetachDocumentRequest: + additionalProperties: false + description: "" + properties: + clientId: + additionalProperties: false + description: "" + title: client_id + type: string + documentSummary: + $ref: '#/components/schemas/yorkie.v1.DocumentSummary' + additionalProperties: false + description: "" + title: document_summary + type: object + project: + $ref: '#/components/schemas/yorkie.v1.Project' + additionalProperties: false + description: "" + title: project + type: object + title: ClusterServiceDetachDocumentRequest + type: object + yorkie.v1.ClusterServiceDetachDocumentResponse: + additionalProperties: false + description: "" + title: ClusterServiceDetachDocumentResponse + type: object + yorkie.v1.DocumentSummary: + additionalProperties: false + description: "" + properties: + accessedAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: accessed_at + type: object + createdAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: created_at + type: object + id: + additionalProperties: false + description: "" + title: id + type: string + key: + additionalProperties: false + description: "" + title: key + type: string + snapshot: + additionalProperties: false + description: "" + title: snapshot + type: string + updatedAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: updated_at + type: object + title: DocumentSummary + type: object + yorkie.v1.Project: + additionalProperties: false + description: "" + properties: + authWebhookMethods: + additionalProperties: false + description: "" + items: + type: string + title: auth_webhook_methods + type: array + authWebhookUrl: + additionalProperties: false + description: "" + title: auth_webhook_url + type: string + clientDeactivateThreshold: + additionalProperties: false + description: "" + title: client_deactivate_threshold + type: string + createdAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: created_at + type: object + id: + additionalProperties: false + description: "" + title: id + type: string + name: + additionalProperties: false + description: "" + title: name + type: string + publicKey: + additionalProperties: false + description: "" + title: public_key + type: string + secretKey: + additionalProperties: false + description: "" + title: secret_key + type: string + updatedAt: + $ref: '#/components/schemas/google.protobuf.Timestamp' + additionalProperties: false + description: "" + title: updated_at + type: object + title: Project + type: object + securitySchemes: + ApiKeyAuth: + in: header + name: Authorization + type: apiKey +security: +- ApiKeyAuth: [] +tags: +- description: ClusterService is a service that provides an API for Cluster. + name: yorkie.v1.ClusterService diff --git a/api/yorkie/v1/cluster.pb.go b/api/yorkie/v1/cluster.pb.go new file mode 100644 index 000000000..cb99cb55c --- /dev/null +++ b/api/yorkie/v1/cluster.pb.go @@ -0,0 +1,257 @@ +// +// Copyright 2024 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. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: yorkie/v1/cluster.proto + +package v1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ClusterServiceDetachDocumentRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Project *Project `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` + ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + DocumentSummary *DocumentSummary `protobuf:"bytes,3,opt,name=document_summary,json=documentSummary,proto3" json:"document_summary,omitempty"` +} + +func (x *ClusterServiceDetachDocumentRequest) Reset() { + *x = ClusterServiceDetachDocumentRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_yorkie_v1_cluster_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClusterServiceDetachDocumentRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClusterServiceDetachDocumentRequest) ProtoMessage() {} + +func (x *ClusterServiceDetachDocumentRequest) ProtoReflect() protoreflect.Message { + mi := &file_yorkie_v1_cluster_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClusterServiceDetachDocumentRequest.ProtoReflect.Descriptor instead. +func (*ClusterServiceDetachDocumentRequest) Descriptor() ([]byte, []int) { + return file_yorkie_v1_cluster_proto_rawDescGZIP(), []int{0} +} + +func (x *ClusterServiceDetachDocumentRequest) GetProject() *Project { + if x != nil { + return x.Project + } + return nil +} + +func (x *ClusterServiceDetachDocumentRequest) GetClientId() string { + if x != nil { + return x.ClientId + } + return "" +} + +func (x *ClusterServiceDetachDocumentRequest) GetDocumentSummary() *DocumentSummary { + if x != nil { + return x.DocumentSummary + } + return nil +} + +type ClusterServiceDetachDocumentResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ClusterServiceDetachDocumentResponse) Reset() { + *x = ClusterServiceDetachDocumentResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_yorkie_v1_cluster_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClusterServiceDetachDocumentResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClusterServiceDetachDocumentResponse) ProtoMessage() {} + +func (x *ClusterServiceDetachDocumentResponse) ProtoReflect() protoreflect.Message { + mi := &file_yorkie_v1_cluster_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClusterServiceDetachDocumentResponse.ProtoReflect.Descriptor instead. +func (*ClusterServiceDetachDocumentResponse) Descriptor() ([]byte, []int) { + return file_yorkie_v1_cluster_proto_rawDescGZIP(), []int{1} +} + +var File_yorkie_v1_cluster_proto protoreflect.FileDescriptor + +var file_yorkie_v1_cluster_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x79, 0x6f, 0x72, 0x6b, 0x69, + 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x2f, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0xb7, 0x01, 0x0a, 0x23, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x49, 0x64, 0x12, 0x45, 0x0a, 0x10, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x73, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x79, + 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x0f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x26, 0x0a, 0x24, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, + 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x32, 0x85, 0x01, 0x0a, 0x0e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x73, 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2e, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, + 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, + 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, + 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x65, 0x61, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_yorkie_v1_cluster_proto_rawDescOnce sync.Once + file_yorkie_v1_cluster_proto_rawDescData = file_yorkie_v1_cluster_proto_rawDesc +) + +func file_yorkie_v1_cluster_proto_rawDescGZIP() []byte { + file_yorkie_v1_cluster_proto_rawDescOnce.Do(func() { + file_yorkie_v1_cluster_proto_rawDescData = protoimpl.X.CompressGZIP(file_yorkie_v1_cluster_proto_rawDescData) + }) + return file_yorkie_v1_cluster_proto_rawDescData +} + +var file_yorkie_v1_cluster_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_yorkie_v1_cluster_proto_goTypes = []interface{}{ + (*ClusterServiceDetachDocumentRequest)(nil), // 0: yorkie.v1.ClusterServiceDetachDocumentRequest + (*ClusterServiceDetachDocumentResponse)(nil), // 1: yorkie.v1.ClusterServiceDetachDocumentResponse + (*Project)(nil), // 2: yorkie.v1.Project + (*DocumentSummary)(nil), // 3: yorkie.v1.DocumentSummary +} +var file_yorkie_v1_cluster_proto_depIdxs = []int32{ + 2, // 0: yorkie.v1.ClusterServiceDetachDocumentRequest.project:type_name -> yorkie.v1.Project + 3, // 1: yorkie.v1.ClusterServiceDetachDocumentRequest.document_summary:type_name -> yorkie.v1.DocumentSummary + 0, // 2: yorkie.v1.ClusterService.DetachDocument:input_type -> yorkie.v1.ClusterServiceDetachDocumentRequest + 1, // 3: yorkie.v1.ClusterService.DetachDocument:output_type -> yorkie.v1.ClusterServiceDetachDocumentResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_yorkie_v1_cluster_proto_init() } +func file_yorkie_v1_cluster_proto_init() { + if File_yorkie_v1_cluster_proto != nil { + return + } + file_yorkie_v1_resources_proto_init() + if !protoimpl.UnsafeEnabled { + file_yorkie_v1_cluster_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClusterServiceDetachDocumentRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_yorkie_v1_cluster_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClusterServiceDetachDocumentResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_yorkie_v1_cluster_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_yorkie_v1_cluster_proto_goTypes, + DependencyIndexes: file_yorkie_v1_cluster_proto_depIdxs, + MessageInfos: file_yorkie_v1_cluster_proto_msgTypes, + }.Build() + File_yorkie_v1_cluster_proto = out.File + file_yorkie_v1_cluster_proto_rawDesc = nil + file_yorkie_v1_cluster_proto_goTypes = nil + file_yorkie_v1_cluster_proto_depIdxs = nil +} diff --git a/api/yorkie/v1/system.proto b/api/yorkie/v1/cluster.proto similarity index 76% rename from api/yorkie/v1/system.proto rename to api/yorkie/v1/cluster.proto index 046a67f32..2b565b838 100644 --- a/api/yorkie/v1/system.proto +++ b/api/yorkie/v1/cluster.proto @@ -24,15 +24,15 @@ option go_package = "github.com/yorkie-team/yorkie/api/yorkie/v1;v1"; option java_multiple_files = true; option java_package = "dev.yorkie.api.v1"; -// System is a service that provides an API for Cluster. -service SystemService { - rpc DetachDocument (SystemServiceDetachDocumentRequest) returns (SystemServiceDetachDocumentResponse) {} +// ClusterService is a service that provides an API for Cluster. +service ClusterService { + rpc DetachDocument (ClusterServiceDetachDocumentRequest) returns (ClusterServiceDetachDocumentResponse) {} } -message SystemServiceDetachDocumentRequest { +message ClusterServiceDetachDocumentRequest { Project project = 1; string client_id = 2; DocumentSummary document_summary = 3; } -message SystemServiceDetachDocumentResponse {} +message ClusterServiceDetachDocumentResponse {} diff --git a/api/yorkie/v1/system.pb.go b/api/yorkie/v1/system.pb.go deleted file mode 100644 index 40631fd7c..000000000 --- a/api/yorkie/v1/system.pb.go +++ /dev/null @@ -1,258 +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. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc (unknown) -// source: yorkie/v1/system.proto - -package v1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type SystemServiceDetachDocumentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // TODO(hackerwins): Consider to replace this fields with types.Project, types.Client, types.DocumentSummary - Project *Project `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` - ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - DocumentSummary *DocumentSummary `protobuf:"bytes,3,opt,name=document_summary,json=documentSummary,proto3" json:"document_summary,omitempty"` -} - -func (x *SystemServiceDetachDocumentRequest) Reset() { - *x = SystemServiceDetachDocumentRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_yorkie_v1_system_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SystemServiceDetachDocumentRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SystemServiceDetachDocumentRequest) ProtoMessage() {} - -func (x *SystemServiceDetachDocumentRequest) ProtoReflect() protoreflect.Message { - mi := &file_yorkie_v1_system_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SystemServiceDetachDocumentRequest.ProtoReflect.Descriptor instead. -func (*SystemServiceDetachDocumentRequest) Descriptor() ([]byte, []int) { - return file_yorkie_v1_system_proto_rawDescGZIP(), []int{0} -} - -func (x *SystemServiceDetachDocumentRequest) GetProject() *Project { - if x != nil { - return x.Project - } - return nil -} - -func (x *SystemServiceDetachDocumentRequest) GetClientId() string { - if x != nil { - return x.ClientId - } - return "" -} - -func (x *SystemServiceDetachDocumentRequest) GetDocumentSummary() *DocumentSummary { - if x != nil { - return x.DocumentSummary - } - return nil -} - -type SystemServiceDetachDocumentResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *SystemServiceDetachDocumentResponse) Reset() { - *x = SystemServiceDetachDocumentResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_yorkie_v1_system_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SystemServiceDetachDocumentResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SystemServiceDetachDocumentResponse) ProtoMessage() {} - -func (x *SystemServiceDetachDocumentResponse) ProtoReflect() protoreflect.Message { - mi := &file_yorkie_v1_system_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SystemServiceDetachDocumentResponse.ProtoReflect.Descriptor instead. -func (*SystemServiceDetachDocumentResponse) Descriptor() ([]byte, []int) { - return file_yorkie_v1_system_proto_rawDescGZIP(), []int{1} -} - -var File_yorkie_v1_system_proto protoreflect.FileDescriptor - -var file_yorkie_v1_system_proto_rawDesc = []byte{ - 0x0a, 0x16, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, - 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, - 0x01, 0x0a, 0x22, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, - 0x12, 0x45, 0x0a, 0x10, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x75, 0x6d, - 0x6d, 0x61, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x79, 0x6f, 0x72, - 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x53, - 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x0f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x25, 0x0a, 0x23, 0x53, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x82, - 0x01, 0x0a, 0x0d, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x71, 0x0a, 0x0e, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, - 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x2e, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x63, - 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x42, 0x45, 0x0a, 0x11, 0x64, 0x65, 0x76, 0x2e, 0x79, 0x6f, 0x72, 0x6b, 0x69, - 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x65, - 0x61, 0x6d, 0x2f, 0x79, 0x6f, 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x79, 0x6f, - 0x72, 0x6b, 0x69, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_yorkie_v1_system_proto_rawDescOnce sync.Once - file_yorkie_v1_system_proto_rawDescData = file_yorkie_v1_system_proto_rawDesc -) - -func file_yorkie_v1_system_proto_rawDescGZIP() []byte { - file_yorkie_v1_system_proto_rawDescOnce.Do(func() { - file_yorkie_v1_system_proto_rawDescData = protoimpl.X.CompressGZIP(file_yorkie_v1_system_proto_rawDescData) - }) - return file_yorkie_v1_system_proto_rawDescData -} - -var file_yorkie_v1_system_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_yorkie_v1_system_proto_goTypes = []interface{}{ - (*SystemServiceDetachDocumentRequest)(nil), // 0: yorkie.v1.SystemServiceDetachDocumentRequest - (*SystemServiceDetachDocumentResponse)(nil), // 1: yorkie.v1.SystemServiceDetachDocumentResponse - (*Project)(nil), // 2: yorkie.v1.Project - (*DocumentSummary)(nil), // 3: yorkie.v1.DocumentSummary -} -var file_yorkie_v1_system_proto_depIdxs = []int32{ - 2, // 0: yorkie.v1.SystemServiceDetachDocumentRequest.project:type_name -> yorkie.v1.Project - 3, // 1: yorkie.v1.SystemServiceDetachDocumentRequest.document_summary:type_name -> yorkie.v1.DocumentSummary - 0, // 2: yorkie.v1.SystemService.DetachDocument:input_type -> yorkie.v1.SystemServiceDetachDocumentRequest - 1, // 3: yorkie.v1.SystemService.DetachDocument:output_type -> yorkie.v1.SystemServiceDetachDocumentResponse - 3, // [3:4] is the sub-list for method output_type - 2, // [2:3] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_yorkie_v1_system_proto_init() } -func file_yorkie_v1_system_proto_init() { - if File_yorkie_v1_system_proto != nil { - return - } - file_yorkie_v1_resources_proto_init() - if !protoimpl.UnsafeEnabled { - file_yorkie_v1_system_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SystemServiceDetachDocumentRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_yorkie_v1_system_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SystemServiceDetachDocumentResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_yorkie_v1_system_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_yorkie_v1_system_proto_goTypes, - DependencyIndexes: file_yorkie_v1_system_proto_depIdxs, - MessageInfos: file_yorkie_v1_system_proto_msgTypes, - }.Build() - File_yorkie_v1_system_proto = out.File - file_yorkie_v1_system_proto_rawDesc = nil - file_yorkie_v1_system_proto_goTypes = nil - file_yorkie_v1_system_proto_depIdxs = nil -} diff --git a/api/yorkie/v1/v1connect/cluster.connect.go b/api/yorkie/v1/v1connect/cluster.connect.go new file mode 100644 index 000000000..707d003dd --- /dev/null +++ b/api/yorkie/v1/v1connect/cluster.connect.go @@ -0,0 +1,120 @@ +// +// Copyright 2024 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. + +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: yorkie/v1/cluster.proto + +package v1connect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + v1 "github.com/yorkie-team/yorkie/api/yorkie/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion0_1_0 + +const ( + // ClusterServiceName is the fully-qualified name of the ClusterService service. + ClusterServiceName = "yorkie.v1.ClusterService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // ClusterServiceDetachDocumentProcedure is the fully-qualified name of the ClusterService's + // DetachDocument RPC. + ClusterServiceDetachDocumentProcedure = "/yorkie.v1.ClusterService/DetachDocument" +) + +// ClusterServiceClient is a client for the yorkie.v1.ClusterService service. +type ClusterServiceClient interface { + DetachDocument(context.Context, *connect.Request[v1.ClusterServiceDetachDocumentRequest]) (*connect.Response[v1.ClusterServiceDetachDocumentResponse], error) +} + +// NewClusterServiceClient constructs a client for the yorkie.v1.ClusterService service. By default, +// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and +// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() +// or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewClusterServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ClusterServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &clusterServiceClient{ + detachDocument: connect.NewClient[v1.ClusterServiceDetachDocumentRequest, v1.ClusterServiceDetachDocumentResponse]( + httpClient, + baseURL+ClusterServiceDetachDocumentProcedure, + opts..., + ), + } +} + +// clusterServiceClient implements ClusterServiceClient. +type clusterServiceClient struct { + detachDocument *connect.Client[v1.ClusterServiceDetachDocumentRequest, v1.ClusterServiceDetachDocumentResponse] +} + +// DetachDocument calls yorkie.v1.ClusterService.DetachDocument. +func (c *clusterServiceClient) DetachDocument(ctx context.Context, req *connect.Request[v1.ClusterServiceDetachDocumentRequest]) (*connect.Response[v1.ClusterServiceDetachDocumentResponse], error) { + return c.detachDocument.CallUnary(ctx, req) +} + +// ClusterServiceHandler is an implementation of the yorkie.v1.ClusterService service. +type ClusterServiceHandler interface { + DetachDocument(context.Context, *connect.Request[v1.ClusterServiceDetachDocumentRequest]) (*connect.Response[v1.ClusterServiceDetachDocumentResponse], error) +} + +// NewClusterServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewClusterServiceHandler(svc ClusterServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + clusterServiceDetachDocumentHandler := connect.NewUnaryHandler( + ClusterServiceDetachDocumentProcedure, + svc.DetachDocument, + opts..., + ) + return "/yorkie.v1.ClusterService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case ClusterServiceDetachDocumentProcedure: + clusterServiceDetachDocumentHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedClusterServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedClusterServiceHandler struct{} + +func (UnimplementedClusterServiceHandler) DetachDocument(context.Context, *connect.Request[v1.ClusterServiceDetachDocumentRequest]) (*connect.Response[v1.ClusterServiceDetachDocumentResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("yorkie.v1.ClusterService.DetachDocument is not implemented")) +} diff --git a/api/yorkie/v1/v1connect/system.connect.go b/api/yorkie/v1/v1connect/system.connect.go deleted file mode 100644 index e8557036e..000000000 --- a/api/yorkie/v1/v1connect/system.connect.go +++ /dev/null @@ -1,120 +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. - -// Code generated by protoc-gen-connect-go. DO NOT EDIT. -// -// Source: yorkie/v1/system.proto - -package v1connect - -import ( - connect "connectrpc.com/connect" - context "context" - errors "errors" - v1 "github.com/yorkie-team/yorkie/api/yorkie/v1" - http "net/http" - strings "strings" -) - -// This is a compile-time assertion to ensure that this generated file and the connect package are -// compatible. If you get a compiler error that this constant is not defined, this code was -// generated with a version of connect newer than the one compiled into your binary. You can fix the -// problem by either regenerating this code with an older version of connect or updating the connect -// version compiled into your binary. -const _ = connect.IsAtLeastVersion0_1_0 - -const ( - // SystemServiceName is the fully-qualified name of the SystemService service. - SystemServiceName = "yorkie.v1.SystemService" -) - -// These constants are the fully-qualified names of the RPCs defined in this package. They're -// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. -// -// Note that these are different from the fully-qualified method names used by -// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to -// reflection-formatted method names, remove the leading slash and convert the remaining slash to a -// period. -const ( - // SystemServiceDetachDocumentProcedure is the fully-qualified name of the SystemService's - // DetachDocument RPC. - SystemServiceDetachDocumentProcedure = "/yorkie.v1.SystemService/DetachDocument" -) - -// SystemServiceClient is a client for the yorkie.v1.SystemService service. -type SystemServiceClient interface { - DetachDocument(context.Context, *connect.Request[v1.SystemServiceDetachDocumentRequest]) (*connect.Response[v1.SystemServiceDetachDocumentResponse], error) -} - -// NewSystemServiceClient constructs a client for the yorkie.v1.SystemService service. By default, -// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and -// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() -// or connect.WithGRPCWeb() options. -// -// The URL supplied here should be the base URL for the Connect or gRPC server (for example, -// http://api.acme.com or https://acme.com/grpc). -func NewSystemServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SystemServiceClient { - baseURL = strings.TrimRight(baseURL, "/") - return &systemServiceClient{ - detachDocument: connect.NewClient[v1.SystemServiceDetachDocumentRequest, v1.SystemServiceDetachDocumentResponse]( - httpClient, - baseURL+SystemServiceDetachDocumentProcedure, - opts..., - ), - } -} - -// systemServiceClient implements SystemServiceClient. -type systemServiceClient struct { - detachDocument *connect.Client[v1.SystemServiceDetachDocumentRequest, v1.SystemServiceDetachDocumentResponse] -} - -// DetachDocument calls yorkie.v1.SystemService.DetachDocument. -func (c *systemServiceClient) DetachDocument(ctx context.Context, req *connect.Request[v1.SystemServiceDetachDocumentRequest]) (*connect.Response[v1.SystemServiceDetachDocumentResponse], error) { - return c.detachDocument.CallUnary(ctx, req) -} - -// SystemServiceHandler is an implementation of the yorkie.v1.SystemService service. -type SystemServiceHandler interface { - DetachDocument(context.Context, *connect.Request[v1.SystemServiceDetachDocumentRequest]) (*connect.Response[v1.SystemServiceDetachDocumentResponse], error) -} - -// NewSystemServiceHandler builds an HTTP handler from the service implementation. It returns the -// path on which to mount the handler and the handler itself. -// -// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf -// and JSON codecs. They also support gzip compression. -func NewSystemServiceHandler(svc SystemServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { - systemServiceDetachDocumentHandler := connect.NewUnaryHandler( - SystemServiceDetachDocumentProcedure, - svc.DetachDocument, - opts..., - ) - return "/yorkie.v1.SystemService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case SystemServiceDetachDocumentProcedure: - systemServiceDetachDocumentHandler.ServeHTTP(w, r) - default: - http.NotFound(w, r) - } - }) -} - -// UnimplementedSystemServiceHandler returns CodeUnimplemented from all methods. -type UnimplementedSystemServiceHandler struct{} - -func (UnimplementedSystemServiceHandler) DetachDocument(context.Context, *connect.Request[v1.SystemServiceDetachDocumentRequest]) (*connect.Response[v1.SystemServiceDetachDocumentResponse], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("yorkie.v1.SystemService.DetachDocument is not implemented")) -} diff --git a/client/client.go b/client/client.go index 3f2f082b0..46b39d925 100644 --- a/client/client.go +++ b/client/client.go @@ -193,7 +193,7 @@ func Dial(rpcAddr string, opts ...Option) (*Client, error) { // Dial dials the given rpcAddr. func (c *Client) Dial(rpcAddr string) error { if !strings.Contains(rpcAddr, "://") { - if c.conn.Transport == nil { + if c.options.CertFile == "" { rpcAddr = "http://" + rpcAddr } else { rpcAddr = "https://" + rpcAddr diff --git a/system/client.go b/cluster/client.go similarity index 83% rename from system/client.go rename to cluster/client.go index ef14b8fa4..998f82ee8 100644 --- a/system/client.go +++ b/cluster/client.go @@ -14,9 +14,9 @@ * limitations under the License. */ -// Package system is a package for the system service for communication between +// Package cluster is a package for the cluster service for communication between // nodes in the Yorkie cluster. -package system +package cluster import ( "context" @@ -45,9 +45,9 @@ func WithLogger(logger *zap.Logger) Option { return func(o *Options) { o.Logger = logger } } -// WithInsecure configures insecure option of the client. -func WithInsecure(isInsecure bool) Option { - return func(o *Options) { o.IsInsecure = isInsecure } +// WithSecure configures secure option of the client. +func WithSecure(isSecure bool) Option { + return func(o *Options) { o.IsSecure = isSecure } } // Options configures how we set up the client. @@ -55,15 +55,16 @@ type Options struct { // Logger is the Logger of the client. Logger *zap.Logger - // IsInsecure is whether to disable the TLS connection of the client. - IsInsecure bool + // IsSecure is whether to enable the TLS connection of the client. + IsSecure bool } // Client is a client for admin service. type Client struct { - conn *http.Client - client v1connect.SystemServiceClient - logger *zap.Logger + conn *http.Client + client v1connect.ClusterServiceClient + logger *zap.Logger + isSecure bool } // New creates an instance of Client. @@ -74,7 +75,7 @@ func New(opts ...Option) (*Client, error) { } conn := &http.Client{} - if !options.IsInsecure { + if options.IsSecure { tlsConfig := &tls.Config{MinVersion: tls.VersionTLS12} conn.Transport = &http2.Transport{TLSClientConfig: tlsConfig} } @@ -89,8 +90,9 @@ func New(opts ...Option) (*Client, error) { } return &Client{ - conn: conn, - logger: logger, + conn: conn, + logger: logger, + isSecure: options.IsSecure, }, nil } @@ -111,14 +113,14 @@ func Dial(rpcAddr string, opts ...Option) (*Client, error) { // Dial dials to the admin service. func (c *Client) Dial(rpcAddr string) error { if !strings.Contains(rpcAddr, "://") { - if c.conn.Transport == nil { - rpcAddr = "http://" + rpcAddr - } else { + if c.isSecure { rpcAddr = "https://" + rpcAddr + } else { + rpcAddr = "http://" + rpcAddr } } - c.client = v1connect.NewSystemServiceClient(c.conn, rpcAddr) + c.client = v1connect.NewClusterServiceClient(c.conn, rpcAddr) return nil } @@ -139,7 +141,7 @@ func (c *Client) DetachDocument( ) error { _, err := c.client.DetachDocument( ctx, - withShardKey(connect.NewRequest(&api.SystemServiceDetachDocumentRequest{ + withShardKey(connect.NewRequest(&api.ClusterServiceDetachDocumentRequest{ Project: converter.ToProject(project), ClientId: clientID.String(), DocumentSummary: converter.ToDocumentSummary(&types.DocumentSummary{ diff --git a/server/clients/clients.go b/server/clients/clients.go index 13244c168..7c47ee7b6 100644 --- a/server/clients/clients.go +++ b/server/clients/clients.go @@ -22,9 +22,9 @@ import ( "errors" "github.com/yorkie-team/yorkie/api/types" + "github.com/yorkie-team/yorkie/cluster" "github.com/yorkie-team/yorkie/server/backend" "github.com/yorkie-team/yorkie/server/backend/database" - "github.com/yorkie-team/yorkie/system" ) var ( @@ -38,11 +38,11 @@ var ( // Activate activates the given client. func Activate( ctx context.Context, - db database.Database, + be *backend.Backend, project *types.Project, clientKey string, ) (*database.ClientInfo, error) { - return db.ActivateClient(ctx, project.ID, clientKey) + return be.DB.ActivateClient(ctx, project.ID, clientKey) } // Deactivate deactivates the given client. @@ -52,16 +52,18 @@ func Deactivate( project *types.Project, refKey types.ClientRefKey, ) (*database.ClientInfo, error) { - info, err := FindActiveClientInfo(ctx, be.DB, refKey) + info, err := FindActiveClientInfo(ctx, be, refKey) if err != nil { return nil, err } - systemClient, err := system.Dial(be.Config.GatewayAddr, system.WithInsecure(true)) + // TODO(hackerwins): Introduce cluster client pool. + // - https://connectrpc.com/docs/go/deployment/ + cli, err := cluster.Dial(be.Config.GatewayAddr) if err != nil { return nil, err } - defer systemClient.Close() + defer cli.Close() for docID, clientDocInfo := range info.Documents { if clientDocInfo.Status != database.DocumentAttached { @@ -82,26 +84,21 @@ func Deactivate( return nil, err } - if err := systemClient.DetachDocument(ctx, project, actorID, docID, project.PublicKey, docInfo.Key); err != nil { + if err := cli.DetachDocument(ctx, project, actorID, docID, project.PublicKey, docInfo.Key); err != nil { return nil, err } } - info, err = be.DB.DeactivateClient(ctx, refKey) - if err != nil { - return nil, err - } - - return info, err + return be.DB.DeactivateClient(ctx, refKey) } // FindActiveClientInfo find the active client info by the given ref key. func FindActiveClientInfo( ctx context.Context, - db database.Database, + be *backend.Backend, refKey types.ClientRefKey, ) (*database.ClientInfo, error) { - info, err := db.FindClientInfoByRefKey(ctx, refKey) + info, err := be.DB.FindClientInfoByRefKey(ctx, refKey) if err != nil { return nil, err } diff --git a/server/packs/packs_test.go b/server/packs/packs_test.go index 42a85b642..a207a1b15 100644 --- a/server/packs/packs_test.go +++ b/server/packs/packs_test.go @@ -231,7 +231,7 @@ func TestPacks(t *testing.T) { assert.NoError(t, err) assert.Equal(t, int64(1), docInfo.ServerSeq) - clientInfo, err := clients.FindActiveClientInfo(ctx, testBackend.DB, types.ClientRefKey{ + clientInfo, err := clients.FindActiveClientInfo(ctx, testBackend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) @@ -277,7 +277,7 @@ func TestPacks(t *testing.T) { assert.Equal(t, int64(2), docInfo.ServerSeq) // 2-4. clientInfo.Checkpoint has not been updated - clientInfo, err = clients.FindActiveClientInfo(ctx, testBackend.DB, types.ClientRefKey{ + clientInfo, err = clients.FindActiveClientInfo(ctx, testBackend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) @@ -303,7 +303,7 @@ func TestPacks(t *testing.T) { assert.Equal(t, int64(2), docInfo.ServerSeq) // 3-4. clientInfo.Checkpoint has been updated properly - clientInfo, err = clients.FindActiveClientInfo(ctx, testBackend.DB, types.ClientRefKey{ + clientInfo, err = clients.FindActiveClientInfo(ctx, testBackend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) diff --git a/server/rpc/system_server.go b/server/rpc/cluster_server.go similarity index 75% rename from server/rpc/system_server.go rename to server/rpc/cluster_server.go index 40dc2ceb4..583f02b0d 100644 --- a/server/rpc/system_server.go +++ b/server/rpc/cluster_server.go @@ -35,31 +35,33 @@ import ( "github.com/yorkie-team/yorkie/server/packs" ) -type systemServer struct { +// clusterServer is a server that provides the internal Yorkie cluster service. +// This service is used for communication between nodes in the Yorkie cluster. +type clusterServer struct { backend *backend.Backend } -// newSystemServer creates a new instance of systemServer. -func newSystemServer(backend *backend.Backend) *systemServer { - return &systemServer{ +// newClusterServer creates a new instance of clusterServer. +func newClusterServer(backend *backend.Backend) *clusterServer { + return &clusterServer{ backend: backend, } } // DetachDocument detaches the given document from the given client. -func (s *systemServer) DetachDocument( +func (s *clusterServer) DetachDocument( ctx context.Context, - req *connect.Request[api.SystemServiceDetachDocumentRequest], -) (*connect.Response[api.SystemServiceDetachDocumentResponse], error) { + req *connect.Request[api.ClusterServiceDetachDocumentRequest], +) (*connect.Response[api.ClusterServiceDetachDocumentResponse], error) { actorID, err := time.ActorIDFromHex(req.Msg.ClientId) if err != nil { return nil, err } - documentSummary := converter.FromDocumentSummary(req.Msg.DocumentSummary) + summary := converter.FromDocumentSummary(req.Msg.DocumentSummary) project := converter.FromProject(req.Msg.Project) - locker, err := s.backend.Coordinator.NewLocker(ctx, packs.PushPullKey(project.ID, documentSummary.Key)) + locker, err := s.backend.Coordinator.NewLocker(ctx, packs.PushPullKey(project.ID, summary.Key)) if err != nil { return nil, err } @@ -73,7 +75,7 @@ func (s *systemServer) DetachDocument( } }() - clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend.DB, types.ClientRefKey{ + clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) @@ -83,7 +85,7 @@ func (s *systemServer) DetachDocument( docRefKey := types.DocRefKey{ ProjectID: project.ID, - DocID: documentSummary.ID, + DocID: summary.ID, } docInfo, err := documents.FindDocInfoByRefKey(ctx, s.backend, docRefKey) @@ -91,7 +93,7 @@ func (s *systemServer) DetachDocument( return nil, err } - doc, err := packs.BuildDocForCheckpoint(ctx, s.backend, docInfo, clientInfo.Checkpoint(documentSummary.ID), actorID) + doc, err := packs.BuildDocForCheckpoint(ctx, s.backend, docInfo, clientInfo.Checkpoint(summary.ID), actorID) if err != nil { return nil, err } @@ -118,5 +120,5 @@ func (s *systemServer) DetachDocument( return nil, err } - return connect.NewResponse(&api.SystemServiceDetachDocumentResponse{}), nil + return connect.NewResponse(&api.ClusterServiceDetachDocumentResponse{}), nil } diff --git a/server/rpc/server.go b/server/rpc/server.go index 8031112ea..cdf9e32b0 100644 --- a/server/rpc/server.go +++ b/server/rpc/server.go @@ -73,7 +73,7 @@ func NewServer(conf *Config, be *backend.Backend) (*Server, error) { mux := http.NewServeMux() mux.Handle(v1connect.NewYorkieServiceHandler(newYorkieServer(yorkieServiceCtx, be), opts...)) mux.Handle(v1connect.NewAdminServiceHandler(newAdminServer(be, tokenManager), opts...)) - mux.Handle(v1connect.NewSystemServiceHandler(newSystemServer(be), opts...)) + mux.Handle(v1connect.NewClusterServiceHandler(newClusterServer(be), opts...)) mux.Handle(grpchealth.NewHandler(healthChecker)) mux.Handle(httphealth.NewHandler(healthChecker)) // TODO(hackerwins): We need to provide proper http server configuration. diff --git a/server/rpc/yorkie_server.go b/server/rpc/yorkie_server.go index 88a469448..4408fb38b 100644 --- a/server/rpc/yorkie_server.go +++ b/server/rpc/yorkie_server.go @@ -67,7 +67,7 @@ func (s *yorkieServer) ActivateClient( } project := projects.From(ctx) - cli, err := clients.Activate(ctx, s.backend.DB, project, req.Msg.ClientKey) + cli, err := clients.Activate(ctx, s.backend, project, req.Msg.ClientKey) if err != nil { return nil, err } @@ -145,7 +145,7 @@ func (s *yorkieServer) AttachDocument( } }() - clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend.DB, types.ClientRefKey{ + clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) @@ -221,7 +221,7 @@ func (s *yorkieServer) DetachDocument( } }() - clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend.DB, types.ClientRefKey{ + clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) @@ -320,7 +320,7 @@ func (s *yorkieServer) PushPullChanges( }() } - clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend.DB, types.ClientRefKey{ + clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) @@ -386,7 +386,7 @@ func (s *yorkieServer) WatchDocument( DocID: docID, } - if _, err = clients.FindActiveClientInfo(ctx, s.backend.DB, types.ClientRefKey{ + if _, err = clients.FindActiveClientInfo(ctx, s.backend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(clientID), }); err != nil { @@ -533,7 +533,7 @@ func (s *yorkieServer) RemoveDocument( }() } - clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend.DB, types.ClientRefKey{ + clientInfo, err := clients.FindActiveClientInfo(ctx, s.backend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(actorID), }) @@ -664,7 +664,7 @@ func (s *yorkieServer) Broadcast( return nil, err } - if _, err = clients.FindActiveClientInfo(ctx, s.backend.DB, types.ClientRefKey{ + if _, err = clients.FindActiveClientInfo(ctx, s.backend, types.ClientRefKey{ ProjectID: project.ID, ClientID: types.IDFromActorID(clientID), }); err != nil { From 5528d78c8e6b001e2f2b694ed67f5438dec2dcf5 Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Fri, 18 Oct 2024 13:08:28 +0900 Subject: [PATCH 7/8] Remove gateway variable to prevent mixed use --- build/charts/yorkie-cluster/templates/yorkie/deployment.yaml | 2 +- build/charts/yorkie-cluster/values.yaml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml b/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml index 15de6b065..88807bf9e 100644 --- a/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml +++ b/build/charts/yorkie-cluster/templates/yorkie/deployment.yaml @@ -46,7 +46,7 @@ spec: "--profiling-port", "{{ .Values.yorkie.ports.profilingPort }}", "--backend-gateway-addr", - "{{ .Values.yorkie.gateway }}.{{ .Values.yorkie.namespace }}.svc.cluster.local", + "yorkie-gateway.{{ .Values.yorkie.namespace }}.svc.cluster.local", ] ports: - containerPort: {{ .Values.yorkie.ports.rpcPort }} diff --git a/build/charts/yorkie-cluster/values.yaml b/build/charts/yorkie-cluster/values.yaml index cb82b11b0..204e58d18 100644 --- a/build/charts/yorkie-cluster/values.yaml +++ b/build/charts/yorkie-cluster/values.yaml @@ -3,8 +3,6 @@ yorkie: name: yorkie namespace: yorkie - gateway: yorkie-gateway - autoscaling: enabled: false replicaCount: 3 From f89f6a42649ce07d4cb49e8220dc76944eed982b Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Fri, 18 Oct 2024 13:14:50 +0900 Subject: [PATCH 8/8] Add TODOs --- server/rpc/cluster_server.go | 4 ++++ server/rpc/server.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/server/rpc/cluster_server.go b/server/rpc/cluster_server.go index 583f02b0d..3d86178c0 100644 --- a/server/rpc/cluster_server.go +++ b/server/rpc/cluster_server.go @@ -93,6 +93,9 @@ func (s *clusterServer) DetachDocument( return nil, err } + // TODO(hackerwins): BuildDocForCheckpoint is expensive because it reads the entire document. + // We need to optimize this by creating a ChangePack directly. + // 01. Create ChangePack with clear presence. doc, err := packs.BuildDocForCheckpoint(ctx, s.backend, docInfo, clientInfo.Checkpoint(summary.ID), actorID) if err != nil { return nil, err @@ -105,6 +108,7 @@ func (s *clusterServer) DetachDocument( return nil, err } + // 02. PushPull with the created ChangePack. if _, err := packs.PushPull( ctx, s.backend, diff --git a/server/rpc/server.go b/server/rpc/server.go index cdf9e32b0..8f8719b31 100644 --- a/server/rpc/server.go +++ b/server/rpc/server.go @@ -70,12 +70,16 @@ func NewServer(conf *Config, be *backend.Backend) (*Server, error) { ) yorkieServiceCtx, yorkieServiceCancel := context.WithCancel(context.Background()) + + // TODO(hackerwins): We need to block incoming requests to the cluster service, + // because the cluster service is for internal communication between Yorkie nodes. mux := http.NewServeMux() mux.Handle(v1connect.NewYorkieServiceHandler(newYorkieServer(yorkieServiceCtx, be), opts...)) mux.Handle(v1connect.NewAdminServiceHandler(newAdminServer(be, tokenManager), opts...)) mux.Handle(v1connect.NewClusterServiceHandler(newClusterServer(be), opts...)) mux.Handle(grpchealth.NewHandler(healthChecker)) mux.Handle(httphealth.NewHandler(healthChecker)) + // TODO(hackerwins): We need to provide proper http server configuration. return &Server{ conf: conf,