3 Star 11 Fork 1

cherry-game/cherry

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cherry.go 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
phantaic 提交于 2023-11-04 14:11 . add: ConfigureNode()
package cherry
import (
cfacade "github.com/cherry-game/cherry/facade"
ccluster "github.com/cherry-game/cherry/net/cluster"
cdiscovery "github.com/cherry-game/cherry/net/discovery"
)
type (
AppBuilder struct {
*Application
components []cfacade.IComponent
}
)
func Configure(profileFilePath, nodeId string, isFrontend bool, mode NodeMode) *AppBuilder {
appBuilder := &AppBuilder{
Application: NewApp(profileFilePath, nodeId, isFrontend, mode),
components: make([]cfacade.IComponent, 0),
}
return appBuilder
}
func ConfigureNode(node cfacade.INode, isFrontend bool, mode NodeMode) *AppBuilder {
appBuilder := &AppBuilder{
Application: NewAppNode(node, isFrontend, mode),
components: make([]cfacade.IComponent, 0),
}
return appBuilder
}
func (p *AppBuilder) Startup() {
app := p.Application
if app.NodeMode() == Cluster {
cluster := ccluster.New()
app.SetCluster(cluster)
app.Register(cluster)
discovery := cdiscovery.New()
app.SetDiscovery(discovery)
app.Register(discovery)
}
// Register custom components
app.Register(p.components...)
// startup
app.Startup()
}
func (p *AppBuilder) Register(component ...cfacade.IComponent) {
p.components = append(p.components, component...)
}
func (p *AppBuilder) AddActors(actors ...cfacade.IActorHandler) {
p.actorSystem.Add(actors...)
}
func (p *AppBuilder) NetParser() cfacade.INetParser {
return p.netParser
}
func (p *AppBuilder) SetNetParser(parser cfacade.INetParser) {
p.netParser = parser
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/cherry-game/cherry.git
[email protected]:cherry-game/cherry.git
cherry-game
cherry
cherry
master

搜索帮助