From 44f8ec91b1ddc80da0c6e5ba86e3475113120646 Mon Sep 17 00:00:00 2001 From: Jeehyun Kim Date: Mon, 24 Jun 2024 12:02:51 +0900 Subject: [PATCH] Refactor package structure (#210) --- docker/docker-compose-ci.yml | 2 +- docker/docker-compose.yml | 2 +- .../java/com/example/texteditor/EditorViewModel.kt | 2 +- .../kotlin/dev/yorkie/TestAnnotations.kt | 3 +++ .../kotlin/dev/yorkie/core/PresenceTest.kt | 1 + .../dev/yorkie/document/json/JsonTreeTest.kt | 2 +- .../main/kotlin/dev/yorkie/api/ElementConverter.kt | 2 +- .../kotlin/dev/yorkie/api/PresenceConverter.kt | 4 ++-- yorkie/src/main/kotlin/dev/yorkie/core/Client.kt | 6 ++++-- .../main/kotlin/dev/yorkie/document/Document.kt | 14 +++++++------- .../kotlin/dev/yorkie/document/change/Change.kt | 4 ++-- .../dev/yorkie/document/change/ChangeContext.kt | 2 +- .../yorkie/{core => document/presence}/Presence.kt | 2 +- .../{core => document/presence}/Presences.kt | 2 +- .../test/kotlin/dev/yorkie/api/ConverterTest.kt | 2 +- .../src/test/kotlin/dev/yorkie/core/ClientTest.kt | 1 + 16 files changed, 29 insertions(+), 22 deletions(-) rename yorkie/src/main/kotlin/dev/yorkie/{core => document/presence}/Presence.kt (95%) rename yorkie/src/main/kotlin/dev/yorkie/{core => document/presence}/Presences.kt (97%) diff --git a/docker/docker-compose-ci.yml b/docker/docker-compose-ci.yml index 0ed3e87cc..521172bac 100644 --- a/docker/docker-compose-ci.yml +++ b/docker/docker-compose-ci.yml @@ -2,7 +2,7 @@ version: '3.3' services: yorkie: - image: 'yorkieteam/yorkie:0.4.22' + image: 'yorkieteam/yorkie:0.4.24' container_name: 'yorkie' command: ['server', '--mongo-connection-uri', 'mongodb://mongo:27017'] restart: always diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 98a1fc1e0..fbab26dd3 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.3' services: yorkie: - image: 'yorkieteam/yorkie:0.4.22' + image: 'yorkieteam/yorkie:0.4.24' container_name: 'yorkie' command: ['server', '--enable-pprof'] restart: always diff --git a/examples/texteditor/src/main/java/com/example/texteditor/EditorViewModel.kt b/examples/texteditor/src/main/java/com/example/texteditor/EditorViewModel.kt index fab399d97..e962d0100 100644 --- a/examples/texteditor/src/main/java/com/example/texteditor/EditorViewModel.kt +++ b/examples/texteditor/src/main/java/com/example/texteditor/EditorViewModel.kt @@ -8,11 +8,11 @@ import com.google.gson.Gson import dev.yorkie.core.Client import dev.yorkie.core.Client.SyncMode.Realtime import dev.yorkie.core.Client.SyncMode.RealtimePushOnly -import dev.yorkie.core.PresenceInfo import dev.yorkie.document.Document import dev.yorkie.document.Document.Event.PresenceChanged import dev.yorkie.document.json.JsonText import dev.yorkie.document.operation.OperationInfo +import dev.yorkie.document.presence.PresenceInfo import dev.yorkie.document.time.ActorID import kotlin.random.Random import kotlinx.coroutines.CoroutineScope diff --git a/yorkie/src/androidTest/kotlin/dev/yorkie/TestAnnotations.kt b/yorkie/src/androidTest/kotlin/dev/yorkie/TestAnnotations.kt index c0d26b900..a192f5147 100644 --- a/yorkie/src/androidTest/kotlin/dev/yorkie/TestAnnotations.kt +++ b/yorkie/src/androidTest/kotlin/dev/yorkie/TestAnnotations.kt @@ -2,6 +2,9 @@ package dev.yorkie +/** + * Annotation to prevent TooManyRequestsException in JsonTree-related tests + */ @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) internal annotation class TreeTest diff --git a/yorkie/src/androidTest/kotlin/dev/yorkie/core/PresenceTest.kt b/yorkie/src/androidTest/kotlin/dev/yorkie/core/PresenceTest.kt index dbb469bcd..3a058404d 100644 --- a/yorkie/src/androidTest/kotlin/dev/yorkie/core/PresenceTest.kt +++ b/yorkie/src/androidTest/kotlin/dev/yorkie/core/PresenceTest.kt @@ -8,6 +8,7 @@ import dev.yorkie.document.Document.Event.PresenceChanged import dev.yorkie.document.Document.Event.PresenceChanged.MyPresence import dev.yorkie.document.Document.Event.PresenceChanged.Others import dev.yorkie.document.Document.Event.StreamConnectionChanged +import dev.yorkie.document.presence.PresenceInfo import dev.yorkie.gson import java.util.UUID import junit.framework.TestCase.assertEquals diff --git a/yorkie/src/androidTest/kotlin/dev/yorkie/document/json/JsonTreeTest.kt b/yorkie/src/androidTest/kotlin/dev/yorkie/document/json/JsonTreeTest.kt index 5f6f34873..7296ce4ff 100644 --- a/yorkie/src/androidTest/kotlin/dev/yorkie/document/json/JsonTreeTest.kt +++ b/yorkie/src/androidTest/kotlin/dev/yorkie/document/json/JsonTreeTest.kt @@ -8,7 +8,6 @@ import dev.yorkie.api.toCrdtTree import dev.yorkie.core.Client import dev.yorkie.core.Client.SyncMode.Manual import dev.yorkie.core.GENERAL_TIMEOUT -import dev.yorkie.core.Presence import dev.yorkie.core.createClient import dev.yorkie.core.withTwoClientsAndDocuments import dev.yorkie.document.Document @@ -23,6 +22,7 @@ import dev.yorkie.document.operation.OperationInfo import dev.yorkie.document.operation.OperationInfo.SetOpInfo import dev.yorkie.document.operation.OperationInfo.TreeEditOpInfo import dev.yorkie.document.operation.OperationInfo.TreeStyleOpInfo +import dev.yorkie.document.presence.Presence import dev.yorkie.gson import kotlin.test.assertEquals import kotlin.test.assertIs diff --git a/yorkie/src/main/kotlin/dev/yorkie/api/ElementConverter.kt b/yorkie/src/main/kotlin/dev/yorkie/api/ElementConverter.kt index b7ba77032..f8da74373 100644 --- a/yorkie/src/main/kotlin/dev/yorkie/api/ElementConverter.kt +++ b/yorkie/src/main/kotlin/dev/yorkie/api/ElementConverter.kt @@ -23,7 +23,6 @@ import dev.yorkie.api.v1.treeNode import dev.yorkie.api.v1.treeNodeID import dev.yorkie.api.v1.treeNodes import dev.yorkie.api.v1.treePos -import dev.yorkie.core.P import dev.yorkie.document.crdt.CrdtArray import dev.yorkie.document.crdt.CrdtCounter import dev.yorkie.document.crdt.CrdtCounter.Companion.asCounterValue @@ -47,6 +46,7 @@ import dev.yorkie.document.crdt.RgaTreeSplitPos import dev.yorkie.document.crdt.Rht import dev.yorkie.document.crdt.RhtNode import dev.yorkie.document.crdt.TextValue +import dev.yorkie.document.presence.P import dev.yorkie.document.time.ActorID import dev.yorkie.document.time.TimeTicket.Companion.InitialTimeTicket import dev.yorkie.util.IndexTreeNode diff --git a/yorkie/src/main/kotlin/dev/yorkie/api/PresenceConverter.kt b/yorkie/src/main/kotlin/dev/yorkie/api/PresenceConverter.kt index acff982b8..dfa5ee7dc 100644 --- a/yorkie/src/main/kotlin/dev/yorkie/api/PresenceConverter.kt +++ b/yorkie/src/main/kotlin/dev/yorkie/api/PresenceConverter.kt @@ -2,8 +2,8 @@ package dev.yorkie.api import dev.yorkie.api.v1.presence import dev.yorkie.api.v1.presenceChange -import dev.yorkie.core.P -import dev.yorkie.core.PresenceChange +import dev.yorkie.document.presence.P +import dev.yorkie.document.presence.PresenceChange import dev.yorkie.document.time.ActorID internal typealias PBPresence = dev.yorkie.api.v1.Presence diff --git a/yorkie/src/main/kotlin/dev/yorkie/core/Client.kt b/yorkie/src/main/kotlin/dev/yorkie/core/Client.kt index a81eccb49..331f31ef7 100644 --- a/yorkie/src/main/kotlin/dev/yorkie/core/Client.kt +++ b/yorkie/src/main/kotlin/dev/yorkie/core/Client.kt @@ -24,14 +24,16 @@ import dev.yorkie.api.v1.detachDocumentRequest import dev.yorkie.api.v1.pushPullChangesRequest import dev.yorkie.api.v1.removeDocumentRequest import dev.yorkie.api.v1.watchDocumentRequest -import dev.yorkie.core.Presences.Companion.UninitializedPresences -import dev.yorkie.core.Presences.Companion.asPresences import dev.yorkie.document.Document import dev.yorkie.document.Document.DocumentStatus import dev.yorkie.document.Document.Event.PresenceChanged.MyPresence.Initialized import dev.yorkie.document.Document.Event.PresenceChanged.Others import dev.yorkie.document.Document.Event.StreamConnectionChanged import dev.yorkie.document.Document.Event.SyncStatusChanged +import dev.yorkie.document.presence.P +import dev.yorkie.document.presence.PresenceInfo +import dev.yorkie.document.presence.Presences.Companion.UninitializedPresences +import dev.yorkie.document.presence.Presences.Companion.asPresences import dev.yorkie.document.time.ActorID import dev.yorkie.util.Logger.Companion.log import dev.yorkie.util.OperationResult diff --git a/yorkie/src/main/kotlin/dev/yorkie/document/Document.kt b/yorkie/src/main/kotlin/dev/yorkie/document/Document.kt index 7052159d0..eddbf5896 100644 --- a/yorkie/src/main/kotlin/dev/yorkie/document/Document.kt +++ b/yorkie/src/main/kotlin/dev/yorkie/document/Document.kt @@ -3,13 +3,6 @@ package dev.yorkie.document import androidx.annotation.VisibleForTesting import com.google.protobuf.ByteString import dev.yorkie.api.toSnapshot -import dev.yorkie.core.P -import dev.yorkie.core.Presence -import dev.yorkie.core.PresenceChange -import dev.yorkie.core.PresenceInfo -import dev.yorkie.core.Presences -import dev.yorkie.core.Presences.Companion.UninitializedPresences -import dev.yorkie.core.Presences.Companion.asPresences import dev.yorkie.document.Document.Event.PresenceChanged import dev.yorkie.document.Document.Event.PresenceChanged.MyPresence import dev.yorkie.document.Document.Event.PresenceChanged.Others @@ -25,6 +18,13 @@ import dev.yorkie.document.json.JsonArray import dev.yorkie.document.json.JsonElement import dev.yorkie.document.json.JsonObject import dev.yorkie.document.operation.OperationInfo +import dev.yorkie.document.presence.P +import dev.yorkie.document.presence.Presence +import dev.yorkie.document.presence.PresenceChange +import dev.yorkie.document.presence.PresenceInfo +import dev.yorkie.document.presence.Presences +import dev.yorkie.document.presence.Presences.Companion.UninitializedPresences +import dev.yorkie.document.presence.Presences.Companion.asPresences import dev.yorkie.document.time.ActorID import dev.yorkie.document.time.TimeTicket import dev.yorkie.document.time.TimeTicket.Companion.InitialTimeTicket diff --git a/yorkie/src/main/kotlin/dev/yorkie/document/change/Change.kt b/yorkie/src/main/kotlin/dev/yorkie/document/change/Change.kt index fff50736d..e547f8d03 100644 --- a/yorkie/src/main/kotlin/dev/yorkie/document/change/Change.kt +++ b/yorkie/src/main/kotlin/dev/yorkie/document/change/Change.kt @@ -1,10 +1,10 @@ package dev.yorkie.document.change -import dev.yorkie.core.PresenceChange -import dev.yorkie.core.Presences import dev.yorkie.document.crdt.CrdtRoot import dev.yorkie.document.operation.Operation import dev.yorkie.document.operation.OperationInfo +import dev.yorkie.document.presence.PresenceChange +import dev.yorkie.document.presence.Presences import dev.yorkie.document.time.ActorID /** diff --git a/yorkie/src/main/kotlin/dev/yorkie/document/change/ChangeContext.kt b/yorkie/src/main/kotlin/dev/yorkie/document/change/ChangeContext.kt index ac922cd06..2db4c0b6e 100644 --- a/yorkie/src/main/kotlin/dev/yorkie/document/change/ChangeContext.kt +++ b/yorkie/src/main/kotlin/dev/yorkie/document/change/ChangeContext.kt @@ -1,11 +1,11 @@ package dev.yorkie.document.change -import dev.yorkie.core.PresenceChange import dev.yorkie.document.crdt.CrdtContainer import dev.yorkie.document.crdt.CrdtElement import dev.yorkie.document.crdt.CrdtRoot import dev.yorkie.document.crdt.GCPair import dev.yorkie.document.operation.Operation +import dev.yorkie.document.presence.PresenceChange import dev.yorkie.document.time.TimeTicket /** diff --git a/yorkie/src/main/kotlin/dev/yorkie/core/Presence.kt b/yorkie/src/main/kotlin/dev/yorkie/document/presence/Presence.kt similarity index 95% rename from yorkie/src/main/kotlin/dev/yorkie/core/Presence.kt rename to yorkie/src/main/kotlin/dev/yorkie/document/presence/Presence.kt index 4cdec0fae..59f0bd80b 100644 --- a/yorkie/src/main/kotlin/dev/yorkie/core/Presence.kt +++ b/yorkie/src/main/kotlin/dev/yorkie/document/presence/Presence.kt @@ -1,4 +1,4 @@ -package dev.yorkie.core +package dev.yorkie.document.presence import dev.yorkie.document.change.ChangeContext diff --git a/yorkie/src/main/kotlin/dev/yorkie/core/Presences.kt b/yorkie/src/main/kotlin/dev/yorkie/document/presence/Presences.kt similarity index 97% rename from yorkie/src/main/kotlin/dev/yorkie/core/Presences.kt rename to yorkie/src/main/kotlin/dev/yorkie/document/presence/Presences.kt index e82792193..120dc7ecb 100644 --- a/yorkie/src/main/kotlin/dev/yorkie/core/Presences.kt +++ b/yorkie/src/main/kotlin/dev/yorkie/document/presence/Presences.kt @@ -1,4 +1,4 @@ -package dev.yorkie.core +package dev.yorkie.document.presence import dev.yorkie.document.time.ActorID diff --git a/yorkie/src/test/kotlin/dev/yorkie/api/ConverterTest.kt b/yorkie/src/test/kotlin/dev/yorkie/api/ConverterTest.kt index 2881dfdbb..d1160a695 100644 --- a/yorkie/src/test/kotlin/dev/yorkie/api/ConverterTest.kt +++ b/yorkie/src/test/kotlin/dev/yorkie/api/ConverterTest.kt @@ -3,7 +3,6 @@ package dev.yorkie.api import com.google.protobuf.kotlin.toByteStringUtf8 import dev.yorkie.api.v1.jSONElement import dev.yorkie.api.v1.operation -import dev.yorkie.core.PresenceChange import dev.yorkie.document.Document import dev.yorkie.document.change.Change import dev.yorkie.document.change.ChangeID @@ -40,6 +39,7 @@ import dev.yorkie.document.operation.SetOperation import dev.yorkie.document.operation.StyleOperation import dev.yorkie.document.operation.TreeEditOperation import dev.yorkie.document.operation.TreeStyleOperation +import dev.yorkie.document.presence.PresenceChange import dev.yorkie.document.time.ActorID import dev.yorkie.document.time.ActorID.Companion.INITIAL_ACTOR_ID import dev.yorkie.document.time.TimeTicket diff --git a/yorkie/src/test/kotlin/dev/yorkie/core/ClientTest.kt b/yorkie/src/test/kotlin/dev/yorkie/core/ClientTest.kt index 9931a5650..aaede2b11 100644 --- a/yorkie/src/test/kotlin/dev/yorkie/core/ClientTest.kt +++ b/yorkie/src/test/kotlin/dev/yorkie/core/ClientTest.kt @@ -26,6 +26,7 @@ import dev.yorkie.document.change.Change import dev.yorkie.document.change.ChangeID import dev.yorkie.document.change.ChangePack import dev.yorkie.document.change.CheckPoint +import dev.yorkie.document.presence.PresenceChange import dev.yorkie.document.time.ActorID import dev.yorkie.util.createSingleThreadDispatcher import kotlin.test.assertEquals