-
Notifications
You must be signed in to change notification settings - Fork 460
Extract IdempotencyRecord data-model change and JDBC schema v5 #4431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,8 @@ | |
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
|
|
@@ -42,46 +42,36 @@ public interface ModelIdempotencyRecord extends Converter<IdempotencyRecord> { | |
|
|
||
| String TABLE_NAME = "idempotency_records"; | ||
|
|
||
| // Logical tenant / realm identifier. | ||
| String REALM_ID = "realm_id"; | ||
| // Client-provided idempotency key. | ||
| String IDEMPOTENCY_KEY = "idempotency_key"; | ||
| // Logical operation type (e.g. commit-table). | ||
| String OPERATION_TYPE = "operation_type"; | ||
| // Normalized identifier of the affected resource. | ||
| String RESOURCE_ID = "resource_id"; | ||
|
|
||
| // Final HTTP status code once the operation is completed (null while in-progress). | ||
| // Hash of caller principal identity bound to the reservation. | ||
| // Compared on replay to prevent cross-principal cache hits. | ||
| String PRINCIPAL_HASH = "principal_hash"; | ||
|
|
||
| String HTTP_STATUS = "http_status"; | ||
| // Optional error subtype for failures. | ||
| String ERROR_SUBTYPE = "error_subtype"; | ||
| // Short serialized representation of the response body. | ||
|
|
||
| String RESPONSE_SUMMARY = "response_summary"; | ||
| // Serialized representation of response headers. | ||
| String RESPONSE_HEADERS = "response_headers"; | ||
| // Timestamp when the operation was finalized (null while in-progress). | ||
| String FINALIZED_AT = "finalized_at"; | ||
|
|
||
| // Timestamp when the record was created. | ||
| String CREATED_AT = "created_at"; | ||
| // Timestamp when the record was last updated. | ||
| String UPDATED_AT = "updated_at"; | ||
| // Timestamp for the last heartbeat update (null if no heartbeat recorded). | ||
| String HEARTBEAT_AT = "heartbeat_at"; | ||
| // Identifier of the executor that owns the in-progress record (null if not owned). | ||
| String EXECUTOR_ID = "executor_id"; | ||
| // Expiration timestamp after which the record can be considered stale/purgeable. | ||
| String EXPIRES_AT = "expires_at"; | ||
|
Comment on lines
-65
to
64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we removing this comments ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not mind keeping or deleting these comments, but IMHO the value of these comments is pretty low: their meaning is deducible from field names. Specifying behaviour here is not the ideal place, because there's no logic in this code area. Logic for processing the values for these columns exists somewhere else.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree with @dimas-b that these comments are not quite valuable given the field names themselves are descriptive already. +1 on removing them. |
||
|
|
||
| List<String> ALL_COLUMNS = | ||
| List.of( | ||
| IDEMPOTENCY_KEY, | ||
| OPERATION_TYPE, | ||
| RESOURCE_ID, | ||
| PRINCIPAL_HASH, | ||
| HTTP_STATUS, | ||
| ERROR_SUBTYPE, | ||
| RESPONSE_SUMMARY, | ||
| RESPONSE_HEADERS, | ||
| FINALIZED_AT, | ||
| CREATED_AT, | ||
| UPDATED_AT, | ||
|
|
@@ -97,6 +87,8 @@ public interface ModelIdempotencyRecord extends Converter<IdempotencyRecord> { | |
|
|
||
| String getResourceId(); | ||
|
|
||
| String getPrincipalHash(); | ||
|
|
||
| @Nullable | ||
| Integer getHttpStatus(); | ||
|
|
||
|
|
@@ -106,9 +98,6 @@ public interface ModelIdempotencyRecord extends Converter<IdempotencyRecord> { | |
| @Nullable | ||
| String getResponseSummary(); | ||
|
|
||
| @Nullable | ||
| String getResponseHeaders(); | ||
|
|
||
| @Nullable | ||
| Instant getFinalizedAt(); | ||
|
|
||
|
|
@@ -131,7 +120,6 @@ default IdempotencyRecord fromResultSet(ResultSet rs) throws SQLException { | |
|
|
||
| /** Convert the current ResultSet row into an {@link IdempotencyRecord}. */ | ||
| static IdempotencyRecord fromRow(ResultSet rs) throws SQLException { | ||
| // Requires realm_id to be projected in the ResultSet. | ||
| return fromRow(rs.getString(REALM_ID), rs); | ||
| } | ||
|
|
||
|
|
@@ -143,11 +131,11 @@ static IdempotencyRecord fromRow(String realmId, ResultSet rs) throws SQLExcepti | |
| String idempotencyKey = rs.getString(IDEMPOTENCY_KEY); | ||
| String operationType = rs.getString(OPERATION_TYPE); | ||
| String resourceId = rs.getString(RESOURCE_ID); | ||
| String principalHash = rs.getString(PRINCIPAL_HASH); | ||
|
|
||
| Integer httpStatus = (Integer) rs.getObject(HTTP_STATUS); | ||
| String errorSubtype = rs.getString(ERROR_SUBTYPE); | ||
| String responseSummary = rs.getString(RESPONSE_SUMMARY); | ||
| String responseHeaders = rs.getString(RESPONSE_HEADERS); | ||
|
|
||
| Instant createdAt = rs.getTimestamp(CREATED_AT).toInstant(); | ||
| Instant updatedAt = rs.getTimestamp(UPDATED_AT).toInstant(); | ||
|
|
@@ -166,10 +154,10 @@ static IdempotencyRecord fromRow(String realmId, ResultSet rs) throws SQLExcepti | |
| idempotencyKey, | ||
| operationType, | ||
| resourceId, | ||
| principalHash, | ||
| httpStatus, | ||
| errorSubtype, | ||
| responseSummary, | ||
| responseHeaders, | ||
| createdAt, | ||
| updatedAt, | ||
| finalizedAt, | ||
|
|
@@ -184,10 +172,10 @@ default Map<String, Object> toMap(DatabaseType databaseType) { | |
| map.put(IDEMPOTENCY_KEY, getIdempotencyKey()); | ||
| map.put(OPERATION_TYPE, getOperationType()); | ||
| map.put(RESOURCE_ID, getResourceId()); | ||
| map.put(PRINCIPAL_HASH, getPrincipalHash()); | ||
| map.put(HTTP_STATUS, getHttpStatus()); | ||
| map.put(ERROR_SUBTYPE, getErrorSubtype()); | ||
| map.put(RESPONSE_SUMMARY, getResponseSummary()); | ||
| map.put(RESPONSE_HEADERS, getResponseHeaders()); | ||
| map.put(FINALIZED_AT, getFinalizedAt() == null ? null : Timestamp.from(getFinalizedAt())); | ||
| map.put(CREATED_AT, Timestamp.from(getCreatedAt())); | ||
| map.put(UPDATED_AT, Timestamp.from(getUpdatedAt())); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would rather just say authenticated {@PolarisPrincipal} associated with the idempotency record ... something.