feat: make proposal responses durable

This commit is contained in:
Josh Creek
2026-09-01 07:52:52 +01:00
parent 30b4560bd5
commit eef7cf28da
6 changed files with 228 additions and 16 deletions
+9 -4
View File
@@ -7,10 +7,15 @@ import (
func TestProposalRecoverySQLBindsParticipantAndExpiresAtReadBoundary(t *testing.T) {
for query, fragments := range map[string][]string{
ProposalExpireSQL: {"state = 'OPEN'", "expires_at <= $2", "revision = revision + 1"},
ProposalParticipantExpireSQL: {"response = 'PENDING'", "response = 'TIMED_OUT'"},
ProposalRecoverySelectSQL: {"proposal_id = $1", "player_id = $2", "EXISTS"},
ProposalParticipantsSelectSQL: {"proposal_id = $1", "ORDER BY player_id"},
ProposalExpireSQL: {"state = 'OPEN'", "expires_at <= $2", "revision = revision + 1"},
ProposalParticipantExpireSQL: {"response = 'PENDING'", "response = 'TIMED_OUT'"},
ProposalRecoverySelectSQL: {"proposal_id = $1", "player_id = $2", "EXISTS"},
ProposalParticipantsSelectSQL: {"proposal_id = $1", "ORDER BY player_id"},
ProposalResponseIdempotencyInsertSQL: {"ON CONFLICT (scope, idempotency_key) DO NOTHING", "payload_digest"},
ProposalLockSQL: {"proposal_id = $1", "FOR UPDATE"},
ProposalParticipantLockSQL: {"proposal_id = $1", "player_id = $2", "FOR UPDATE"},
ProposalParticipantRespondSQL: {"response = 'PENDING'", "responded_at"},
ProposalRevisionBumpSQL: {"revision = revision + 1", "state = 'OPEN'"},
} {
for _, fragment := range fragments {
if !contains(query, fragment) {