/**
 * @Author: david.yan(david.yan@qq.com)
 * @Date: 2021-11-26 15:25:03
 */
package main

import (
	"bsm/full/module/base/passport/internal/config"
	"bsm/full/module/base/passport/internal/impl"
	"bsm/full/module/base/passport/internal/server"
	"git.apinb.com/bsm-sdk/core/service"
)

var (
	ServiceKey = "Passport"
)

func Run() {
	config.New(ServiceKey)
	impl.NewImpl()

	// 初始化服务
	s := server.New(nil)
	srv := service.New(
		s.Grpc,
		&service.Options{
			Addr:        config.Spec.Addr,
			MsConf:      config.Spec.MicroService,
			EtcdClient:  impl.EtcdService,
			GatewayCtx:  s.Ctx,
			GatewayConf: config.Spec.Gateway,
			GatewayMux:  s.Mux,
		},
	)

	// 注册：初始化数据（如果需要）
	// srv.Use(models.InitData)

	// 停止服务
	defer srv.Stop()

	// 启动服务
	srv.Start()
}

func main() {
	Run()
}
