package controller

import (
	"github.com/pingcap/log"
	appworkflow "github.com/tidbcloud/serverless-service/internal/workflow"
)

// WorkflowRunner owns the FastFlow executor lifecycle. It must only be
// constructed in the dedicated "workflow" pod — constructing it elsewhere
// would race the executor across replicas.
type WorkflowRunner struct{}

func NewWorkflowRunner() *WorkflowRunner {
	w := &WorkflowRunner{}
	if err := DiCall(func(_ *appworkflow.Runtime) {}); err != nil {
		panic(err)
	}
	log.Info("FastFlow workflow executor is up")
	return w
}

// Start is a no-op; FastFlow's executor goroutines are spawned by
// fastflow.Init() during NewWorkflowRunner construction. The caller is
// expected to keep the process alive (e.g. via a metrics HTTP server).
func (w *WorkflowRunner) Start() {}
