koding / kite

Micro-service framework in Go
https://godoc.org/github.com/koding/kite
MIT License
3.26k stars 300 forks source link

kite/client: make callback execution synchronous #172

Closed rjeczalik closed 8 years ago

rjeczalik commented 8 years ago

deps: https://github.com/koding/kite/pull/171

The default behaviour for go1.4 scheduler is to execute incoming callback in order they were received. That applies to small group of short-lived callbacks that don't do any I/O.

go1.5+ scheduler is more reentrant, which makes callback execution out-of-order. This breaks existing code that relies on go1.4 scheduler behaviour.

This PR adds ConcurrentCallbacks field to client which is false by default to restore go1.4 behaviour.

If you rely on your callbacks being done asynchronously (e.g. you're doing heavy computations in them) set ConcurrentCallbacks to true for each your *kite.Client value.

cihangir commented 8 years ago

Could you please write a simple test to validate it is working as expected? like writing a two handler one waits for 100ms other returns immediately, and assert that second handler's response returns after first ones.

Thanks for fixing this long standing issue on upgrading our go version :)

rjeczalik commented 8 years ago

@cihangir Will do.