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

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

var (
	ServiceKey = "Feed"
)

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.EtcdService,
			GatewayCtx:  s.Ctx,
			GatewayConf: config.Spec.Gateway,
			GatewayMux:  s.Mux,
		},
	)

	// 注册：初始化数据
	srv.Use(models.InitData)

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

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

func main() {
	Run()
}
