mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
feat(multiplayer): deliver allocated server rosters
This commit is contained in:
@@ -104,11 +104,14 @@ func newAPIService(db *sql.DB, workloadSecret string, indexes ...api.CandidateIn
|
||||
RankedProfileProvider: store.PostgresRankedProfiles{DB: db},
|
||||
TierPolicy: domain.DefaultTierPolicy(),
|
||||
Assignment: api.AssignmentProviderFromStore(db),
|
||||
CandidateIndex: candidateIndex,
|
||||
ProbeRecorder: store.PostgresQueue{DB: db},
|
||||
WorkloadVerify: api.WorkloadVerifierFromSignedToken([]byte(workloadSecret), db),
|
||||
Now: func() time.Time { return time.Now().UTC() },
|
||||
Log: logEvent,
|
||||
Roster: func(ctx context.Context, binding domain.WorkloadBinding, now time.Time) ([][]byte, error) {
|
||||
return store.GetAssignmentRoster(ctx, db, binding.MatchID, binding.ServerID, now)
|
||||
},
|
||||
CandidateIndex: candidateIndex,
|
||||
ProbeRecorder: store.PostgresQueue{DB: db},
|
||||
WorkloadVerify: api.WorkloadVerifierFromSignedToken([]byte(workloadSecret), db),
|
||||
Now: func() time.Time { return time.Now().UTC() },
|
||||
Log: logEvent,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ func main() {
|
||||
imageDigestEnv := options.String("image-digest-env", "COSMIC_CLASH_IMAGE_DIGEST", "environment variable containing this build's sha256 image digest")
|
||||
assignmentReadyAttempts := options.Int("assignment-ready-attempts", 5, "retry attempts for assignment-ready registration after process-ready succeeds (a slow-to-propagate signed roster is not fatal)")
|
||||
assignmentReadyBackoff := options.Duration("assignment-ready-backoff", 2*time.Second, "delay between assignment-ready retry attempts")
|
||||
rosterPath := options.String("roster-path", "", "writable path for the workload-authenticated signed join roster; fetched before the child starts")
|
||||
if err := options.Parse(args[:separator]); err != nil {
|
||||
os.Exit(2)
|
||||
}
|
||||
@@ -75,6 +76,7 @@ func main() {
|
||||
|
||||
AssignmentReadyAttempts: *assignmentReadyAttempts,
|
||||
AssignmentReadyBackoff: *assignmentReadyBackoff,
|
||||
RosterPath: *rosterPath,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "game-server-supervisor: %v\n", err)
|
||||
|
||||
@@ -66,9 +66,12 @@ func main() {
|
||||
RankedProfileProvider: store.PostgresRankedProfiles{DB: db},
|
||||
TierPolicy: domain.DefaultTierPolicy(),
|
||||
Assignment: api.AssignmentProviderFromStore(db),
|
||||
ProbeRecorder: store.PostgresQueue{DB: db},
|
||||
WorkloadVerify: api.WorkloadVerifierFromSignedToken([]byte(*workloadSecret), db),
|
||||
Now: func() time.Time { return time.Now().UTC() },
|
||||
Roster: func(ctx context.Context, binding domain.WorkloadBinding, now time.Time) ([][]byte, error) {
|
||||
return store.GetAssignmentRoster(ctx, db, binding.MatchID, binding.ServerID, now)
|
||||
},
|
||||
ProbeRecorder: store.PostgresQueue{DB: db},
|
||||
WorkloadVerify: api.WorkloadVerifierFromSignedToken([]byte(*workloadSecret), db),
|
||||
Now: func() time.Time { return time.Now().UTC() },
|
||||
}
|
||||
handler := service.Handler()
|
||||
listener, err := net.Listen("tcp", *listen)
|
||||
|
||||
Reference in New Issue
Block a user