gw123 / Gmq
基于事件机制的多模块框架,支持动态库,grpc,websocket,mqtt等多种与后端通信组合方式. 模块动态替换,部分加载或者升级.
Stars: ✭ 31
Labels
Projects that are alternatives of or similar to Gmq
Date Fns
⏳ Modern JavaScript date utility library ⌛️
Stars: ✭ 27,650 (+89093.55%)
Mutual labels: modules
React Styling Hoc
Механизм темизации для React-компонентов, написанных с использованием CSS модулей.
Stars: ✭ 25 (-19.35%)
Mutual labels: modules
Es Check
Checks the version of ES in JavaScript files with simple shell commands 🏆
Stars: ✭ 448 (+1345.16%)
Mutual labels: modules
Resolve
Implements the node.js require.resolve() algorithm
Stars: ✭ 622 (+1906.45%)
Mutual labels: modules
Gohack
Make temporary edits to your Go module dependencies
Stars: ✭ 739 (+2283.87%)
Mutual labels: modules
Gnet
🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go./ gnet 是一个高性能、轻量级、非阻塞的事件驱动 Go 网络框架。
Stars: ✭ 5,736 (+18403.23%)
Mutual labels: event-loop
Redux Dynamic Modules
Modularize Redux by dynamically loading reducers and middlewares.
Stars: ✭ 874 (+2719.35%)
Mutual labels: modules
Go Modiff
Command line tool for diffing go module dependency changes between versions 📔
Stars: ✭ 24 (-22.58%)
Mutual labels: modules
Cms
Decoupled CMS for any Laravel app, gain control of: pages, blogs, galleries, events, images, custom modules and more.
Stars: ✭ 498 (+1506.45%)
Mutual labels: modules
Typescript Plugin Css Modules
A TypeScript language service plugin providing support for CSS Modules.
Stars: ✭ 520 (+1577.42%)
Mutual labels: modules
React Article Bucket
总结,积累,分享,传播JavaScript各模块核心知识点文章全集,欢迎star,issue(勿fork,内容可能随时修改)。webpack核心内容部分请查看专栏: https://github.com/liangklfangl/webpack-core-usage
Stars: ✭ 750 (+2319.35%)
Mutual labels: event-loop
Pygorithm
A Python module for learning all major algorithms
Stars: ✭ 4,256 (+13629.03%)
Mutual labels: modules
Automate Everything
这是我准备写的第一本书,其实早些时候已经打算开始写书了,只是苦于没有写书经验,无从下手。写书不同于博客,写书需要将知识,经验等系统化地讲述出来,而我现在恰巧缺乏这种表现能力。因此我决定在这里将项目中零散的东西记录下来,然后后期润色一下,写成一本书。
Stars: ✭ 430 (+1287.1%)
Mutual labels: modules
Piral
Framework for next generation web apps using microfrontends. 🚀
Stars: ✭ 711 (+2193.55%)
Mutual labels: modules
Event Loop
ReactPHP's core reactor event loop that libraries can use for evented I/O.
Stars: ✭ 945 (+2948.39%)
Mutual labels: event-loop
Revuejs
🐇 A tiny, light and handy state management for vuejs 2, writing less verbose code.
Stars: ✭ 25 (-19.35%)
Mutual labels: modules
#GMQ 消息模块组合架构
功能特性
- 自动管理channel 实现配置变动后 模块重启
- 多模块按需编译,按配置加载
- 支持多种消息通信方式(mqtt,http,websocket,grpc)
- 模块之间通过消息之间通信相互独立解耦
- 优雅的日志输出方式
- 多数据库支持,方便开发
- 支持读取yml中配置环境变量,方便容器化部署
- 全局的service获取方式,模块调用更加灵活
目录结构
- bootstarp 引导启动目录, 加载配置, 按需加载需要的module(仅仅编译添加的文件) ,加载全局service
- common 公共引用路径
- core 框架核心
- modules 模块路径
- resource 资源路径
- storage 上传文件保存路径
模块配置说明
moduleName:
type : inner/exe/dll/so
enable: 1/ture
moduleName 模块名称
- type 模块类型目前支持 内部模块(golang),可执行程序, dll/so windows,linux动态库方式
- 通信方式支持 mqtt,http,grpc,websocket方式
- enable 配置模块是否要启用
如何新加一个model, 下面以debugmodel为例
- 在modules 添加deubugModel 文件夹
- 添加DebugModule.go 文件
import (
"github.com/gw123/GMQ/modules/base"
"github.com/gw123/GMQ/core/interfaces"
"fmt"
)
type DebugModule struct {
base.BaseModule
}
func NewDebugModule() *DebugModule {
this := new(DebugModule)
return this
}
func (this *DebugModule) Init(app interfaces.App, config interfaces.ModuleConfig) error {
this.BaseModule.Init(app, this, config)
//订阅 debug 消息主题
app.Sub("debug", this)
return nil
}
// 处理消息
func (this *DebugModule) Handle(event interfaces.Event) error {
return nil
}
// 定时触发方法
func (this *DebugModule) Watch(index int) {
return
}
- 实现模块提供者 DebugModuleProvider.go
package debugModule
import "github.com/gw123/GMQ/core/interfaces"
type DebugModuleProvider struct {
module interfaces.Module
}
func NewDebugModuleProvider() *DebugModuleProvider {
this := new(DebugModuleProvider)
return this
}
func (this *DebugModuleProvider) GetModuleName() string {
return "Debug"
}
func (this *DebugModuleProvider) Register() {
}
func (this *DebugModuleProvider) GetModule() interfaces.Module {
if this.module != nil {
return this.module
}
this.module = NewDebugModule()
return this.module
}
func (this *DebugModuleProvider) GetNewModule() interfaces.Module {
this.module = NewDebugModule()
return this.module
}
- 在bootstarp/moduleProvider.go 引入debugModuel
func LoadModuleProvider(app interfaces.App) {
app.LoadModuleProvider(debugModule.NewDebugModuleProvider())
return
}
#数据库配置 支持多数据库配置
dbpool:
default: xyt
db1:
database: "gateway"
host: "xytschool.com"
username: "dbuser"
password: "dbpwd"
drive: "mysql,pg,sqllite"
db2:
database: "gateway"
host: "xytschool.com"
username: "dbuser"
password: "dbpwd"
drive: "mysql,pg,sqllite"
#数据库使用
- //获取数据库信息 GetDb(dnname string) (*gorm.DB, error)
- //获取默认数据库 GetDefaultDb() (*gorm.DB, error)
mqtt模块配置 (mqtt 目前使用的是阿里云IOT服务)
mqtt:
type : inner
productKey : key
deviceSecret: secret
deviceName: name
web模块功能
web:
type : inner
addr: 0.0.0.0
port: 8080
staticFileUrl: "http://127.0.0.1:8080"
staticFileVersion : "1001"
viewsRoot: "./views"
publicRoot: "./public"
sotragePath: "./storage"
allowOrigins:
- "http://127.0.0.1:8080"
- "http://localhost:10086"
- "http://127.0.0.1:88"
docker服务化支持实现一个评论的服务,具体实现可以参考commentModuel
这里我把编译好多程序命名为gatwway , 下面是gateway的配置文件
app:
logFilterCategories : "EventQueue,Dispath"
debugLevel: debug
dbpool:
default: xyt
xyt:
database: "gateway"
host: "${DB_HOST}"
username: "${DB_USER}"
password: "${DB_PWD}"
drive: "mysql"
modules:
comment:
type: inner
bindAddr: ${COMMENT_ADDR}
上面的${var} 的配置是从程序运行的环境变量中读取, 例如 ${DB_HOST}
- mv docker-compose.example.yml docker-compose.yml 修改内容为自己的配置
- 修改 envoy.yaml 配置
- 运行 docker-compose up -d
Starting envoy ... done
Starting gateway ... done
todo list
- 模块停止
- 清空模块队列中的任务
- 平滑停止,主程序在所有模块的队列中的任务执行完毕后停止
- 讲当前模块中的任务做磁盘持久化
在线使用案例 httt://xytschool.com
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].