Reduce the risk of panic
What would you like to be added:
Layotto(open source version) will be imported and deployed in the production environment.
Thanks to golang's weird design,a panic in a third-party library will bring down the whole process, which means a panic bug can bring down the whole cluster.
Since that, we must reduce the risk of panic before deploying Layotto in the production environment.
Tasks included:
- [x] replace all code which starts a new goroutine(e.g.
go func(){xxx}) with recover phrase( e.g.utils.GoWithRecover(func() { xxx }) - [ ] Let users import components on demand.Currently we import all components in the
main.goand it has the risk of dependency conflicts.To reduce the risk,we can let users decide which components should be imported and which should not.But it takes time to do some research and careful design.
chinese:
- 把所有创建新协程的地方(e.g.
go func(){xxx})加上recover(直接用工具类即可,utils.GoWithRecover(func() { xxx }) - 让用户按需import需要的组件。目前是main.go里默认import加载所有组件,万一有依赖冲突之类的事情很危险。可以改造成用啥组件才import啥,但是方案需要调研下
注:新手任务只需要做第一个就行(给所有创建新协程的地方加上recover),不用管第二个,第二个我来调研一下
Why is this needed: Make Layotto more robust
I am happy to do this work, can you assign this issue to me?
I am happy to do this work, can you assign this issue to me?
Cool ! Welcome to the Layotto community
I'm very excited to do this work, pls assign this issue to me! thx a lot
I'm very excited to do this work, pls assign this issue to me! thx a lot
Ah,sorry that I just assigned this issue to @arcosx
@x-shadow-man Would you like to choose another task in the task list #108
Any unmarked task in the list is unassigned and needs help
Thanks for your passion !
Sorry for my late submission🤣, I submitted a PR #208 regarding the first solution point: replace all code which starts a new goroutine.......
One question, should my changes involve the directories demo,sdk, and _test.go ?
The reason for this is that I noticed that demo,sdk does not contain mosn.io/pkg/utils/, would it be redundant to introduce it, and would _test.go not actually affect the deployment of the production environment.
@arcosx Thanks for your contribution!
I think sdk package also need recover,while demo and _test.go don't. If panic happens during testing ,let it crash and we can easily find out the bugs.
There is no need to introduce mosn.io/pkg/utils/ into sdk .We can write a new GoWithRecover in sdk or just copy the existing mosn.io/pkg/utils/goroutine.go into the sdk package