package service

import (
	"context"

	"github.com/tidbcloud/aws-shared-provider/pkg/tidbworker"
	scalerpb "github.com/tidbcloud/aws-shared-provider/pkg/tidbworker/proto/scaler"
	"gorm.io/gorm"
	ctrl "sigs.k8s.io/controller-runtime"
)

// Server is the interface for scaler server.
type Server interface {
	// GetDB returns the storage backend the server uses.
	GetDB() *gorm.DB
	// GetConfig returns the configuration of the server.
	GetConfig() *tidbworker.Config
}

// ScalerService wraps scaler server to provide grpc service.
type ScalerService struct {
	Server
	scalerpb.UnimplementedScalerServer
}

func (s *ScalerService) Ping(_ context.Context, _ *scalerpb.PingRequest) (*scalerpb.Response, error) {
	ctrl.Log.Info("Ping request received")
	return &scalerpb.Response{}, nil
}
