Skip to content

Call managers instead of the store from APIs#942

Open
chris124567 wants to merge 9 commits intomasterfrom
christopher/remove-admin-store
Open

Call managers instead of the store from APIs#942
chris124567 wants to merge 9 commits intomasterfrom
christopher/remove-admin-store

Conversation

@chris124567
Copy link
Copy Markdown
Member

Close #938

Copilot AI review requested due to automatic review settings April 16, 2026 18:25
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-project-automation github-project-automation bot moved this to In Progress in Sia Apr 16, 2026
@chris124567 chris124567 changed the title Remove store interface from admin API Call managers from admin API instead of the store Apr 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the admin API’s direct dependency on the persistent store by moving stats/accessors to the appropriate domain managers (accounts, contracts, hosts, slabs, subscriber), aligning with Issue #938.

Changes:

  • Refactors admin API to fetch stats/state via managers instead of an admin.Store interface.
  • Introduces/relocates stats types and thin manager methods for accounts/contracts/hosts/slabs and subscriber state.
  • Updates Postgres store return types and adjusts related tests and wiring (cmd + testutils).

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
testutils/indexer.go Updates admin API construction to pass managers + subscriber instead of store.
cmd/indexd/run.go Updates production wiring for new admin.NewAPI signature.
api/admin/admin.go Removes Store interface usage; routes stats/state through managers/subscriber.
api/admin/types.go Replaces admin-local stats structs with types sourced from domain packages.
api/admin/prometheus.go (Indirectly impacted) Continues to provide Prometheus marshalling via admin response wrapper types.
subscriber/subscriber.go Exposes LastScannedIndex for admin state/metrics without passing store.
accounts/stats.go Adds account/connect-key/app stats types + AccountManager accessors.
accounts/manager.go Extends accounts store interface with stats methods.
contracts/stats.go Adds contracts stats type + ContractManager.ContractsStats accessor.
contracts/manager.go Extends contracts store interface with stats + delete methods; adds manager passthrough.
hosts/stats.go Adds aggregated host stats type + HostManager.AggregatedHostStats accessor.
hosts/manager.go Extends hosts store interface with aggregated stats method.
slabs/stats.go Adds sectors/slabs stats type + SlabManager.SectorStats accessor.
slabs/manager.go Extends slabs store interface and adds manager passthrough for slab/object queries + stats.
persist/postgres/stats.go Changes stats return types to domain types (accounts/hosts/slabs).
persist/postgres/stats_test.go Updates tests to use accounts.AppStats instead of admin types.
persist/postgres/contracts.go Changes contracts stats return type to contracts.ContractsStats.
persist/postgres/contracts_test.go Updates expected stats type to contracts.ContractsStats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread persist/postgres/stats.go
Comment thread api/admin/admin.go
Comment thread hosts/stats.go Outdated
@chris124567 chris124567 changed the title Call managers from admin API instead of the store Call managers instead of the store from admin API Apr 16, 2026
@chris124567 chris124567 changed the title Call managers instead of the store from admin API Call managers instead of the store from APIs Apr 16, 2026
Copy link
Copy Markdown
Member

@peterjan peterjan left a comment

Choose a reason for hiding this comment

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

All our managers accept a context parameter but most don't do anything with it because our store methods don't take a context. We should consider removing all of those from the managers as well

Comment thread api/admin/admin.go Outdated
Comment thread api/admin/types.go Outdated
ChrisSchinnerl
ChrisSchinnerl previously approved these changes Apr 20, 2026
Copy link
Copy Markdown
Member

@ChrisSchinnerl ChrisSchinnerl left a comment

Choose a reason for hiding this comment

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

Lgtm. It doesn't fix the "silliness" as we have somehow started to call it but that's fine imo. It gets rid of the store fields and that's really the point of this PR.

@chris124567 chris124567 requested a review from peterjan April 21, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Move stats functions to respective managers

4 participants