package capacitycontroller

import (
	"context"
	"sync"
)

// StaticAdapter proves that capacity coordination does not require Kubernetes.
// It reports configured fixed replicas and intentionally ignores scale writes.
type StaticAdapter struct {
	mu       sync.RWMutex
	replicas map[string]int
}

var _ OrchestratorAdapter = (*StaticAdapter)(nil)

func NewStaticAdapter(initial map[string]int) *StaticAdapter {
	copyOfInitial := make(map[string]int, len(initial))
	for poolID, replicas := range initial {
		copyOfInitial[poolID] = replicas
	}
	return &StaticAdapter{replicas: copyOfInitial}
}

func (adapter *StaticAdapter) PoolState(_ context.Context, poolID, _ string) (PoolInfrastructureState, error) {
	adapter.mu.RLock()
	replicas := adapter.replicas[poolID]
	adapter.mu.RUnlock()
	return PoolInfrastructureState{
		PoolID: poolID, CurrentReplicas: replicas,
		AllocatableMemoryBytes: 1 << 60, WorkerRequestMemoryBytes: 1,
		AllocatableMilliCPU: 1 << 50, WorkerRequestMilliCPU: 1,
	}, nil
}

func (adapter *StaticAdapter) ScalePool(context.Context, string, string, int) error {
	return nil
}

func (adapter *StaticAdapter) SetInstanceTerminationPriority(context.Context, string, int) error {
	return nil
}
