func (r *registryImp) KeepAlive(ctx context.Context, Req *tars.KeepAliveReq) (err error) {
	logger.Debugf("KeepAlive: %+v", Req)
	if err := r.driver.KeepAliveNode(ctx, Req.NodeName); err != nil {
		logger.Errorf("KeepAliveNode error %v", err)
		return err
	}
	if Req.State == "" {
		Req.State = consts.StateActive
	}
	return r.driver.SetServerState(ctx, Req.NodeName, Req.Application, Req.Server, Req.State)
}
KeepAlive is a reentrant function
package main
import (
	"context"
	"fmt"
	"net/http"
	"strings"
	"time"
	rtars "github.com/TarsCloud/TarsGo/tars"
	"github.com/prometheus/client_golang/prometheus/promhttp"
	"github.com/tarscloud/k8stars/consts"
	tars "github.com/tarscloud/k8stars/tarsregistry/autogen/Tars"
	"github.com/tarscloud/k8stars/tarsregistry/store"
)
type registryImp struct {
	driver store.Store
}
func (r *registryImp) OnStartup(ctx context.Context, Req *tars.OnStartupReq) (err error) {
	logger.Debugf("OnStartup: %+v", Req)
	if err := r.driver.RegisterNode(ctx, Req.NodeName); err != nil {
		return fmt.Errorf("RegisterNode error %v", err)
	}
	sConf := &store.ServerConf{
		Application: Req.Application,
		Server:      Req.Server,
		NodeName:    Req.NodeName,
		State:       Req.State,
		Version:     Req.Version,
		EnableSet:   "N",
		GridFlag:    "NORMAL",
	}
	if Req.DisableFlow {
		sConf.GridFlag = "NO_FLOW"
	}
	tmps := strings.Split(Req.SetID, ".")
	if len(tmps) == 3 {
		sConf.SetName = tmps[0]
		sConf.SetGroup = tmps[1]
		sConf.SetArea = tmps[2]
		sConf.EnableSet = "Y"
	}
	if err := r.driver.RegisterServer(ctx, sConf); err != nil {
		return fmt.Errorf("RegisterServer error %v", err)
	}
	adapters := make([]*store.AdapterConf, len(Req.Adapters))
	for i := range Req.Adapters {
		ad := Req.Adapters[i]
		adapters[i] = &store.AdapterConf{
			Application:  Req.Application,
			Server:       Req.Server,
			NodeName:     Req.NodeName,
			Servant:      ad.Servant,
			AdapterName:  ad.Servant + "Adapter",
			Endpoint:     ad.Endpoint,
			Protocol:     ad.Protocol,
			QueueCap:     int(ad.QueueCap),
			QueueTimeout: int(ad.QueueTimeout),
			MaxConns:     int(ad.MaxConns),
			ThreadNum:    int(ad.ThreadNum),
		}
	}
	if err := r.driver.RegistryAdapter(ctx, adapters); err != nil {
		return fmt.Errorf("RegistryAdapter error %v", err)
	}
	return nil
}
func (r *registryImp) OnPrestop(ctx context.Context, Req *tars.OnPrestopReq) (err error) {
	logger.Debugf("OnPrestop: %+v", Req)
	if Req.Application == "" && Req.Server == "" {
		return r.driver.SetServerState(ctx, Req.NodeName, Req.Application, Req.Server, consts.StateDestroyed)
	}
	return r.driver.DeleteServerConf(ctx, Req.NodeName, Req.Application, Req.Server)
}