Skip to content

refactor(dynamodb): split 7,935-line service.rs into sub-modules#284

Merged
vieiralucas merged 1 commit intomainfrom
worktree-split-dynamodb
Apr 12, 2026
Merged

refactor(dynamodb): split 7,935-line service.rs into sub-modules#284
vieiralucas merged 1 commit intomainfrom
worktree-split-dynamodb

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 12, 2026

Summary

  • Splits monolithic 7,935-line service.rs into 7 focused sub-modules
  • mod.rs (4,829 lines): struct, dispatch, expression evaluation engine, helpers, tests
  • tables.rs (1,378 lines): table CRUD, TTL, tags, backups
  • batch.rs (564 lines): batch/transact operations, PartiQL
  • items.rs (407 lines): PutItem, GetItem, DeleteItem, UpdateItem
  • queries.rs (328 lines): Query, Scan
  • streams.rs (299 lines): endpoints, limits, Kinesis destinations
  • global_tables.rs (281 lines): global table operations

Test plan

  • cargo clippy --workspace --all-targets -- -D warnings passes clean
  • All 92 DynamoDB unit tests pass
  • CI passes
  • Cubic review passes

Summary by cubic

Split the monolithic DynamoDB service.rs into focused sub-modules to improve readability, maintainability, and testability. No behavior changes; APIs stay the same.

  • Refactors
    • Added modules: 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).
    • Kept shared helpers and the expression engine in mod.rs.
    • cargo clippy --workspace --all-targets -- -D warnings passes; all DynamoDB unit tests pass.

Written for commit 2a32f62. Summary will update on new commits.

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)
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

)
})?
.iter()
.filter_map(|r| {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

let state = self.state.read();
let tables: Vec<Value> = state
.global_tables
.values()
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

let body = Self::parse_body(req)?;
validate_optional_string_length(
"exclusiveStartGlobalTableName",
body["ExclusiveStartGlobalTableName"].as_str(),
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

@vieiralucas vieiralucas merged commit 26f334d into main Apr 12, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-split-dynamodb branch April 12, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant