gotomicro / ego Goto Github PK
View Code? Open in Web Editor NEWA simple and component-based microservice kit for go. 一个简单的基于组件的 Go 微服务套件。
Home Page: https://ego-org.com
License: MIT License
A simple and component-based microservice kit for go. 一个简单的基于组件的 Go 微服务套件。
Home Page: https://ego-org.com
License: MIT License
run demo with quickstart
https://ego.gocn.vip/frame/quickstart/quickstart.html
go mod is
github.com/gotomicro/[email protected]
when i want to start app
go run main.go --config=config.toml
get error
package command-line-arguments
imports github.com/gotomicro/ego
imports github.com/gotomicro/ego/core/util/xcolor: build constraints exclude all Go files in E:\go\pkg\mod\github.com\gotomicro\[email protected]\core\util\xcolor
switch to
github.com/gotomicro/[email protected]
this version is ok
Describe the bug
go1.18.1使用golang.org/x/[email protected]会报依赖问题
Welcome to use ego To know who is using it, pls append your org info as follow,
Organization:ego (Required)
Location: Shanghai, China(Required)
Contact: Email or Official website (Optional)
Purpose:use as our basic framework (Required)
Thanks again for your participation!
欢迎使用 ego,首先感谢你的使用,其次您可以参考下面的样例来提供您的信息以收集下使用场景:
再次感谢你的参与!!!
有些事情是一巴掌能拍响的吗?希望能一视同仁。
Is your feature request related to a problem? Please describe.
在接入ego过程中,遇到2类场景, 在接入过程里,比较容易出错。
Describe the solution you'd like
对问题1的期望解决方式:
对econf支持载入多数据源,并且允许不同文件的key重复。
预期样式:
var redisfilepath = "/xxx/xx/redis.yaml"
var db filepath = "/xx/xx/db.yaml"
var domainfilepath = "/xxx/xx/domain.yaml"
rediscfg := econf.NewFromFile(redisfilepath)
dbcfg :=econf.NewfromFile(dbfilepath)
domaincfg :=econf.NewFromFile(domainfilepath)
部分核心component优先支持, eredis,egorm,支持指定econf.Configuration来读取键值
预期样式:
eredis.LoadFromCfg(rediscfg, "userredis.scene1")
对问题2的期望解决方式:
部分核心component支持该方法,来内存赋值: egin.LoadFromKV(map[string]interface{})
Describe alternatives you've considered
对问题1的econf,写法使用多变量来承接,而不是杂糅进econf里,写成econf.Load(file1,file2,file3),主要考虑到econf中的维护关系,都是围绕单配置源,watch相关操作,在集成多文件时,容易出现不兼容问题。其次,不同的中间件,在载入配置信息时,应该显式地知道读取哪个配置文件(egin.LoadFrom(ginconfig))
,而不是由框架静默选择。
对问题2的入参设置为map,是基于部分component的配置key,未提供可配置字段的Set方法,因为Container结构体里面的config是小写的,很多优化配置的参数,在未正确接入econf (解决问题1前)时,无法载入。
下面脑图是什么工具画的呀?好看
Describe the bug
core/util/xcolor/string_windows.go
undefined: Random
To Reproduce
Steps to reproduce the behavior:
core/util/xcolor/string_windows.go
ego version
v0.6.3 & master
Handler 中 panic,egin 却依然返回 200 code。
func Import(ctx *gin.Context) {
for _, s := range something {
Panic()
}
// 此处仍然能继续返回
ctx.JSON(200, map[string]interface{}{"result": "ok"})
}
func Panic(){
panic("don't panic")
}
背景:
在安全场景下,后端服务提供给第三方,或者跟网关的情况下,虽然在网关后面但是需要与第三方或者官网进行双向认证
当前情况:
egin不支持https并且支持双向认证
Is your feature request related to a problem? Please describe.
编译后可执行程序,需要配置文件,往往要把配置文件和可执行程序一起放在线上服务器,配置文件内容尤其是sql连接信息,非常敏感
Describe the solution you'd like
1.16之后,有了 embed 特性,可以在编译服务过程中过程中,就把配置打包进去, 线上真正只需要一个可执行程序
Describe alternatives you've considered
1.16之前,我们是将配置写在一个go文件里面,不是很友好
Additional context
期待更好
BUG描述
在ego初始化后注册econf.OnChange回调会出现数据竞争
另外在ego初始化后操作组件也可能出现此情况(未验证)
BUG复现方法
1.代码
package main
import (
"github.com/gotomicro/ego"
"github.com/gotomicro/ego/core/econf"
)
type Mysql struct {
Dsn string
}
func main() {
ego.New()
econf.OnChange(func(c *econf.Configuration) {})
}
2.执行命令go run -race ./cmd/ego/main.go --config=./configs/main/config.toml
3.报错信息
==================
WARNING: DATA RACE
Write at 0x00c0001228a0 by main goroutine:
github.com/gotomicro/ego/core/econf.(*Configuration).OnChange()
/go/pkg/mod/github.com/gotomicro/[email protected]/core/econf/conf.go:72 +0xf3
github.com/gotomicro/ego/core/econf.OnChange()
/go/pkg/mod/github.com/gotomicro/[email protected]/core/econf/api.go:36 +0x32
main.main()
/workspaces/coreadmin/cmd/ego/main.go:15 +0x31
Previous read at 0x00c0001228a0 by goroutine 29:
github.com/gotomicro/ego/core/econf.(*Configuration).LoadFromDataSource.func1()
/go/pkg/mod/github.com/gotomicro/[email protected]/core/econf/conf.go:92 +0x64
Goroutine 29 (running) created at:
github.com/gotomicro/ego/core/econf.(*Configuration).LoadFromDataSource()
/go/pkg/mod/github.com/gotomicro/[email protected]/core/econf/conf.go:90 +0x316
github.com/gotomicro/ego/core/econf.LoadFromDataSource()
/go/pkg/mod/github.com/gotomicro/[email protected]/core/econf/api.go:48 +0x4a6
github.com/gotomicro/ego.loadConfig()
/go/pkg/mod/github.com/gotomicro/[email protected]/ego_function.go:171 +0x450
github.com/gotomicro/ego.runSerialFuncReturnError()
/go/pkg/mod/github.com/gotomicro/[email protected]/ego_function.go:262 +0x16bd
github.com/gotomicro/ego.New()
/go/pkg/mod/github.com/gotomicro/[email protected]/ego.go:124 +0x1623
main.main()
/workspaces/coreadmin/cmd/ego/main.go:13 +0x30
==================
Found 1 data race(s)
exit status 66
例如现在的新建 egin component 代码为:
server := egin.Load("server.http").Build()
而我现在使用的一个旧项目已经在线上运行,更改 config 结构不方便,能否通过下面这种方式传入自定义配置项呢?
server := egin.Load("", egin.Config{Port: 9001, Host: "0.0.0.0"}).Build()
Is your feature request related to a problem? Please describe.
根据当前的代码,目前ecron设计上,每个cron task配置一个config后,都会启动一个cron来运行这个job,这样代价是不是有点高?
Describe the solution you'd like
大多数业务场景下,任务会根据业务场景归类,希望这里的ecron是一个配置项目支持的是一组task的管理
Describe the bug
the value of cost
key in grpc api access log should be float, but is string
To Reproduce
Steps to reproduce the behavior:
server.grpc
logego团队,你好!
ego框架在vscode中运行,然后怎么进行vscode调试。
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
在用grpc时我用到了grpc-gateway,我目前自己写了一个grpc-gatway的ego-componet因为对ego框架部分功能不太熟,实现得不够优雅,希望ego框架官方能够增加此模块
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
使用apollo config如何apply到econf结构体里呢?
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
configuration is optional at the initial stage
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.