quarkshologridledger/tongo-core/internal/application/scheduler/scheduler.go

42 lines
1.1 KiB
Go

package scheduler
import (
"context"
"log/slog"
"github.com/costap/quarkshologridledger/tongo-core/internal/domain/entity"
"github.com/costap/quarkshologridledger/tongo-core/internal/domain/port"
)
// Scheduler manages the lifecycle of all active matches.
type Scheduler struct {
matchmaker port.MatchmakerService
matches []*entity.Match
logger *slog.Logger
}
// New creates a new Scheduler instance.
func New(matchmaker port.MatchmakerService, logger *slog.Logger) *Scheduler {
return &Scheduler{
matchmaker: matchmaker,
matches: make([]*entity.Match, 0),
logger: logger,
}
}
// Tick advances the scheduler by one cycle, creating or retiring matches as needed.
func (s *Scheduler) Tick(ctx context.Context) error {
s.logger.Debug("Scheduler tick")
return nil
}
// ActiveMatches returns all currently active matches.
func (s *Scheduler) ActiveMatches() []*entity.Match {
return s.matches
}
// SeedMatches creates initial matches up to the target count.
func (s *Scheduler) SeedMatches(ctx context.Context, count int) error {
s.logger.Info("Seeding initial matches", "count", count)
return nil
}