farseer-go,一个模块化的完整基础设施框架

417 阅读5分钟

概述

什么是farseer-go

基于Golang模块化完整的基础设施框架,创建现代化Web应用和APIs

使用目前最为流行的组件,并用模块化技术来提供这些组件。

框架完美支持 DDD领域驱动 的战术设计,如仓储资源库应用层事务领域事件应用层动态WebAPI

它有一个.net core 成熟版本,已经使用了10多年,非常棒

不用担心框架会让你依赖过多的包,farseer-go的组件都是独立的包,不使用的包不会下载到您的应用程序中

每个组件都是单独的包,因此版本号也是单独发布的

有什么特点?

  • 统一配置:所有的配置被整合到./farseer.yaml

  • 优雅:所有的模块都遵循开发者体验优先为原则。

  • 模块化:供了完整的模块化系统,使你能够开发可重复使用的应用程序模块。

  • 领域驱动:帮助你实现基于DDD的分层架构并构建可维护的代码库。

  • 链路追踪(下个版本推出):如果您使用框架中的Orm、Redis、Http、Grpc、ES、MQ、EventBus、Task、FSS,将隐式为您实现链路追踪,并提供API请求日志、慢查询。

结合FOPS 项目(自动构建、链路追踪控制台、K8S集群日志收集)支持代码无侵入的全链路实时监控。

集成的组件

包名描述地址
fs基础核心包github.com/farseer-go/…
collections数据集合github.com/farseer-go/…
webapiweb api服务github.com/farseer-go/…
async异步编程github.com/farseer-go/…
mapper对象转换github.com/farseer-go/…
cacheMemory本地缓存github.com/farseer-go/…
redisclientgithub.com/farseer-go/…
data数据库ORMgithub.com/farseer-go/…
elasticSearchclientgithub.com/farseer-go/…
eventBus事件总线github.com/farseer-go/…
queue本地队列github.com/farseer-go/…
tasks本地任务github.com/farseer-go/…
fss分布试调度clientgithub.com/farseer-go/…
utils工具集github.com/farseer-go/…

如何开始

main.go

package main
import "github.com/farseer-go/fs"

func main() {
   fs.Initialize[StartupModule]("your project Name")
}

在main函数第一行,执行fs.Initialize,开始初始化框架

运行后控制台打印加载信息:

2023-01-05 16:15:00 AppName:  demo
2023-01-05 16:15:00 AppID:    199530571963039744
2023-01-05 16:15:00 AppIP:    192.168.3.55
2023-01-05 16:15:00 HostName: stedenMacBook-Pro.local
2023-01-05 16:15:00 HostTime: 2023-01-05 16:15:00
2023-01-05 16:15:00 PID:      22131

2023-01-05 16:15:00 ---------------------------------------
2023-01-05 16:15:00 Loading Module...
2023-01-05 16:15:00 Loading Module:cache.Module
2023-01-05 16:15:00 Loading Module:cacheMemory.Module
2023-01-05 16:15:00 Loading Module:eventBus.Module
2023-01-05 16:15:00 Loading Module:queue.Module
2023-01-05 16:15:00 Loading Module:infrastructure.Module
2023-01-05 16:15:00 Loading Module:webapi.Module
2023-01-05 16:15:00 Loading Module:domain.Module
2023-01-05 16:15:00 Loading Module:application.Module
2023-01-05 16:15:00 Loading Module:interfaces.Module
2023-01-05 16:15:00 Loading Module:main.StartupModule
2023-01-05 16:15:00 Loaded, 11 modules in total
2023-01-05 16:15:00 ---------------------------------------
2023-01-05 16:15:00 Elapsed time:0 ms modules.FarseerKernelModule.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms cache.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms cacheMemory.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms eventBus.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms queue.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms infrastructure.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms webapi.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms domain.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms application.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms interfaces.Module.PreInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms main.StartupModule.PreInitialize()
2023-01-05 16:15:00 ---------------------------------------
2023-01-05 16:15:00 Elapsed time:0 ms modules.FarseerKernelModule.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms cache.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms cacheMemory.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms eventBus.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms queue.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms infrastructure.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms webapi.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms domain.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms application.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms interfaces.Module.Initialize()
2023-01-05 16:15:00 Elapsed time:0 ms main.StartupModule.Initialize()
2023-01-05 16:15:00 ---------------------------------------
2023-01-05 16:15:00 Elapsed time:0 ms modules.FarseerKernelModule.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms cache.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms cacheMemory.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms eventBus.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms queue.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms infrastructure.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms webapi.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms domain.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms application.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms interfaces.Module.PostInitialize()
2023-01-05 16:15:00 Elapsed time:0 ms main.StartupModule.PostInitialize()
2023-01-05 16:15:00 ---------------------------------------
2023-01-05 16:15:00 Initialization completed, total time:0 ms 
2023-01-05 16:15:00 [Info] Web service is started:http://localhost:8888/