Skip to content

Refactor store/datastore with common interfaces and helpers#1403

Closed
the-glu wants to merge 1 commit intointeruss:masterfrom
Orbitalize:normalize_datastore
Closed

Refactor store/datastore with common interfaces and helpers#1403
the-glu wants to merge 1 commit intointeruss:masterfrom
Orbitalize:normalize_datastore

Conversation

@the-glu
Copy link
Copy Markdown
Contributor

@the-glu the-glu commented Mar 31, 2026

This PR refactor the store / datastore system into common interfaces and helpers.

(Badly) duplicated code has been removed and everything is now normalized.

There are a few remarks / side effects, noted directly in comments.

Quick summary of changes:

  • Store interface ([db]/store/store.go) moved to a generic one, old one just use the common.
  • Base store in pkg/datastore/store.go that handle all generic part of old stores (e.g creation, Interact/Transact). What is left in [db]/datatore/store.go is special elements (eg. the config flag for scd, Cleanup) and call to BaseStore
  • New helper in pkg/datastoreutils/dial.go that create data stores in a generic way for all DB. Replace all store creation that where in core-service/db-manager (and different in both cases).

The rest is unchanged, this don't redo the whole system but improve the current one.

base, err := datastore.NewBaseStore(ctx, db, flags.ConnectParameters().MaxRetries, func(q dssql.Queryable) repos.Repository {
return &repo{
Queryable: q,
clock: s.Clock,
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.

NB: Tests want to overwrite that, so we create the store, use a pointer there and add the basestore later..

scdV1Server, err = createSCDServer(ctx, logger)
if err != nil {
ridV1Server.Cron.Stop()
ridV2Server.Cron.Stop()
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.

'Hidden' changes: crons that print stats are not stopped anymore if scd fails, but I didn't find a real purpose for that (since it's going to stop anyways)

@the-glu
Copy link
Copy Markdown
Contributor Author

the-glu commented Mar 31, 2026

Moved to smaller PRs

@the-glu the-glu closed this Mar 31, 2026
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