kite icon indicating copy to clipboard operation
kite copied to clipboard

Closer interface for kite methods.

Open fatih opened this issue 11 years ago • 0 comments

Our kite handler only satisfies currently this interface:

type Handler interface {
    ServeKite(*Request) (result interface{}, err error)
}

This is sufficient to handle and call a method. We should add a new feature to http://godoc.org/github.com/koding/kite#Kite.Close that when closed it should check whether a method also supports http://golang.org/pkg/io/#Closer, if yes it should call it. Example implementation:

func (k *Kite) Close() {
    //...

    for _, method := range k.handlers {
        if m, ok := method.(io.Closer); ok {
            m.Close()
        }
    }
}

This is helpful for graceful shutdown of a kite or cleaning up resources for some specific methods. This is an idea and open to suggestions.

fatih avatar Aug 08 '14 15:08 fatih