package v1

import (
	"time"
)

const (
	// RestoreAnnotationKeyPrefix is the prefix for Restore-feature gate annotations.
	// Mirrors BackupAnnotationKeyPrefix for symmetry with backup-side feature gates.
	RestoreAnnotationKeyPrefix = "restore.tidbcloud.com/"

	// RestoreAnnoWaitTimeout carries the duration string that the operator uses
	// as ReplicationConfig.WaitTimeout on the Restore CR. It bounds how long the
	// operator waits for a missing CompactBackup CR to appear (does NOT cap a
	// running compaction). Format: Go duration string, e.g. "5m", "300s".
	RestoreAnnoWaitTimeout = RestoreAnnotationKeyPrefix + "pitr-compaction-wait-timeout"
)

// WaitTimeout parses the RestoreAnnoWaitTimeout annotation and returns the
// duration. Returns 0 and no error if the annotation is absent.
func (r *Restore) WaitTimeout() (time.Duration, error) {
	v := r.Annotations[RestoreAnnoWaitTimeout]
	if v == "" {
		return 0, nil
	}
	return time.ParseDuration(v)
}
