goboot

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2023 License: MIT

README

goboot

概述

goboot是个一个Golang开发过程中,使用的一些经验总结的库,涵盖Web开发和游戏开发领域。

快速开始

开发一个http服务器

goboot开发http服务器,只需要传入调用httpapi包,传入配置文件地址,监听端口,以及实例ID:

instance := httpapi.New(*configPath, *addr, *instanceId)

...

// 启动
boot.BootServe(instance)

通过模块化的Module,来建立API,一个Module要遵循httpapi.Module的定义:

Module interface {
		// 初始化模块
		Init(app *App)
		// 模块的分组路由
		Group() Group
}
开发一个gRPC服务

goboot开发gRPC服务器,同样只需要使用:

instance := server.New(*name, *configPath, *addr, *instanceId)

boot.BootServe(instance)

不同的是,这里的server需要定制protobuf文件实现。

开发一个游戏服务器

goboot开发游戏服务器,使用的gameapi包的实现:

instance := gameapi.New(*configPath, *addr, *instanceId)

boot.BootServe(instance)

同样使用的模块化的管理接口,不同的是,gameapi使用的opcode->protobufMessage的映射管理作为路由:

Moddule interface {

		// 初始化模块
		Init(app *App)

		// 模块的分组路由
		Group() map[uint16]Handler
}

参考

实例
Module
Handler
服务注册和发现
日志

注意事项

  1. 使用gameapi开发游戏服务器时,opcode为0已经被心跳包占用

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL