koding / kite

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

kite: expose client lifetime information to kite handler #213

Closed rjeczalik closed 6 years ago

rjeczalik commented 6 years ago

There is a common scenario, where a kite handler expects a callback sent from a client, just to start a long-running goroutine and feed information to client via that callback.

We want to have a mean to terminate that long-running goroutine when client disconnect, in order to clean resources.

This PR makes the (*kite.Request).Context a proper context.Context value, which is canceled upon client being disconnected.