Skip to content

Commit 2732bb2

Browse files
authored
feat(entities) Adds batch entity and batch sql schema (#46)
## Summary feat(entities) Adds batch entity and batch sql schema ## Why? <!-- Why is this change necessary? What is the motivation or justification? --> This sets up batch entity and its corresponding sql schema. This establishes the core concept of a batch that will be used through the system. ## What? * Add a `Batch` entity * Add `batch` mysql schema * Note: `BatchStore` in upcoming PR ## Test Plan ## Issues ## Stack 1. #44 1. @ #46 1. #47 1. #48 1. #49
1 parent 91e968e commit 2732bb2

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

entity/batch.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package entity
2+
3+
// BatchState defines the possible states of a batch.
4+
type BatchState string
5+
6+
const (
7+
// BatchStateUnknown is the unreachable state. It is set by default when the structure is initialized. It should never be seen in the system.
8+
BatchStateUnknown BatchState = ""
9+
// TODO: Add comprehensive list of known batch states.
10+
)
11+
12+
// Batch represents a group of requests to land (merge into target branch of the source control repository).
13+
type Batch struct {
14+
// ID is the globally unique identifier for the batch. Format: "<queue>/batch/<counter_value>".
15+
ID string
16+
// 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.
17+
Queue string
18+
// Contains is a list of land request IDs that are part of this batch.
19+
// Request IDs will always be part of the same queue.
20+
//
21+
// For e.g. - [queueA/1, queueA/2, queueA/3].
22+
//
23+
Contains []string
24+
// Dependencies is a list of batch IDs (and associated metadata) for this batch.
25+
// Dependencies will always be part of the same queue.
26+
//
27+
// For e.g - Consider batches - queueA/batch/1, queueA/batch/2, queueA/batch/3
28+
// such that - queueA/batch/2 and queueA/batch/3 depend on queueA/batch/1
29+
//
30+
// In this case, the Dependencies field for -
31+
// - queueA/batch/1 will be empty
32+
// - queueA/batch/2 will contain queueA/batch/1
33+
// - queueA/batch/3 will contain queueA/batch/1
34+
//
35+
Dependencies []map[string]interface{}
36+
// The state of the batch lifecycle this batch is in.
37+
State BatchState
38+
// Version is the version of the object. It is used for optimistic locking.
39+
// Versioning starts at 1 and is incremented for each change to the object.
40+
Version int32
41+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE TABLE IF NOT EXISTS batch (
2+
id VARCHAR(255) NOT NULL,
3+
queue VARCHAR(255) NOT NULL,
4+
contains JSON NOT NULL,
5+
dependencies JSON NOT NULL,
6+
state VARCHAR(255) NOT NUll,
7+
version INT NOT NULL,
8+
PRIMARY KEY (id)
9+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

0 commit comments

Comments
 (0)