Documentation ¶
Index ¶
- Variables
- func NewStateStoreWithMiniRedis(t *testing.T) (statestore.FrontendStore, statestore.BackendStore, *miniredis.Miniredis)
- type Assigner
- type AssignerFunc
- type Backend
- type BackendOption
- func WithBackendLogger(logger *slog.Logger) BackendOption
- func WithBackendMeterProvider(provider metric.MeterProvider) BackendOption
- func WithEvaluator(evaluator Evaluator) BackendOption
- func WithFetchTicketsLimit(limit int64) BackendOption
- func WithTicketValidationBeforeAssign(enabled bool) BackendOption
- type BackendOptionFunc
- type Evaluator
- type EvaluatorFunc
- type FrontendOption
- type FrontendOptionFunc
- type FrontendService
- func (s *FrontendService) AcknowledgeBackfill(ctx context.Context, request *pb.AcknowledgeBackfillRequest) (*pb.AcknowledgeBackfillResponse, error)
- func (s *FrontendService) CreateBackfill(ctx context.Context, request *pb.CreateBackfillRequest) (*pb.Backfill, error)
- func (s *FrontendService) CreateTicket(ctx context.Context, req *pb.CreateTicketRequest) (*pb.Ticket, error)
- func (s *FrontendService) DeleteBackfill(ctx context.Context, request *pb.DeleteBackfillRequest) (*emptypb.Empty, error)
- func (s *FrontendService) DeleteTicket(ctx context.Context, req *pb.DeleteTicketRequest) (*emptypb.Empty, error)
- func (s *FrontendService) GetBackfill(ctx context.Context, request *pb.GetBackfillRequest) (*pb.Backfill, error)
- func (s *FrontendService) GetTicket(ctx context.Context, req *pb.GetTicketRequest) (*pb.Ticket, error)
- func (s *FrontendService) UpdateBackfill(ctx context.Context, request *pb.UpdateBackfillRequest) (*pb.Backfill, error)
- func (s *FrontendService) WatchAssignments(req *pb.WatchAssignmentsRequest, ...) error
- type MatchFunction
- type MatchFunctionFunc
- type MiniMatch
- func (m *MiniMatch) AddMatchFunction(profile *pb.MatchProfile, mmf MatchFunction)
- func (m *MiniMatch) FrontendService() pb.FrontendServiceServer
- func (m *MiniMatch) StartBackend(ctx context.Context, assigner Assigner, tickRate time.Duration, ...) error
- func (m *MiniMatch) StartFrontend(listenAddr string) error
- func (m *MiniMatch) TickBackend(ctx context.Context) error
- type TestFrontendServer
- type TestServer
- type TestServerOption
- type TestServerOptionFunc
Constants ¶
This section is empty.
Variables ¶
var MatchFunctionSimple1vs1 = MatchFunctionFunc(func(ctx context.Context, profile *pb.MatchProfile, poolTickets map[string][]*pb.Ticket) ([]*pb.Match, error) { var matches []*pb.Match for _, tickets := range poolTickets { for len(tickets) >= 2 { match := newMatch(profile, tickets[:2]) match.AllocateGameserver = true tickets = tickets[2:] matches = append(matches, match) } } return matches, nil })
Functions ¶
func NewStateStoreWithMiniRedis ¶ added in v0.2.6
func NewStateStoreWithMiniRedis(t *testing.T) (statestore.FrontendStore, statestore.BackendStore, *miniredis.Miniredis)
Types ¶
type Assigner ¶
type Assigner interface {
Assign(ctx context.Context, matches []*pb.Match) ([]*pb.AssignmentGroup, error)
}
Assigner assigns a GameServer info to the established matches.
type AssignerFunc ¶
func (AssignerFunc) Assign ¶
func (f AssignerFunc) Assign(ctx context.Context, matches []*pb.Match) ([]*pb.AssignmentGroup, error)
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func NewBackend ¶
func NewBackend(store statestore.BackendStore, assigner Assigner, opts ...BackendOption) (*Backend, error)
func (*Backend) AddMatchFunction ¶ added in v0.2.0
func (b *Backend) AddMatchFunction(profile *pb.MatchProfile, mmf MatchFunction)
type BackendOption ¶ added in v0.2.0
type BackendOption interface {
// contains filtered or unexported methods
}
func WithBackendLogger ¶ added in v0.2.7
func WithBackendLogger(logger *slog.Logger) BackendOption
func WithBackendMeterProvider ¶ added in v0.2.0
func WithBackendMeterProvider(provider metric.MeterProvider) BackendOption
func WithEvaluator ¶ added in v0.2.0
func WithEvaluator(evaluator Evaluator) BackendOption
func WithFetchTicketsLimit ¶ added in v0.2.0
func WithFetchTicketsLimit(limit int64) BackendOption
FetchTicketsLimit prevents OOM Kill by limiting the number of tickets retrieved at one time. The default is 10000.
func WithTicketValidationBeforeAssign ¶ added in v0.4.0
func WithTicketValidationBeforeAssign(enabled bool) BackendOption
WithTicketValidationBeforeAssign specifies whether to enable to check for the existence of tickets before assigning them. See docs/consistency.md for details.
type BackendOptionFunc ¶ added in v0.2.0
type BackendOptionFunc func(options *backendOptions)
type EvaluatorFunc ¶ added in v0.2.0
type FrontendOption ¶ added in v0.4.0
type FrontendOption interface {
// contains filtered or unexported methods
}
func WithTicketTTL ¶ added in v0.4.0
func WithTicketTTL(ticketTTL time.Duration) FrontendOption
type FrontendOptionFunc ¶ added in v0.4.0
type FrontendOptionFunc func(options *frontendOptions)
type FrontendService ¶
type FrontendService struct {
// contains filtered or unexported fields
}
func NewFrontendService ¶
func NewFrontendService(store statestore.FrontendStore, opts ...FrontendOption) *FrontendService
func (*FrontendService) AcknowledgeBackfill ¶
func (s *FrontendService) AcknowledgeBackfill(ctx context.Context, request *pb.AcknowledgeBackfillRequest) (*pb.AcknowledgeBackfillResponse, error)
func (*FrontendService) CreateBackfill ¶
func (s *FrontendService) CreateBackfill(ctx context.Context, request *pb.CreateBackfillRequest) (*pb.Backfill, error)
func (*FrontendService) CreateTicket ¶
func (s *FrontendService) CreateTicket(ctx context.Context, req *pb.CreateTicketRequest) (*pb.Ticket, error)
func (*FrontendService) DeleteBackfill ¶
func (s *FrontendService) DeleteBackfill(ctx context.Context, request *pb.DeleteBackfillRequest) (*emptypb.Empty, error)
func (*FrontendService) DeleteTicket ¶
func (s *FrontendService) DeleteTicket(ctx context.Context, req *pb.DeleteTicketRequest) (*emptypb.Empty, error)
func (*FrontendService) GetBackfill ¶
func (s *FrontendService) GetBackfill(ctx context.Context, request *pb.GetBackfillRequest) (*pb.Backfill, error)
func (*FrontendService) GetTicket ¶
func (s *FrontendService) GetTicket(ctx context.Context, req *pb.GetTicketRequest) (*pb.Ticket, error)
func (*FrontendService) UpdateBackfill ¶
func (s *FrontendService) UpdateBackfill(ctx context.Context, request *pb.UpdateBackfillRequest) (*pb.Backfill, error)
func (*FrontendService) WatchAssignments ¶
func (s *FrontendService) WatchAssignments(req *pb.WatchAssignmentsRequest, stream pb.FrontendService_WatchAssignmentsServer) error
type MatchFunction ¶
type MatchFunction interface {
MakeMatches(ctx context.Context, profile *pb.MatchProfile, poolTickets map[string][]*pb.Ticket) ([]*pb.Match, error)
}
MatchFunction performs matchmaking based on Ticket for each fetched Pool.
type MatchFunctionFunc ¶
type MatchFunctionFunc func(ctx context.Context, profile *pb.MatchProfile, poolTickets map[string][]*pb.Ticket) ([]*pb.Match, error)
func (MatchFunctionFunc) MakeMatches ¶
type MiniMatch ¶
type MiniMatch struct {
// contains filtered or unexported fields
}
func NewMiniMatch ¶
func NewMiniMatch(frontendStore statestore.FrontendStore, backendStore statestore.BackendStore) *MiniMatch
func NewMiniMatchWithRedis ¶
func NewMiniMatchWithRedis(opts ...statestore.RedisOption) (*MiniMatch, error)
func (*MiniMatch) AddMatchFunction ¶ added in v0.2.0
func (m *MiniMatch) AddMatchFunction(profile *pb.MatchProfile, mmf MatchFunction)
func (*MiniMatch) FrontendService ¶
func (m *MiniMatch) FrontendService() pb.FrontendServiceServer
func (*MiniMatch) StartBackend ¶
func (*MiniMatch) StartFrontend ¶
type TestFrontendServer ¶ added in v0.2.6
type TestFrontendServer struct {
// contains filtered or unexported fields
}
func NewTestFrontendServer ¶ added in v0.2.6
func NewTestFrontendServer(t *testing.T, store statestore.FrontendStore, addr string, opts ...FrontendOption) *TestFrontendServer
func (*TestFrontendServer) Addr ¶ added in v0.2.6
func (ts *TestFrontendServer) Addr() string
func (*TestFrontendServer) Dial ¶ added in v0.2.6
func (ts *TestFrontendServer) Dial(t *testing.T) pb.FrontendServiceClient
func (*TestFrontendServer) Start ¶ added in v0.2.6
func (ts *TestFrontendServer) Start(t *testing.T)
func (*TestFrontendServer) Stop ¶ added in v0.2.6
func (ts *TestFrontendServer) Stop()
type TestServer ¶
type TestServer struct {
// contains filtered or unexported fields
}
func RunTestServer ¶
func RunTestServer(t *testing.T, matchFunctions map[*pb.MatchProfile]MatchFunction, assigner Assigner, opts ...TestServerOption) *TestServer
RunTestServer helps with integration tests using Open Match. It provides an Open Match Frontend equivalent API in the Go process using a random port.
func (*TestServer) DialFrontend ¶
func (ts *TestServer) DialFrontend(t *testing.T) pb.FrontendServiceClient
func (*TestServer) FrontendAddr ¶
func (ts *TestServer) FrontendAddr() string
FrontendAddr returns the address listening as frontend.
func (*TestServer) TickBackend ¶
func (ts *TestServer) TickBackend() error
TickBackend triggers a Director's Tick, which immediately calls Match Function and Assigner. This is useful for sleep-independent testing.
type TestServerOption ¶
type TestServerOption interface {
// contains filtered or unexported methods
}
func WithTestServerBackendOptions ¶ added in v0.2.0
func WithTestServerBackendOptions(backendOptions ...BackendOption) TestServerOption
func WithTestServerBackendTick ¶ added in v0.2.0
func WithTestServerBackendTick(tick time.Duration) TestServerOption
func WithTestServerFrontendOptions ¶ added in v0.4.0
func WithTestServerFrontendOptions(frontendOptions ...FrontendOption) TestServerOption
func WithTestServerListenAddr ¶
func WithTestServerListenAddr(addr string) TestServerOption
type TestServerOptionFunc ¶
type TestServerOptionFunc func(*testServerOptions)