synapsecns / sanguine

Synapse Monorepo
MIT License
35 stars 26 forks source link

Common-ize database in go in sanguine #127

Open CryptoMaxPlanck opened 1 year ago

CryptoMaxPlanck commented 1 year ago

Right now, between sanguine/scribe and sanguine/agents, there is a lot of replicated DB code. Some attempts to resolve this have been in #125 where there is a new dbcommon dir, but it is incomplete, only filling in some helpers and generic functions.

greptile-apps[bot] commented 3 weeks ago

To common-ize the database code in Go for the Sanguine project, follow these steps:

  1. Identify Common Code: Review the database code in /services/scribe/db and /agents/agents/guard/db, /agents/agents/executor/db.

  2. Move Common Code: Move common functions, interfaces, and types to /core/dbcommon. For example, move shared SQL implementations and database interfaces.

  3. Refactor Scribe DB: Update /services/scribe/db to use the common code from /core/dbcommon. Replace direct implementations with calls to the common functions and interfaces.

  4. Refactor Guard DB: Update /agents/agents/guard/db to use the common code from /core/dbcommon. Ensure all database operations utilize the shared code.

  5. Refactor Executor DB: Update /agents/agents/executor/db to use the common code from /core/dbcommon. Ensure consistency in database operations.

  6. Update Imports: Ensure all files in scribe, guard, and executor DB packages import the common code from /core/dbcommon.

Example:

// Before
import (
    "github.com/synapsecns/sanguine/services/scribe/db/datastore"
)

// After
import (
    "github.com/synapsecns/sanguine/core/dbcommon"
)
  1. Test: Ensure all tests in scribe, guard, and executor DB packages pass using the common code.

This will reduce code duplication and improve maintainability.

References

/core/dbcommon /agents/agents/guard/db /services/scribe/db /agents/agents/executor/db /contrib/screener-api/db

Ask Greptile