Documentation
¶
Overview ¶
Package ruleset parses and validates AWS GameLift FlexMatch rule set JSON documents (the same payload accepted by CreateMatchmakingRuleSet).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidRuleSet = errors.New("flexi: invalid rule set")
ErrInvalidRuleSet is returned when the rule set JSON is malformed or fails semantic validation.
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm struct {
Strategy string `json:"strategy,omitempty"`
BatchingPreference string `json:"batchingPreference,omitempty"`
BalancedAttribute string `json:"balancedAttribute,omitempty"`
BackfillPriority string `json:"backfillPriority,omitempty"`
}
Algorithm captures the rule set's algorithm block.
type CompoundStatement ¶
CompoundStatement is the body of a compound rule: a condition combinator applied to a list of child rule names.
type Expansion ¶
type Expansion struct {
Target string `json:"target"`
Steps []ExpansionStep `json:"steps"`
}
Expansion declares a time-driven loosening of a target value.
type ExpansionStep ¶
type ExpansionStep struct {
WaitTimeSeconds int `json:"waitTimeSeconds"`
Value json.RawMessage `json:"value"`
}
ExpansionStep applies Value once WaitTimeSeconds have elapsed.
type PlayerAttribute ¶
type PlayerAttribute struct {
Name string `json:"name"`
Type string `json:"type"`
Default json.RawMessage `json:"default,omitempty"`
}
PlayerAttribute declares a player attribute the rule set will reference.
type Rule ¶
type Rule struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type RuleType `json:"type"`
// comparison / distance / collection
Measurements []string `json:"measurements,omitempty"`
ReferenceValue json.RawMessage `json:"referenceValue,omitempty"`
// comparison
Operation string `json:"operation,omitempty"`
// distance
MaxDistance *float64 `json:"maxDistance,omitempty"`
MinDistance *float64 `json:"minDistance,omitempty"`
// absoluteSort
SortDirection string `json:"sortDirection,omitempty"`
SortAttribute string `json:"sortAttribute,omitempty"`
MapKey string `json:"mapKey,omitempty"`
SortReference string `json:"sortReference,omitempty"`
// batchDistance
BatchAttribute string `json:"batchAttribute,omitempty"`
MaxAttributeDistance *float64 `json:"maxAttributeDistance,omitempty"`
PartyAggregation string `json:"partyAggregation,omitempty"`
// collection
MinCount *int `json:"minCount,omitempty"`
MaxCount *int `json:"maxCount,omitempty"`
// latency
MaxLatency *int `json:"maxLatency,omitempty"`
// compound
Statement *CompoundStatement `json:"statement,omitempty"`
}
Rule is a single rule entry. Fields not relevant to the rule's Type are zero. referenceValue may be a literal number/string OR a property expression string, hence kept as RawMessage to preserve fidelity until evaluation.
type RuleSet ¶
type RuleSet struct {
Name string `json:"name"`
RuleLanguageVersion string `json:"ruleLanguageVersion"`
PlayerAttributes []PlayerAttribute `json:"playerAttributes,omitempty"`
Algorithm Algorithm `json:"algorithm"`
Teams []Team `json:"teams"`
Rules []Rule `json:"rules,omitempty"`
Expansions []Expansion `json:"expansions,omitempty"`
// AcceptanceRequired, when true, holds matches formed by the engine in
// REQUIRES_ACCEPTANCE state until every player on every matched ticket
// has accepted via Matchmaker.Accept. Mirrors the FlexMatch field of the
// same name on MatchmakingConfiguration.
AcceptanceRequired bool `json:"acceptanceRequired,omitempty"`
// AcceptanceTimeoutSeconds bounds how long a proposed match may sit in
// REQUIRES_ACCEPTANCE. When the deadline passes without full acceptance,
// the proposal is discarded and involved tickets move to TIMED_OUT.
// Zero means no timeout. Ignored when AcceptanceRequired is false.
AcceptanceTimeoutSeconds int `json:"acceptanceTimeoutSeconds,omitempty"`
}
RuleSet is the parsed top-level FlexMatch rule set.