Skip to content

refactor(storage): move the gateway's four stores into submitqueue/gateway/extension/storage - #741

Open
roychying wants to merge 1 commit into
chenghan.ying/service-scoped-extensions-rfcfrom
chenghan.ying/sq-storage-1-gateway
Open

roychying wants to merge 1 commit into
chenghan.ying/service-scoped-extensions-rfcfrom
chenghan.ying/sq-storage-1-gateway

Conversation

@roychying

@roychying roychying commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Why?

First half of the split. The gateway resolves exactly four stores — the append-only request log and the three read models — and the orchestrator the other nine, with no overlap in either direction.

What?

submitqueue/gateway/extension/storage/ gains its own Factory and a four-accessor Storage, plus the four MySQL implementations, their tests and their four .sql files. The old aggregate drops to nine accessors.

The thirteen store contracts and their mocks stay at submitqueue/extension/storage/. That package keeps its import path, so callers naming only a contract or an error are untouched.

Also adds a union schema target (//submitqueue/extension/storage:schema) plus a testutil helper, so colocated callers name no service directory, and narrows each per-service integration suite to its own schema.

Two repo-level lists needed the new package, neither discoverable from the code: the mocks Makefile target and queueshard's schemaRoots.

Test Plan

  • go build ./..., go vet ./..., make lint, make check-mocks, make check-gazelle, make check-tidy all clean; make test passes 121/121.
  • queueshard still reports 25 tables.

Issue

@roychying
roychying added this pull request to stack #742 September 22, 2026 23:11

@behinddwalls behinddwalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agent-written.

The service aggregate/schema split is right. These comments cover the remaining differences from the proposed structure.

// the binding are rejected, and reads never surface another queue's records.
type Storage interface {
// GetRequestLogStore returns the RequestLogStore instance.
GetRequestLogStore() RequestLogStore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agent-written.

Keep store interfaces in submitqueue/extension/storage/; move only the service aggregate, implementation, mocks, and schema. The 4-accessor gateway Storage already enforces the boundary.

"github.com/uber/submitqueue/submitqueue/entity"
"github.com/uber/submitqueue/submitqueue/extension/storage"
basestorage "github.com/uber/submitqueue/submitqueue/extension/storage"
storage "github.com/uber/submitqueue/submitqueue/gateway/extension/storage"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agent-written.

This is the dependency inversion caused by moving the interfaces: domain core/ now imports a service package. Keeping the interfaces in the domain storage contract avoids it.

@roychying roychying Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But even if we keep the store interfaces in domain level, Materializer still takes Factory and resolves per queue (m.stores.For(...{QueueName: log.Queue})), so it imports gateway/extension/storage either way. Same for terminate.go, batch/{find,list,transition}.go and changeset/resolver.go, which also take aggregates. I don't think we can actually avoid importing a service package here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i guess the question is? should this also be moved to gateway now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Technically yes. This is the last section of the RFC (#740). I'd raised it there as a follow-on for a later stage and keep this stack focusing on the schema refactor. Happy to fold it in here if you like.


// Apply schemas programmatically to application database
testutil.ApplySchema(t, s.log, s.db, testutil.SchemaDir("submitqueue/extension/storage/mysql/schema"))
testutil.ApplySchema(t, s.log, s.db, testutil.SchemaDir("submitqueue/gateway/extension/storage/mysql/schema"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agent-written.

The orchestrator suite should not provision gateway tables. Removing this is a useful test that the 9-store service boundary is complete.

@@ -0,0 +1,5 @@
filegroup(
name = "schema",
srcs = glob(["*.sql"]),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agent-written.

Please also expose a union schema target for colocated deployments. Separate service schemas are opt-in; e2e/local should not need to know every service schema directory.

@behinddwalls behinddwalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agent-written.

Requesting changes: the 4-accessor gateway aggregate and schema split are right, but store interfaces should stay in submitqueue/extension/storage/. core/ importing gateway storage is the inversion to avoid. Also drop gateway schema from the orchestrator suite and add a union schema target for colocated deploys.

Comment thread submitqueue/core/request/request.go Outdated
"github.com/uber/submitqueue/submitqueue/entity"
"github.com/uber/submitqueue/submitqueue/extension/storage"
basestorage "github.com/uber/submitqueue/submitqueue/extension/storage"
storage "github.com/uber/submitqueue/submitqueue/gateway/extension/storage"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same for this? should this be in gateway now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as Materializer

@roychying
roychying force-pushed the chenghan.ying/sq-storage-1-gateway branch from 5806046 to d638ec2 Compare September 23, 2026 19:22

This branch has not been deployed

No deployments
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.

2 participants