# README
CORE
Introduction
The Golaxy Distributed Service Development Framework aims to provide a comprehensive server-side solution for real-time communication applications. Based on the EC system and Actor thread model, the framework is designed to be simple and easy to use, making it particularly suitable for developing games and remote control systems.
This project is the core part of the framework, with the main features including:
- Entity Component Framework (
Entity Component
): Provides flexible entity and component management, supporting the creation and maintenance of complex objects. - Entity Prototype System (
Entity Prototype
): Supports the definition and reuse of entity prototypes, simplifying the creation process of entities. - Actor Thread Model (
Actor Model
): Based on the Actor model's thread processing mechanism, each Actor runs in an independent computing unit, achieving parallel task processing and enhancing the system's concurrency performance and stability. - Runtime Environment (
Runtime and Context
): Implements an independent runtime thread environment for Actors, providing mechanisms for entity management and communication calls. - Service Environment (
Service and Context
): Supports the startup, shutdown, and management of services, offering global entity management and communication call mechanisms. - Plugin System (
Plugin Support
): Provides mechanisms for extending framework functions, supporting the implementation of new features in the runtime or service environments. - Local Event System (
Local Event
): Based on a code generator, it provides an efficient local event mechanism within the independent runtime thread environment of Actors. - Asynchronous Call Scheme (
Async/Await
): Supports asynchronous operations, simplifying the writing of asynchronous code, and enhancing the system's responsiveness.
Directory
Directory | Description |
---|---|
/ | Main implementation of service and runtime related functionalities. |
/define | Supports the definition of plugins or components using generics, simplifying code writing. |
/ec | Entity Component Framework. |
/event | Local Event System. |
/event/eventcode | Local Event Code Generator. |
/plugin | Plugin System. |
/pt | Entity Prototype System. |
/runtime | Runtime Context. |
/service | Service Context. |
/utils | Various utility classes and functions. |
Examples
For more details, see: Examples
Installation
go get -u git.golaxy.org/core
# Packages
Package define 利用泛型特性,简化代码编写。
- 支持组件与组件接口定义,可以参考官方样例:https://git.golaxy.org/examples,学习如何使用。
- 支持插件与插件接口定义,注意插件共有运行时插件、服务插件、通用插件三种,可以参考官方样例:https://git.golaxy.org/examples,学习如何使用。
- 使用Goland作为IDE时,需要更新至2023.2版本以上,否则可能会有误报错。
- 根据代码结构,选择性使用。
*/.
go:generate stringer -type TreeNodeState.
Package event 高效的事件系统,适用于单线程环境,需要使用go:generate功能来生成代码。.
go:generate stringer -type PluginState.
Package pt 实体与组件原型,用于创建实例。.
go:generate stringer -type RunningState.
go:generate stringer -type RunningState.
Package utils 一些工具类与函数。.
# Functions
Async 异步执行代码,有返回值.
AsyncVoid 异步执行代码,无返回值.
Await 异步等待结果返回.
CreateEntity 创建实体.
CreateEntityPT 创建实体原型.
Go 使用新线程执行代码,有返回值.
GoVoid 使用新线程执行代码,无返回值.
NewRuntime 创建运行时.
NewService 创建服务.
ReadChan 读取channel.
TimeAfter 定时器,指定时长.
TimeAt 定时器,指定时间点.
TimeTick 心跳器.
Deprecated: UnsafeNewRuntime 内部创建运行时.
Deprecated: UnsafeNewService 内部创建服务.
Deprecated: UnsafeRuntime 访问运行时内部方法.
Deprecated: UnsafeService 访问服务内部方法.
# Variables
No description provided by the author
参数错误.
内核错误.
panic错误.
任务处理流水线关闭.
任务处理流水线已满.
运行时错误.
服务错误.
No description provided by the author
# Structs
AwaitDirector 异步等待分发器.
EntityCreator 实体构建器.
EntityPTCreator 实体原型构建器.
RuntimeBehavior 运行时行为,在扩展运行时能力时,匿名嵌入至运行时结构体中.
RuntimeOptions 创建运行时的所有选项.
No description provided by the author
ServiceOptions 创建服务的所有选项.
# Interfaces
LifecycleComponentAwake 组件的生命周期进入唤醒(awake)时的回调,组件实现此接口即可使用.
LifecycleComponentDispose 组件的生命周期进入死亡(death)时的回调,组件实现此接口即可使用.
LifecycleComponentShut 组件的生命周期进入结束(shut)时的回调,组件实现此接口即可使用.
LifecycleComponentStart 组件的生命周期进入开始(start)时的回调,组件实现此接口即可使用.
LifecycleEntityAwake 实体的生命周期进入唤醒(awake)时的回调,实体实现此接口即可使用.
LifecycleEntityDispose 实体的生命周期进入死亡(death)时的回调,实体实现此接口即可使用.
LifecycleEntityShut 实体的生命周期进入结束(shut)时的回调,实体实现此接口即可使用.
LifecycleEntityStart 实体的生命周期进入开始(start)时的回调,实体实现此接口即可使用.
LifecycleRuntimePluginInit 运行时上的插件初始化回调,插件实现此接口即可使用.
LifecycleRuntimePluginShut 运行时上的插件结束回调,插件实现此接口即可使用.
LifecycleServicePluginInit 服务上的插件初始化回调,插件实现此接口即可使用.
LifecycleServicePluginShut 服务上的插件结束回调,插件实现此接口即可使用.
Runtime 运行时接口.
Service 服务.
# Type aliases
LifecycleComponentLateUpdate 如果开启运行时的帧更新特性,那么组件状态为活跃(alive)时,将会收到这个帧迟滞更新(late update)回调,组件实现此接口即可使用.
LifecycleComponentUpdate 如果开启运行时的帧更新特性,那么组件状态为活跃(alive)时,将会收到这个帧更新(update)回调,组件实现此接口即可使用.
LifecycleEntityLateUpdate 如果开启运行时的帧更新特性,那么实体状态为活跃(alive)时,将会收到这个帧迟滞更新(late update)回调,实体实现此接口即可使用.
LifecycleEntityUpdate 如果开启运行时的帧更新特性,那么实体状态为活跃(alive)时,将会收到这个帧更新(update)回调,实体实现此接口即可使用.