-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add solver database #462
base: main
Are you sure you want to change the base?
Conversation
17f9158
to
9595e94
Compare
e466482
to
821b0d5
Compare
We no longer need the log writers for visibility with the database implementation in place.
821b0d5
to
52fb242
Compare
pkg/jsonl/reader.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the jsonl
implementation because it was only used by the solver store.
pkg/jsonl/writer.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the jsonl
implementation because it was only used by the solver store.
err := CheckWeb3Options(options.Web3) | ||
err := CheckServerOptions(options.Server) | ||
if err != nil { | ||
return err | ||
} | ||
err = CheckStoreOptions(options.Store) | ||
if err != nil { | ||
return err | ||
} | ||
err = CheckServerOptions(options.Server) | ||
err = CheckWeb3Options(options.Web3) | ||
if err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff is slightly confusing here because we reordered the checks, but it's adding CheckStoreOptions
.
@@ -53,14 +57,16 @@ type GetDealsQuery struct { | |||
|
|||
type SolverStore interface { | |||
AddJobOffer(jobOffer data.JobOfferContainer) (*data.JobOfferContainer, error) | |||
AddResourceOffer(jobOffer data.ResourceOfferContainer) (*data.ResourceOfferContainer, error) | |||
AddResourceOffer(resourceOffer data.ResourceOfferContainer) (*data.ResourceOfferContainer, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed this parameter, not a job offer.
We cannot run the solver store database tests while the resource provider is running, so we have separated them out.
5a61d27
to
43705ee
Compare
We need to run the solver integration tests before starting the resource provider for the main integration tests. Also, moved to running the solver and resource provider directly from Go and only running base services in Docker.
43705ee
to
00fb709
Compare
Summary
This pull request makes the following changes:
AddResourceOffer
interface method param name typoThis pull request implements a database store for the solver. We will use it to replace the memory store to persist resource offers, job offers, deals, results, and match decisions.
A database implementation also enables horizontal scaling and a shared store over solver instances.
Task/Issue reference
Closes: #445
Test plan
This pull request switches the solver over to the new database implementation. Start the stack, run a few jobs, examine the database entries, run the integration tests.
Switch to the memory store and check that it continues to work by running a few jobs (see Details below for configuring the store implementation)
We have also included a new test suite to check the memory and database store implementations. Run it with:
Or run all of the solver integration tests:
The solver database integration tests must be run before starting the resource provider for the main integration tests. If the resource provider is running, it deletes the resource provider's offer as part of cleanup and the main integration tests fail.
We have reworked the CI integration tests:
solver
andmain
tagscompose-up
stackWe run the solver integration tests before starting the resource provider and the main integration tests after.
Details
The Solver store is configured with environment variables or CLI options. For example, we configure local development like this:
lilypad/stack
Lines 198 to 200 in 49e4413
The
STORE_TYPE
can bedatabase
ormemory
. When theSTORE_TYPE
isdatabase
, theSTORE_CONN_STR
connection string must be set.STORE_GORM_LOG_LEVEL
must besilent
,info
,error
, orwarn
. The Gorm log level is primarily intended for local development use cases, and we set it tosilent
by default.The help text reports the configuration options like this:
All configurations are validated when running the solver command before starting the service.
Tasks
We have added three new interface methods to remove deals, match decisions, and results:
RemoveDeal
methodRemoveResult
methodRemoveMatchDecision
methodGetResults
methodGetMatchDecisions
methodThe new methods support our testing use case, but also fill out the store interface with methods we may use in the future.
The solver database implementation and test coverage tracked by method:
AddJobOffer
methodAddResourceOffer
methodAddDeal
methodAddResult
methodAddMatchDecision
methodGetJobOffers
methodGetResourceOffers
methodGetDeals
methodGetDealsAll
methodGetResults
methodGetMatchDecisions
methodGetJobOffer
methodGetResourceOffer
methodGetResourceOfferByAddress
methodGetDeal
methodGetResult
methodGetMatchDecision
methodUpdateJobOfferState
methodUpdateResourceOfferState
methodUpdateDealState
methodUpdateDealMediator
methodUpdateDealTransactionsJobCreator
methodUpdateDealTransactionsResourceProvider
methodUpdateDealTransactionsMediator
methodRemoveJobOffer
methodRemoveResourceOffer
methodRemoveDeal
methodRemoveResult
methodRemoveMatchDecision
methodAddJobOffer
coverageAddResourceOffer
coverageAddDeal
coverageAddResult
coverageAddMatchDecision
coverageGetJobOffers
coverageGetResourceOffers
coverageGetDeals
coverageGetDealsAll
coverageGetResults
coverageGetMatchDecisions
coverageGetJobOffer
coverageGetResourceOffer
coverageGetResourceOfferByAddress
coverageGetDeal
coverageGetResult
coverageGetMatchDecision
coverageUpdateJobOfferState
coverageUpdateResourceOfferState
coverageUpdateDealState
coverageUpdateDealMediator
coverageUpdateDealTransactionsJobCreator
coverageUpdateDealTransactionsResourceProvider
coverageUpdateDealTransactionsMediator
coverageRemoveJobOffer
coverageRemoveResourceOffer
coverageRemoveDeal
coverageRemoveResult
coverageRemoveMatchDecision
coverageRelated issues or PRs
Epic: https://github.com/Lilypad-Tech/internal/issues/340