package framework

const OutputInterfaceV2IdStr OutputInterfaceVersion = "OutputInterfaceV2"

// ScaleActionType defines the type of scaling action.
type ScaleActionType int

const (
	ScaleActionNone             ScaleActionType = iota
	ScaleActionAddNodes                         // CreateTiKVCapacityReservation
	ScaleActionExpandDisk                       // ScaleSharedPool (disk expansion)
	ScaleActionExpandIOPS                       // ScaleSharedPool (IOPS expansion)
	ScaleActionExpandThroughput                 // ScaleSharedPool (throughput expansion)
)

// ScaleAction tells the output module which kind of action to perform.
type ScaleAction struct {
	Type                        ScaleActionType
	RequiredDataBytes           uint64
	ReservationID               string
	Trigger                     string
	DiskExpandGB                uint32
	FallbackReservationID       string
	FallbackRequiredDataBytes   uint64
	NewIOPS                     uint32 // for ScaleActionExpandIOPS
	NewThroughputMBps           uint32 // for ScaleActionExpandThroughput
	OnSuccess                   func()
	OnDiskExpandSuccess         func() // called only when ExpandDisk itself succeeds (not on fallback)
	OnDiskExpandFallbackSuccess func() // called only when the fallback reservation reaches READY
	OnFailure                   func(error)
}

// OutputInterfaceV2 extends OutputInterfaceV1 with direct action execution,
// enabling the V2 executor to trigger actions without requiring a topology change.
type OutputInterfaceV2 interface {
	OutputInterfaceV1

	// ExecuteAction executes a scale action directly, independent of any
	// topology change. This is the primary entry point for V2 executors.
	// For topology changes that also carry an action (e.g. AddNodes),
	// the executor calls SetNewClusterTopology with the action attached.
	ExecuteAction(clusterId ClusterId, action *ScaleAction) error

	// SetPendingAction sets a pending scale action for the given shared pool.
	// Deprecated: Used only by the V1 executor path. V2 uses ExecuteAction.
	SetPendingAction(sharedPoolID string, action *ScaleAction)
}
