package zero

import (
	"go.opentelemetry.io/otel"

	zerov1beta1 "github.com/tidbcloud/tidb-management-service/api/spec/tidb_cloud_open_api/zero/v1beta1"
	"github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/repository"
	serverlessclustersvc "github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/service/serverless/cluster"
	"github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/pkg/config"
)

var tracer = otel.Tracer("App.OpenAPI.Zero")

// Server extends ZeroInstanceServiceServer with no additional methods so callers
// can use it as both the domain interface and the gRPC server interface.
type Server interface {
	zerov1beta1.ZeroInstanceServiceServer
}

func NewServer(
	serverlessClusterSvc serverlessclustersvc.Service,
	shadowPoolRepo repository.ShadowPoolRepository,
	cfg *config.ShadowPoolConfig,
) Server {
	return &serverImpl{
		serverlessClusterSvc: serverlessClusterSvc,
		shadowPoolRepo:       shadowPoolRepo,
		config:               cfg,
	}
}

type serverImpl struct {
	serverlessClusterSvc serverlessclustersvc.Service
	shadowPoolRepo       repository.ShadowPoolRepository
	config               *config.ShadowPoolConfig
}
