mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-12 03:13:42 +00:00
feat: promote accepted proposals from API
This commit is contained in:
@@ -46,3 +46,15 @@ func (p postgresProposalBackend) Respond(ctx context.Context, playerID, proposal
|
||||
func ProposalProviderFromStore(db *sql.DB) ProposalBackend {
|
||||
return postgresProposalBackend{db: db}
|
||||
}
|
||||
|
||||
// ProposalPromoterFromStore turns a durably accepted proposal into its exact
|
||||
// matcher-selected ALLOCATING match. The store chooses a deterministic match
|
||||
// ID so an API retry after a transient failure cannot duplicate the match.
|
||||
func ProposalPromoterFromStore(db *sql.DB) ProposalPromoter {
|
||||
return ProposalPromoterFunc(func(ctx context.Context, proposal domain.Proposal, now time.Time) error {
|
||||
if proposal.State != domain.Accepted {
|
||||
return domain.ErrIllegalTransition
|
||||
}
|
||||
return store.PromoteStoredAcceptedProposal(ctx, db, proposal.ProposalID, now)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user