From 50a9e2640eb2cdec832db495eb2c222a626b243f Mon Sep 17 00:00:00 2001 From: manjari Date: Mon, 23 Feb 2026 22:55:42 +0000 Subject: [PATCH 1/3] feat(entities) Adds batch entity and batch sql schema --- entity/batch.go | 21 +++++++++++++++++++++ extension/storage/mysql/schema/batch.sql | 9 +++++++++ 2 files changed, 30 insertions(+) create mode 100644 entity/batch.go create mode 100644 extension/storage/mysql/schema/batch.sql diff --git a/entity/batch.go b/entity/batch.go new file mode 100644 index 00000000..0c91baf8 --- /dev/null +++ b/entity/batch.go @@ -0,0 +1,21 @@ +package entity + +// Batch represents a group of requests to land (merge into target branch of the source control repository). +type Batch struct { + // ID is the globally unique identifier for the batch. Format: "/batch/". + ID string + // Queue is the name of the queue processing the land request. Queue name is defined in the configuration and should be unique within the system. + Queue string + // Contains is a list of land request IDs that are part of this batch. + // Request IDs will always be part of the same queue. + // For e.g. - [queueA/1, queueA/2, queueA/3]. + Contains []string + // Dependencies is a list of batch IDs (and associated metdata) for this batch. + // Dependencies will always be part of the same queue. + Dependencies []map[string]interface{} + // The state of the batch lifecycle this batch is in. + State string + // Version is the version of the object. It is used for optimistic locking. + // Versioning starts at 1 and is incremented for each change to the object. + Version int32 +} diff --git a/extension/storage/mysql/schema/batch.sql b/extension/storage/mysql/schema/batch.sql new file mode 100644 index 00000000..c8eb1cdd --- /dev/null +++ b/extension/storage/mysql/schema/batch.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS batch ( + id VARCHAR(255) NOT NULL, + queue VARCHAR(255) NOT NULL, + contains JSON NOT NULL, + dependencies JSON NOT NULL, + state VARCHAR(255) NOT NUll, + version INT NOT NULL, + PRIMARY KEY (id,queue) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; From 6ef886885a440b2c7c05500b3751accb82fb4060 Mon Sep 17 00:00:00 2001 From: manjari Date: Mon, 23 Feb 2026 23:18:47 +0000 Subject: [PATCH 2/3] address comments --- entity/batch.go | 24 ++++++++++++++++++++++-- extension/storage/mysql/schema/batch.sql | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/entity/batch.go b/entity/batch.go index 0c91baf8..91e102aa 100644 --- a/entity/batch.go +++ b/entity/batch.go @@ -1,5 +1,14 @@ package entity +// BatchState defines the possible states of a batch. +type BatchState string + +const ( + // BatchStateUnknown is the unreachable state. It is set by default when the structure is initialized. It should never be seen in the system. + BatchStateUnknown BatchState = "" + // TODO: Add comprehensive list of known batch states. +) + // Batch represents a group of requests to land (merge into target branch of the source control repository). type Batch struct { // ID is the globally unique identifier for the batch. Format: "/batch/". @@ -8,13 +17,24 @@ type Batch struct { Queue string // Contains is a list of land request IDs that are part of this batch. // Request IDs will always be part of the same queue. + // // For e.g. - [queueA/1, queueA/2, queueA/3]. + // Contains []string - // Dependencies is a list of batch IDs (and associated metdata) for this batch. + // Dependencies is a list of batch IDs (and associated metadata) for this batch. // Dependencies will always be part of the same queue. + // + // For e.g - Consider batches - queueA/batch/1, queueA/batch/2, queueA/batch/3 + // such that - queueA/batch/2 and queueA/batch/3 depend on queueA/batch/1 + // + // In this case, the Dependencies field for - + // - queueA/batch/1 will be empty + // - queueA/batch/2 will contain queueA/batch/1 + // - queueA/batch/3 will contain queueA/batch/1 + // Dependencies []map[string]interface{} // The state of the batch lifecycle this batch is in. - State string + State BatchState // Version is the version of the object. It is used for optimistic locking. // Versioning starts at 1 and is incremented for each change to the object. Version int32 diff --git a/extension/storage/mysql/schema/batch.sql b/extension/storage/mysql/schema/batch.sql index c8eb1cdd..0b12e792 100644 --- a/extension/storage/mysql/schema/batch.sql +++ b/extension/storage/mysql/schema/batch.sql @@ -5,5 +5,5 @@ CREATE TABLE IF NOT EXISTS batch ( dependencies JSON NOT NULL, state VARCHAR(255) NOT NUll, version INT NOT NULL, - PRIMARY KEY (id,queue) + PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; From 9e838f11e8ee77cb4809e27a91a02b18c964ff78 Mon Sep 17 00:00:00 2001 From: manjari Date: Tue, 24 Feb 2026 01:57:56 +0000 Subject: [PATCH 3/3] gazelle --- entity/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/entity/BUILD.bazel b/entity/BUILD.bazel index ffef8f95..13e8326a 100644 --- a/entity/BUILD.bazel +++ b/entity/BUILD.bazel @@ -3,6 +3,7 @@ load("@rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "entity", srcs = [ + "batch.go", "change_provider.go", "request.go", ],