Skip to content

Commit

Permalink
refactor: Use protobuf types in Kingdom Spanner DB
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjayVas committed Sep 13, 2024
1 parent 58bb87d commit af2806d
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/proto/wfa/measurement/internal/kingdom/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_proto//proto:defs.bzl", "proto_descriptor_set", "proto_library")
load(
"@wfa_rules_kotlin_jvm//kotlin:defs.bzl",
"kt_jvm_grpc_proto_library",
Expand Down Expand Up @@ -28,9 +28,7 @@ LIBS = [
"event_group_metadata_descriptor",
"event_group",
"event_template",
"exchange_details",
"exchange",
"exchange_step_attempt_details",
"exchange_step_attempt",
"exchange_step",
"exchange_workflow",
Expand All @@ -49,7 +47,6 @@ LIBS = [
"population",
"protocol_config_config",
"protocol_config",
"recurring_exchange_details",
"recurring_exchange",
"requisition_refusal",
"state_transition_measurement_log_entry",
Expand All @@ -60,8 +57,11 @@ DETAILS_LIBS = [
"computation_participant",
"data_provider",
"duchy_measurement_log_entry",
"exchange",
"event_group_metadata_descriptor",
"event_group",
"exchange_step_attempt",
"recurring_exchange",
"requisition",
"measurement_consumer",
"measurement_log_entry",
Expand Down Expand Up @@ -803,3 +803,11 @@ proto_library(
)
for name in SERVICES
]

proto_descriptor_set(
name = "details_descriptor_set",
deps = [
":{name}_details_proto".format(name = name)
for name in DETAILS_LIBS
],
)
17 changes: 17 additions & 0 deletions src/main/resources/kingdom/spanner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Kingdom Spanner Changelog

Liquibase changelog for the Kingdom Spanner database.

## Protobuf Changes

If the definition of any
[Details message](../../../proto/wfa/measurement/internal/README.md#details-message-types)
in the API changes, it must be accompanied by a changelog entry with the
appropriate `PROTO BUNDLE` DDL statements. See
[Work with protocol buffers in GoogleSQL](https://cloud.google.com/spanner/docs/reference/standard-sql/protocol-buffers).

The serialized `FileDescriptorSet` can be obtained from the
`//src/main/proto/wfa/measurement/internal/kingdom:details_descriptor_set` Bazel
build target. The base64-encoded value of the output can be passed in a `SET
PROTO_DESCRIPTORS` statement, which will apply to the following DDL batch. See
[`create-proto-bundles.sql`](create-proto-bundles.sql) for an example.
3 changes: 3 additions & 0 deletions src/main/resources/kingdom/spanner/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ databaseChangeLog:
- include:
file: reorder-measurements-by-continuation-token.sql
relativeToChangeLogFile: true
- include:
file: create-proto-bundle.sql
relativeToChangeLogFile: true
141 changes: 141 additions & 0 deletions src/main/resources/kingdom/spanner/create-proto-bundles.sql

Large diffs are not rendered by default.

0 comments on commit af2806d

Please sign in to comment.