package db

import (
	"github.com/mhaya"
	mhayaCron "github.com/mhaya/components/cron"
	mhayaGops "github.com/mhaya/components/gops"
	mhayaMongo "github.com/mhaya/components/mongo"
	checkCenter "github.com/mhaya/game/game_cluster/internal/component/check_center"
	"github.com/mhaya/game/game_cluster/internal/data"
	"github.com/mhaya/game/game_cluster/internal/mdb"
	"github.com/mhaya/game/game_cluster/nodes/db/module"
)

func Run(profileFilePath, nodeId string) {
	// 配置mhaya引擎
	app := mhaya.Configure(profileFilePath, nodeId, false, mhaya.Cluster)

	// diagnose
	app.Register(mhayaGops.New())
	// 注册调度组件
	app.Register(mhayaCron.New())
	// 注册数据配置组件
	app.Register(data.New())
	// 注册检测中心节点组件，确认中心节点启动后，再启动当前节点
	app.Register(checkCenter.New())
	// 注册db组件
	app.Register(mhayaMongo.NewComponent())

	app.AddActors(
		&module.ActorDBs{},
		&module.ActorSaves{},
		&mdb.ActorDB{Name: nodeId},
	)

	app.Startup()
}
