core

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 1 Imported by: 0

README

internal/core

Shared value types used by both the public flexi package and the other internal/* packages.

This package exists purely to break an import cycle: the public flexi package would otherwise need to import the internal/algorithm, rule, etc. packages while those packages need access to Player, Ticket, Match, and Attribute. Putting the types here lets flexi re-export them as type aliases.

Contents

  • AttributeKind, Attribute, Attributes — tagged-union representation of a FlexMatch player attribute (string / number / string_list / string_number_map).
  • Player — a participant in a Ticket, carrying attributes and per-region latencies.
  • Ticket — a matchmaking request (one or more players) plus the time it was enqueued.
  • Match — a successful pairing: team name → players, plus the IDs of the consumed tickets.
  • TicketStatus and its constants (StatusQueued, StatusSearching, StatusRequiresAcceptance, StatusPlacing, StatusCompleted, StatusFailed, StatusCancelled, StatusTimedOut) — the FlexMatch ticket lifecycle values, re-exported via type alias by the public flexi package. Transitions and the acceptance state machine itself live in flexi, not here.
  • StatusReason and its constant StatusReasonAcceptanceFailed — the supplementary reason a ticket carries when it returns to StatusSearching after a proposed match fails acceptance, mirroring MatchmakingTicket.StatusReason.

Notes for contributors

  • This package must stay dependency-free (no imports of other internal/* packages, no third-party libraries) so anyone can import it.
  • New fields here become part of the public API by way of the type aliases in flexi. Treat additions as you would any other public API change.
  • Constructors and helpers belong in the flexi package, not here. Keep this package to plain data types only.

Documentation

Overview

Package core holds value types shared between the public flexi package and the internal sub-packages, defined here to break an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Kind AttributeKind
	S    string
	N    float64
	SL   []string
	SDM  map[string]float64
}

type AttributeKind

type AttributeKind int
const (
	AttrUnknown AttributeKind = iota
	AttrString
	AttrNumber
	AttrStringList
	AttrStringNumberMap
)

type Attributes

type Attributes map[string]Attribute

type Match

type Match struct {
	Teams                 map[string][]Player
	TicketIDs             []string
	RuleEvaluationMetrics []RuleMetric
}

type Player

type Player struct {
	ID         string
	Attributes Attributes
	Latencies  map[string]int
}

type RuleMetric added in v0.0.2

type RuleMetric struct {
	RuleName    string
	PassedCount int
	FailedCount int
}

RuleMetric aggregates how often a single rule passed or failed during matchmaking. It mirrors one entry of FlexMatch's ruleEvaluationMetrics array. RuleName matches the name declared in the rule set's rules block.

type StatusReason added in v0.1.0

type StatusReason string

StatusReason supplies additional context for a ticket's current status, mirroring MatchmakingTicket.StatusReason in the GameLift API. See types.go in the public package for user-facing docs.

const (
	// StatusReasonAcceptanceFailed marks a ticket that has returned to
	// StatusSearching after a proposed match failed to gather the required
	// acceptances — i.e. a sibling player rejected or let the acceptance
	// window time out. It corresponds to FlexMatch re-entering an accepted
	// ticket into matchmaking after a proposed match fails.
	StatusReasonAcceptanceFailed StatusReason = "ACCEPTANCE_FAILED"
)

type Ticket

type Ticket struct {
	ID         string
	Players    []Player
	EnqueuedAt time.Time
}

type TicketStatus

type TicketStatus string

TicketStatus mirrors the FlexMatch ticket lifecycle as documented for MatchmakingTicket.Status. See types.go in the public package for user-facing docs.

const (
	StatusQueued             TicketStatus = "QUEUED"
	StatusSearching          TicketStatus = "SEARCHING"
	StatusRequiresAcceptance TicketStatus = "REQUIRES_ACCEPTANCE"
	StatusPlacing            TicketStatus = "PLACING"
	StatusCompleted          TicketStatus = "COMPLETED"
	StatusFailed             TicketStatus = "FAILED"
	StatusCancelled          TicketStatus = "CANCELLED"
	StatusTimedOut           TicketStatus = "TIMED_OUT"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL