Skip to content

Commit

Permalink
Migrate duchy postgres package to deploy/common (#1103)
Browse files Browse the repository at this point in the history
This migrates duchy postgres package from duchy/deploy/ to
duchy/deploy/common/.
  • Loading branch information
YuhongWang-Amazon authored Jul 19, 2023
1 parent a63b26e commit e34c15b
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ kt_jvm_library(
name = "services",
srcs = glob(["*Service.kt"]),
visibility = [
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres:__pkg__",
"//src/main/kotlin/org/wfanet/measurement/duchy/common/deploy/postgres:__pkg__",
"//src/test/kotlin/org/wfanet/measurement/duchy/deploy/postgres:__pkg__",
],
deps = [
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres/readers",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres/writers",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/readers",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers",
"//src/main/kotlin/org/wfanet/measurement/system/v1alpha:resource_key",
"//src/main/proto/wfa/measurement/internal/duchy:continuation_tokens_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/system/v1alpha:computation_log_entries_service_kt_jvm_grpc_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres
package org.wfanet.measurement.duchy.deploy.common.postgres

import org.wfanet.measurement.common.db.r2dbc.DatabaseClient
import org.wfanet.measurement.common.grpc.grpcRequire
import org.wfanet.measurement.common.identity.IdGenerator
import org.wfanet.measurement.duchy.deploy.postgres.writers.InsertComputationStat
import org.wfanet.measurement.duchy.deploy.common.postgres.writers.InsertComputationStat
import org.wfanet.measurement.internal.duchy.ComputationStatsGrpcKt.ComputationStatsCoroutineImplBase
import org.wfanet.measurement.internal.duchy.CreateComputationStatRequest
import org.wfanet.measurement.internal.duchy.CreateComputationStatResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres
package org.wfanet.measurement.duchy.deploy.common.postgres

import io.grpc.Status
import java.time.Clock
Expand All @@ -28,9 +28,9 @@ import org.wfanet.measurement.common.toDuration
import org.wfanet.measurement.duchy.db.computation.ComputationProtocolStageDetailsHelper
import org.wfanet.measurement.duchy.db.computation.ComputationProtocolStagesEnumHelper
import org.wfanet.measurement.duchy.db.computation.ComputationTypeEnumHelper
import org.wfanet.measurement.duchy.deploy.postgres.readers.ComputationReader
import org.wfanet.measurement.duchy.deploy.postgres.writers.ClaimWork
import org.wfanet.measurement.duchy.deploy.postgres.writers.CreateComputation
import org.wfanet.measurement.duchy.deploy.common.postgres.readers.ComputationReader
import org.wfanet.measurement.duchy.deploy.common.postgres.writers.ClaimWork
import org.wfanet.measurement.duchy.deploy.common.postgres.writers.CreateComputation
import org.wfanet.measurement.duchy.name
import org.wfanet.measurement.duchy.number
import org.wfanet.measurement.duchy.service.internal.ComputationDetailsNotFoundException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres
package org.wfanet.measurement.duchy.deploy.common.postgres

import io.grpc.Status
import org.wfanet.measurement.common.db.r2dbc.DatabaseClient
import org.wfanet.measurement.common.identity.IdGenerator
import org.wfanet.measurement.duchy.deploy.postgres.readers.ContinuationTokenReader
import org.wfanet.measurement.duchy.deploy.postgres.writers.SetContinuationToken
import org.wfanet.measurement.duchy.deploy.common.postgres.readers.ContinuationTokenReader
import org.wfanet.measurement.duchy.deploy.common.postgres.writers.SetContinuationToken
import org.wfanet.measurement.duchy.service.internal.ContinuationTokenInvalidException
import org.wfanet.measurement.duchy.service.internal.ContinuationTokenMalformedException
import org.wfanet.measurement.internal.duchy.ContinuationTokensGrpcKt.ContinuationTokensCoroutineImplBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

package(default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres:__subpackages__",
])

kt_jvm_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres.readers
package org.wfanet.measurement.duchy.deploy.common.postgres.readers

import com.google.protobuf.Timestamp
import java.time.Instant
Expand Down Expand Up @@ -196,7 +196,7 @@ class ComputationReader(
) {
bind("$1", globalComputationId)
}
return readContext.executeQuery(statement).consume(::Computation).firstOrNull()
return readContext.executeQuery(statement).consume(ComputationReader::Computation).firstOrNull()
}

private suspend fun readComputation(
Expand Down Expand Up @@ -229,7 +229,7 @@ class ComputationReader(
bind("$1", externalRequisitionKey.externalRequisitionId)
bind("$2", externalRequisitionKey.requisitionFingerprint)
}
return readContext.executeQuery(statement).consume(::Computation).firstOrNull()
return readContext.executeQuery(statement).consume(ComputationReader::Computation).firstOrNull()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres.readers
package org.wfanet.measurement.duchy.deploy.common.postgres.readers

import kotlinx.coroutines.flow.firstOrNull
import org.wfanet.measurement.common.db.r2dbc.ReadContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres.testing
package org.wfanet.measurement.duchy.deploy.common.postgres.testing

import java.nio.file.Path
import org.wfanet.measurement.common.getJarResourcePath
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

package(default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres:__subpackages__",
])

kt_jvm_library(
name = "writers",
srcs = glob(["*.kt"]),
deps = [
"//src/main/kotlin/org/wfanet/measurement/duchy/db/computation",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres/readers",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/readers",
"//src/main/kotlin/org/wfanet/measurement/duchy/service/internal:internal_exception",
"//src/main/proto/wfa/measurement/internal/duchy:computation_details_kt_jvm_proto",
"//src/main/proto/wfa/measurement/internal/duchy:computation_stats_service_kt_jvm_grpc_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres.writers
package org.wfanet.measurement.duchy.deploy.common.postgres.writers

import com.google.protobuf.Message
import java.time.Duration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres.writers
package org.wfanet.measurement.duchy.deploy.common.postgres.writers

import com.google.protobuf.ByteString
import com.google.protobuf.Message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres.writers
package org.wfanet.measurement.duchy.deploy.common.postgres.writers

import java.time.Instant
import org.wfanet.measurement.common.db.r2dbc.boundStatement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.duchy.deploy.postgres.writers
package org.wfanet.measurement.duchy.deploy.common.postgres.writers

import com.google.protobuf.InvalidProtocolBufferException
import com.google.protobuf.util.Timestamps
import java.time.Instant
import org.wfanet.measurement.common.base64UrlDecode
import org.wfanet.measurement.common.db.r2dbc.boundStatement
import org.wfanet.measurement.common.db.r2dbc.postgres.PostgresWriter
import org.wfanet.measurement.duchy.deploy.postgres.readers.ContinuationTokenReader
import org.wfanet.measurement.duchy.deploy.common.postgres.readers.ContinuationTokenReader
import org.wfanet.measurement.duchy.service.internal.ContinuationTokenInvalidException
import org.wfanet.measurement.duchy.service.internal.ContinuationTokenMalformedException
import org.wfanet.measurement.duchy.service.internal.DuchyInternalException
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/duchy/postgres/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/postgres:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/duchy/deploy/postgres:__subpackages__",
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kt_jvm_test(
srcs = ["DuchySchemaTest.kt"],
test_class = "org.wfanet.measurement.duchy.deploy.postgres.DuchySchemaTest",
deps = [
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres/testing",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/testing",
"@wfa_common_jvm//imports/java/com/google/common/truth",
"@wfa_common_jvm//imports/java/com/opentable/db/postgres:pg_embedded",
"@wfa_common_jvm//imports/java/org/junit",
Expand All @@ -18,8 +18,8 @@ kt_jvm_test(
srcs = ["PostgresContinuationTokensServiceTest.kt"],
test_class = "org.wfanet.measurement.duchy.deploy.postgres.PostgresContinuationTokensServiceTest",
deps = [
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres:services",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres/testing",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres:services",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/testing",
"//src/main/kotlin/org/wfanet/measurement/duchy/service/internal/testing",
"@wfa_common_jvm//imports/java/com/google/common/truth",
"@wfa_common_jvm//imports/java/com/opentable/db/postgres:pg_embedded",
Expand All @@ -34,8 +34,8 @@ kt_jvm_test(
test_class = "org.wfanet.measurement.duchy.deploy.postgres.PostgresComputationStatsServiceTest",
deps = [
"//src/main/kotlin/org/wfanet/measurement/duchy/db/computation/testing",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres:services",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/postgres/testing",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres:services",
"//src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/testing",
"//src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computations",
"//src/main/kotlin/org/wfanet/measurement/duchy/service/internal/testing",
"@wfa_common_jvm//imports/java/com/google/common/truth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.junit.runners.JUnit4
import org.wfanet.measurement.common.db.r2dbc.ResultRow
import org.wfanet.measurement.common.db.r2dbc.boundStatement
import org.wfanet.measurement.common.db.r2dbc.postgres.testing.EmbeddedPostgresDatabaseProvider
import org.wfanet.measurement.duchy.deploy.postgres.testing.Schemata.DUCHY_CHANGELOG_PATH
import org.wfanet.measurement.duchy.deploy.common.postgres.testing.Schemata.DUCHY_CHANGELOG_PATH

@RunWith(JUnit4::class)
class DuchySchemaTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import org.wfanet.measurement.common.identity.RandomIdGenerator
import org.wfanet.measurement.duchy.db.computation.ComputationProtocolStageDetails
import org.wfanet.measurement.duchy.db.computation.ComputationProtocolStages
import org.wfanet.measurement.duchy.db.computation.ComputationTypes
import org.wfanet.measurement.duchy.deploy.postgres.testing.Schemata.DUCHY_CHANGELOG_PATH
import org.wfanet.measurement.duchy.deploy.common.postgres.PostgresComputationStatsService
import org.wfanet.measurement.duchy.deploy.common.postgres.PostgresComputationsService
import org.wfanet.measurement.duchy.deploy.common.postgres.testing.Schemata.DUCHY_CHANGELOG_PATH
import org.wfanet.measurement.duchy.service.internal.testing.ComputationStatsServiceTest
import org.wfanet.measurement.duchy.storage.ComputationStore
import org.wfanet.measurement.duchy.storage.RequisitionStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.wfanet.measurement.common.db.r2dbc.postgres.testing.EmbeddedPostgresDatabaseProvider
import org.wfanet.measurement.common.identity.RandomIdGenerator
import org.wfanet.measurement.duchy.deploy.postgres.testing.Schemata.DUCHY_CHANGELOG_PATH
import org.wfanet.measurement.duchy.deploy.common.postgres.PostgresContinuationTokensService
import org.wfanet.measurement.duchy.deploy.common.postgres.testing.Schemata.DUCHY_CHANGELOG_PATH
import org.wfanet.measurement.duchy.service.internal.testing.ContinuationTokensServiceTest

@RunWith(JUnit4::class)
Expand Down

0 comments on commit e34c15b

Please sign in to comment.