Closed co11ter closed 8 years ago
@co11ter Thanks for pointing this out.
I indeed the design had some issues. I'm open to suggestion, I will have to rewrite the implementation and possible change the API if possible.
Any input is welcome. You can help if you don't mind.
Someone also pointed this out #57
Problems seems to arise here https://github.com/gernest/utron/blob/master/routes.go#L313-L352
I think I might have ideas on how to fix this without changing of the API
I fix it for me like https://github.com/co11ter/utron/blob/master/routes.go#L382-L398, but I don't think that it's "true way". Maybe we have to create new controller per request?
Another fix https://github.com/co11ter/utron/commit/fb99f6f61fc79d29240433a96e6622acaed84915 but it change API:
type SomeController struct {
*utron.BaseController
}
func NewSomeController() utron.Controller {
return &SomeController{&utron.BaseController{}}
}
utron.RegisterController(NewSomeController)
I can send pull request if you want.
@co11ter cool. Did you test the first one?
I don't think changing the API will be wise for now! Please send the PR, then we can maybe discuss there if any changes need to be made!
I cant spopt the difference , please Open the PR so I can check the diff!
I think, for now the best way will be to create a new Controller on each request.
@co11ter please try to tun the example again to see if this bug is gone for good
yes, it fixed!
@co11ter awesome. Thanks.
Hi!
I write the code:
send many concurent requests to /test:
siege -f urls.txt -c 10 -t30s -i
and have error:
Two parallel routines get the same context. Maybe action signature should be
func (c *SomeController) Action(ctx *utron.Context) {}
instead to save the context into the controller??