refactor(dynamodb): split 7,935-line service.rs into sub-modules#284
refactor(dynamodb): split 7,935-line service.rs into sub-modules#284vieiralucas merged 1 commit intomainfrom
Conversation
Split monolithic service.rs into 7 files following the SSM pattern: - mod.rs: struct, dispatch, expression evaluation, helpers, tests (4,829 lines) - tables.rs: table CRUD, TTL, tags, backups (1,378 lines) - batch.rs: batch/transact operations, PartiQL (564 lines) - items.rs: PutItem, GetItem, DeleteItem, UpdateItem (407 lines) - queries.rs: Query, Scan (328 lines) - streams.rs: endpoints, limits, Kinesis destinations (299 lines) - global_tables.rs: global table operations (281 lines)
There was a problem hiding this comment.
4 issues found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/fakecloud-dynamodb/src/service/streams.rs">
<violation number="1" location="crates/fakecloud-dynamodb/src/service/streams.rs:103">
P1: `update_kinesis_streaming_destination` returns a hard-coded ACTIVE status even when the destination is missing or currently disabled.</violation>
</file>
<file name="crates/fakecloud-dynamodb/src/service/global_tables.rs">
<violation number="1" location="crates/fakecloud-dynamodb/src/service/global_tables.rs:31">
P1: `ReplicationGroup` members without `RegionName` are silently ignored, so invalid input can create a table with an incomplete replica set instead of failing validation.</violation>
<violation number="2" location="crates/fakecloud-dynamodb/src/service/global_tables.rs:155">
P2: `ExclusiveStartGlobalTableName` is validated but ignored, so pagination requests return incorrect slices.</violation>
<violation number="3" location="crates/fakecloud-dynamodb/src/service/global_tables.rs:165">
P2: Listing uses unordered `HashMap::values()` with `take(limit)`, producing nondeterministic result order and unstable pagination.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| Self::ok_json(json!({ | ||
| "TableName": table_name, | ||
| "StreamArn": stream_arn, | ||
| "DestinationStatus": "ACTIVE", |
There was a problem hiding this comment.
P1: update_kinesis_streaming_destination returns a hard-coded ACTIVE status even when the destination is missing or currently disabled.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-dynamodb/src/service/streams.rs, line 103:
<comment>`update_kinesis_streaming_destination` returns a hard-coded ACTIVE status even when the destination is missing or currently disabled.</comment>
<file context>
@@ -0,0 +1,299 @@
+ Self::ok_json(json!({
+ "TableName": table_name,
+ "StreamArn": stream_arn,
+ "DestinationStatus": "ACTIVE",
+ "EnableKinesisStreamingConfiguration": {
+ "ApproximateCreationDateTimePrecision": precision
</file context>
| ) | ||
| })? | ||
| .iter() | ||
| .filter_map(|r| { |
There was a problem hiding this comment.
P1: ReplicationGroup members without RegionName are silently ignored, so invalid input can create a table with an incomplete replica set instead of failing validation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-dynamodb/src/service/global_tables.rs, line 31:
<comment>`ReplicationGroup` members without `RegionName` are silently ignored, so invalid input can create a table with an incomplete replica set instead of failing validation.</comment>
<file context>
@@ -0,0 +1,281 @@
+ )
+ })?
+ .iter()
+ .filter_map(|r| {
+ r["RegionName"].as_str().map(|rn| ReplicaDescription {
+ region_name: rn.to_string(),
</file context>
| let state = self.state.read(); | ||
| let tables: Vec<Value> = state | ||
| .global_tables | ||
| .values() |
There was a problem hiding this comment.
P2: Listing uses unordered HashMap::values() with take(limit), producing nondeterministic result order and unstable pagination.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-dynamodb/src/service/global_tables.rs, line 165:
<comment>Listing uses unordered `HashMap::values()` with `take(limit)`, producing nondeterministic result order and unstable pagination.</comment>
<file context>
@@ -0,0 +1,281 @@
+ let state = self.state.read();
+ let tables: Vec<Value> = state
+ .global_tables
+ .values()
+ .take(limit)
+ .map(|gt| {
</file context>
| let body = Self::parse_body(req)?; | ||
| validate_optional_string_length( | ||
| "exclusiveStartGlobalTableName", | ||
| body["ExclusiveStartGlobalTableName"].as_str(), |
There was a problem hiding this comment.
P2: ExclusiveStartGlobalTableName is validated but ignored, so pagination requests return incorrect slices.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/fakecloud-dynamodb/src/service/global_tables.rs, line 155:
<comment>`ExclusiveStartGlobalTableName` is validated but ignored, so pagination requests return incorrect slices.</comment>
<file context>
@@ -0,0 +1,281 @@
+ let body = Self::parse_body(req)?;
+ validate_optional_string_length(
+ "exclusiveStartGlobalTableName",
+ body["ExclusiveStartGlobalTableName"].as_str(),
+ 3,
+ 255,
</file context>
Summary
service.rsinto 7 focused sub-modulesmod.rs(4,829 lines): struct, dispatch, expression evaluation engine, helpers, teststables.rs(1,378 lines): table CRUD, TTL, tags, backupsbatch.rs(564 lines): batch/transact operations, PartiQLitems.rs(407 lines): PutItem, GetItem, DeleteItem, UpdateItemqueries.rs(328 lines): Query, Scanstreams.rs(299 lines): endpoints, limits, Kinesis destinationsglobal_tables.rs(281 lines): global table operationsTest plan
cargo clippy --workspace --all-targets -- -D warningspasses cleanSummary by cubic
Split the monolithic DynamoDB
service.rsinto focused sub-modules to improve readability, maintainability, and testability. No behavior changes; APIs stay the same.mod.rs(core struct/dispatch/expr eval/helpers/tests),tables.rs(table CRUD, TTL, tags, backups),batch.rs(batch/transact + PartiQL),items.rs(Put/Get/Delete/Update),queries.rs(Query/Scan),streams.rs(endpoints/limits/Kinesis destinations),global_tables.rs(global tables).mod.rs.cargo clippy --workspace --all-targets -- -D warningspasses; all DynamoDB unit tests pass.Written for commit 2a32f62. Summary will update on new commits.