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

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

var (
	ServiceKey = "Address"
)

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

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

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

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

func main() {
	Run()
}
