You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/request/request.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ import (
25
25
// CurrentState holds the current request status obtained from the request log. It is eventually consistent with the request status in the request store. It might take some time to converge, typically no more than a few seconds.
26
26
typeCurrentStatestruct {
27
27
// Status is the current request status obtained from the request log.
28
-
Statusstring
28
+
Statusentity.RequestStatus
29
29
// LastError is the last error associated with the current status.
30
30
LastErrorstring
31
31
// Metadata is the metadata associated with the current status.
@@ -68,7 +68,7 @@ func GetCurrentStateFromRequestLog(ctx context.Context, store storage.RequestLog
68
68
}
69
69
70
70
// A terminal candidate must have a version from the Request entity and a terminal status.
// RequestState defines the possible states of a land request.
33
+
// RequestState defines the possible states of a land request. They are internal and used to implement a state machine. A separate RequestStatus type is used to track the customer-friendly status of a request.
Copy file name to clipboardExpand all lines: entity/request_log.go
+64-3Lines changed: 64 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,64 @@ import (
19
19
"time"
20
20
)
21
21
22
+
// RequestLogStatus defines the possible status of a request. Status is customer-friendly and can be displayed to the user.
23
+
// It is different from the request state, which is internal and used to implement a state machine. Request statuses can be
24
+
// generally added freely by the system without breaking the state machine.
25
+
// Some statuses correspond to the request state, in which case they should be supplemented with the request state version to be used for reconciliation.
26
+
// Other statuses are purely informational and can be added freely.
27
+
// Every status may be accompanied by a last error message and free-formmetadata in the Request Log. It will only be used for display or debugging purposes.
28
+
typeRequestStatusstring
29
+
30
+
const (
31
+
// RequestStatusUnknown is the unknown sentinel status. It is set by default when the structure is initialized. It should never be seen in the system.
32
+
RequestStatusUnknownRequestStatus=""
33
+
34
+
// RequestStatusAccepted indicates that the request has been accepted by the system. Typically a gateway service will set this status when the land request is received and persisted to the logging database.
35
+
RequestStatusAcceptedRequestStatus="accepted"
36
+
37
+
// RequestStatusNew is the initial status of a request. It corresponds to the RequestStateNew state and typically set by the orchestrator service when the request is received and persisted to the operating database.
38
+
RequestStatusNewRequestStatus="new"
39
+
40
+
// RequestStatusValidating indicates that the request is currently being validated (e.g., duplicate check, merge check, etc.).
41
+
RequestStatusValidatingRequestStatus="validating"
42
+
43
+
// RequestStatusValidated indicates that the request has been validated (duplicate check, merge check etc.) successfully. It corresponds to the RequestStateValidated state.
44
+
RequestStatusValidatedRequestStatus="validated"
45
+
46
+
// RequestStatusBatching indicates that the request is waiting to be included in a batch.
47
+
RequestStatusBatchingRequestStatus="batching"
48
+
49
+
// RequestStatusBatched indicates that the request has been included in a new batch and will be sent to speculation.
50
+
RequestStatusBatchedRequestStatus="batched"
51
+
52
+
// RequestStatusSpeculating indicates that the request is currently being speculated (e.g., speculative merge/rebase, etc.).
// RequestStatusSpeculated indicates that the request has been successfully speculated and is ready to be validated via a build system.
56
+
RequestStatusSpeculatedRequestStatus="speculated"
57
+
58
+
// RequestStatusBuilding indicates that the request is currently being built (e.g., CI/CD system is building the change on top of the speculation path).
59
+
RequestStatusBuildingRequestStatus="building"
60
+
61
+
// RequestStatusBuilt indicates that the request has finished the build step successfully and can move to the next phase, either wait for other requests to finish or move to the land phase.
62
+
RequestStatusBuiltRequestStatus="built"
63
+
64
+
// RequestStatusWaitingPath indicates that the request is waiting for other preceiding request in the same speculation path to finish.
// RequestStatusLanding indicates that the request is actively being landed (e.g., source control operation is in progress to push the change to the target branch).
68
+
RequestStatusLandingRequestStatus="landing"
69
+
70
+
// RequestStatusProcessing is the status of a request that is being processed. It corresponds to the RequestStateProcessing state.
71
+
RequestStatusProcessingRequestStatus="processing"
72
+
73
+
// RequestStatusLanded indicates that the request has been successfully processed and landed. It corresponds to the RequestStateLanded state.
74
+
RequestStatusLandedRequestStatus="landed"
75
+
76
+
// RequestStatusError indicates that the request has encountered an error. It corresponds to the RequestStateError state.
77
+
RequestStatusErrorRequestStatus="error"
78
+
)
79
+
22
80
// RequestLog is an append-only record that captures a point-in-time snapshot of a request's status
23
81
// for reconciliation purposes. It is stored in a separate database from the request store to support
24
82
// eventual consistency reconciliation.
@@ -27,8 +85,8 @@ type RequestLog struct {
27
85
RequestIDstring`json:"request_id"`
28
86
// TimestampMs is the time this log entry was created, in milliseconds since Unix epoch.
29
87
TimestampMsint64`json:"timestamp_ms"`
30
-
// Status is the request status at the time this log entry was created. It does not have to correspond to the request status. For example, it may contain intermediate statuses like "validated" or "processing".
31
-
Statusstring`json:"status"`
88
+
// Status is the request status at the time this log entry was created. It may contain requests states from the state machine and also display-friendly intermediate statuses.
89
+
StatusRequestStatus`json:"status"`
32
90
// RequestVersion is the version of the request at the time this log entry was created.
33
91
// Zero if the version is not available.
34
92
RequestVersionint32`json:"request_version"`
@@ -42,7 +100,10 @@ type RequestLog struct {
42
100
43
101
// NewRequestLog creates a new RequestLog with the given fields.
44
102
// TimestampMs is set to the current time. If metadata is nil, it will be initialized as an empty map.
// requestVersion is the version of the request entity, should only be set if reporting a request state as a status, otherwise it should be 0.
104
+
// lastError is the last error message associated with the status at the time of this log entry, empty string if no error.
105
+
// metadata is a set of key-value pairs providing additional context for this log entry. Not constrained to any specific format or schema, used for display or debugging purposes.
// Record the accepted status in the request log for reconciliation. Once the request materializes as a Request entity, the status might be updated to "new".
// It is important to record the status before publishing to the queue for processing. It is important to publish straight to the database and not via a queue.
113
+
// Gateway has to stay consistent with the request log.
0 commit comments