mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
feat: gate allocator roster publication
This commit is contained in:
@@ -18,12 +18,27 @@ type Durable interface {
|
||||
RecordProviderAllocation(context.Context, domain.Allocation, time.Time) (domain.Allocation, error)
|
||||
}
|
||||
|
||||
type RosterPublisher interface {
|
||||
PublishRoster(context.Context, domain.Assignment, []domain.SignedJoinAuthorisation, func([]byte, []byte) bool) error
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
Provider Provider
|
||||
Durable Durable
|
||||
Roster RosterPublisher
|
||||
Now func() time.Time
|
||||
}
|
||||
|
||||
func (s Service) PublishRoster(ctx context.Context, assignment domain.Assignment, roster []domain.SignedJoinAuthorisation, verify func([]byte, []byte) bool) error {
|
||||
if s.Roster == nil {
|
||||
return errNotConfigured
|
||||
}
|
||||
if assignment.Allocation.State != domain.ServerAllocated || assignment.Endpoint == "" {
|
||||
return domain.ErrManifestRejected
|
||||
}
|
||||
return s.Roster.PublishRoster(ctx, assignment, roster, verify)
|
||||
}
|
||||
|
||||
func (s Service) Allocate(ctx context.Context, request domain.AllocationRequest, labels map[string]string) (agones.AllocatedServer, error) {
|
||||
if s.Provider == nil || s.Durable == nil || s.Now == nil {
|
||||
return agones.AllocatedServer{}, errNotConfigured
|
||||
|
||||
Reference in New Issue
Block a user