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

Copy link
Copy Markdown
Contributor

Why?

First half of the storage split (see the RFC in the parent PR). The gateway reaches for exactly four stores — the append-only request log and the three read models — and the orchestrator for the other nine, with no crossover in either direction, including through the shared helpers in submitqueue/core/.

What?

submitqueue/gateway/extension/storage/ now holds those four store interfaces, their MySQL implementations and tests, their mocks, and their four .sql files. It declares its own Factory and a four-accessor Storage; the old aggregate drops to nine.

Two conventions this sets for the orchestrator half:

  • Both packages are named storage, so a file needing the shared errors imports the contract package as basestorage. storage.X therefore always means "this service's storage".
  • Config is a type alias (type Config = basestorage.Config), not a new type, so one config value resolves either service's storage.

Also updates two repo-level lists that are invisible from the code: the mocks Makefile target has a hardcoded package list, and queueshard has a hardcoded 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


// 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.

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