Leaf is an open source game server framework written in Go language (golang) that pays equal attention to development efficiency and execution efficiency. Leaf is suitable for the development of various game servers, including H5 (HTML5) game servers.
# LEAF's attention: (Recommended learning: Go )
A good experience. Leaf always provides as simple and easy-to-use interfaces as possible to improve development efficiency and stability as much as possible. Leaf always tries its best to recover from errors during operation and avoid crashes
Multi-core support. Leaf utilizes multi-core resources as much as possible through the module mechanism and leaf/go, while trying to avoid various side effects
Module mechanism.
Leaf’s module mechanismA game server developed by Leaf consists of multiple modules (such as LeafServer). The modules have the following characteristics:
Each module runs in a separate goroutine
Communication between modules is through a set of lightweight RPC mechanisms (leaf/chanrpc)
Leaf is not recommended in game servers Design too many modules.
The game server registers modules when it starts, for example:leaf.Run(
game.Module,
gate.Module,
login.Module,
)
type Module interface {OnInit()OnDestroy()Run(closeSig chan bool) }
Leaf will first execute the OnInit method of the module in the same goroutine in the order of module registration. After the execution of the OnInit method of all modules is completed, a goroutine will be started for each module and Execute the module's Run method.
Finally, when the game server is shut down (Ctrl C to close the game server), the module's OnDestroy method will be executed in the same goroutine in the reverse order of module registration.
The above is the detailed content of Is golang leaf used a lot?. For more information, please follow other related articles on the PHP Chinese website!