Open CryptoMaxPlanck opened 1 year ago
To common-ize the database code in Go for the Sanguine project, follow these steps:
Identify Common Code: Review the database code in /services/scribe/db
and /agents/agents/guard/db
, /agents/agents/executor/db
.
Move Common Code: Move common functions, interfaces, and types to /core/dbcommon
. For example, move shared SQL implementations and database interfaces.
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.
Refactor Guard DB: Update /agents/agents/guard/db
to use the common code from /core/dbcommon
. Ensure all database operations utilize the shared code.
Refactor Executor DB: Update /agents/agents/executor/db
to use the common code from /core/dbcommon
. Ensure consistency in database operations.
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"
)
scribe
, guard
, and executor
DB packages pass using the common code.This will reduce code duplication and improve maintainability.
/core/dbcommon /agents/agents/guard/db /services/scribe/db /agents/agents/executor/db /contrib/screener-api/db
Right now, between
sanguine/scribe
andsanguine/agents
, there is a lot of replicated DB code. Some attempts to resolve this have been in #125 where there is a newdbcommon
dir, but it is incomplete, only filling in some helpers and generic functions.