created a non-blocking router

master
Charles Iliya Krempeaux 2015-10-10 22:34:12 -07:00
parent 63bc3f98b9
commit 4bb10531bb
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package flog
// NewNonBlockingRouter returns an initialized NonBlockingRouter.
func NewNonBlockingRouter(subrouter Router) *NonBlockingRouter {
router := NonBlockingRouter{
subrouter:subrouter,
}
return &router
}
// NonBlockingRouter is a Router when its Route method is call its does not
// block and dealing with the routing in parallel.
//
// Note that this means that if the application could terminate before this
// completes.
type NonBlockingRouter struct {
subrouter Router
}
func (router *NonBlockingRouter) Route(message string, context map[string]interface{}) error {
go func() {
router.subrouter.Route(message, context)
}()
return nil
}