func NewService(leaseClient client.LeaseClient) *Service {
	return NewServiceWith(leaseClient, util.NewTicker(haSyncerTimeInterval), time.Now)
}
NewService constructs a new HA lease service with the supplied
database connection and the default sync interval.
The sync interval determines how often the leases for
all clusters are refreshed from the database.
package ha
import (
	"context"
	"fmt"
	"sync"
	"time"
	"github.com/timescale/promscale/pkg/ha/client"
	"github.com/timescale/promscale/pkg/ha/state"
	"github.com/timescale/promscale/pkg/log"
	"github.com/timescale/promscale/pkg/util"
)
const (
	haSyncerTimeInterval      = 15 * time.Second
	tryLeaderChangeErrFmt     = "failed to attempt leader change for cluster %s"
	failedToUpdateLeaseErrFmt = "failed to update lease for cluster %s"
)
var ErrNoLeasesInRange = fmt.Errorf("no valid leases in range found")
type Service struct {
	state               *sync.Map
	leaseClient         client.LeaseClient
	syncTicker          util.Ticker
	currentTimeProvider func() time.Time
	doneChannel         chan bool
	doneWG              sync.WaitGroup
}