mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 13:02:08 +00:00
feat: add ranked season rollover policy
This commit is contained in:
+26
-26
@@ -13,9 +13,9 @@ import (
|
||||
type ResourceKind string
|
||||
|
||||
const (
|
||||
QueueTicket ResourceKind = "queue_ticket"
|
||||
Proposal ResourceKind = "proposal"
|
||||
Match ResourceKind = "match"
|
||||
ResourceQueueTicket ResourceKind = "queue_ticket"
|
||||
ResourceProposal ResourceKind = "proposal"
|
||||
ResourceMatch ResourceKind = "match"
|
||||
)
|
||||
|
||||
type State string
|
||||
@@ -40,8 +40,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrConflict = errors.New("mutation conflict")
|
||||
ErrStaleRevision = errors.New("stale revision")
|
||||
ErrConflict = errors.New("mutation conflict")
|
||||
ErrStaleRevision = errors.New("stale revision")
|
||||
ErrIllegalTransition = errors.New("illegal state transition")
|
||||
)
|
||||
|
||||
@@ -101,11 +101,11 @@ func (r *Record) Apply(idempotencyKey string, payload []byte, expectedRevision u
|
||||
func legalTransition(kind ResourceKind, from, to State) bool {
|
||||
var targets []State
|
||||
switch kind {
|
||||
case QueueTicket:
|
||||
case ResourceQueueTicket:
|
||||
targets = queueTransitions[from]
|
||||
case Proposal:
|
||||
case ResourceProposal:
|
||||
targets = proposalTransitions[from]
|
||||
case Match:
|
||||
case ResourceMatch:
|
||||
targets = matchTransitions[from]
|
||||
default:
|
||||
return false
|
||||
@@ -119,31 +119,31 @@ func legalTransition(kind ResourceKind, from, to State) bool {
|
||||
}
|
||||
|
||||
var queueTransitions = map[State][]State{
|
||||
Queued: {Proposed, Cancelled, Expired},
|
||||
Proposed: {Queued, Accepted, Cancelled, Expired},
|
||||
Accepted: {Queued, Allocating, Cancelled, Failed},
|
||||
Allocating: {ProcessReady, Failed, Cancelled},
|
||||
ProcessReady: {AssignmentReady, Failed, Cancelled},
|
||||
Queued: {Proposed, Cancelled, Expired},
|
||||
Proposed: {Queued, Accepted, Cancelled, Expired},
|
||||
Accepted: {Queued, Allocating, Cancelled, Failed},
|
||||
Allocating: {ProcessReady, Failed, Cancelled},
|
||||
ProcessReady: {AssignmentReady, Failed, Cancelled},
|
||||
AssignmentReady: {Assigned, Failed, Cancelled},
|
||||
Assigned: {Connecting, Failed, Cancelled},
|
||||
Connecting: {Live, Failed, Expired},
|
||||
Live: {ResultPending, Failed},
|
||||
ResultPending: {Completed, Failed},
|
||||
Completed: {}, Cancelled: {}, Expired: {}, Failed: {},
|
||||
Assigned: {Connecting, Failed, Cancelled},
|
||||
Connecting: {Live, Failed, Expired},
|
||||
Live: {ResultPending, Failed},
|
||||
ResultPending: {Completed, Failed},
|
||||
Completed: {}, Cancelled: {}, Expired: {}, Failed: {},
|
||||
}
|
||||
|
||||
var proposalTransitions = map[State][]State{
|
||||
Open: {Accepted, Declined, Expired, Cancelled},
|
||||
Open: {Accepted, Declined, Expired, Cancelled},
|
||||
Accepted: {}, Declined: {}, Expired: {}, Cancelled: {},
|
||||
}
|
||||
|
||||
var matchTransitions = map[State][]State{
|
||||
Allocating: {ProcessReady, Failed, Cancelled},
|
||||
ProcessReady: {AssignmentReady, Failed, Cancelled},
|
||||
Allocating: {ProcessReady, Failed, Cancelled},
|
||||
ProcessReady: {AssignmentReady, Failed, Cancelled},
|
||||
AssignmentReady: {Assigned, Failed, Cancelled},
|
||||
Assigned: {Connecting, Failed, Cancelled},
|
||||
Connecting: {Live, Failed, Cancelled},
|
||||
Live: {ResultPending, Failed},
|
||||
ResultPending: {Completed, Failed},
|
||||
Completed: {}, Cancelled: {}, Failed: {},
|
||||
Assigned: {Connecting, Failed, Cancelled},
|
||||
Connecting: {Live, Failed, Cancelled},
|
||||
Live: {ResultPending, Failed},
|
||||
ResultPending: {Completed, Failed},
|
||||
Completed: {}, Cancelled: {}, Failed: {},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user