2015-10-11 05:34:12 +00:00
|
|
|
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 {
|
2016-09-20 18:03:35 +00:00
|
|
|
if nil == router {
|
|
|
|
return errNilReceiver
|
|
|
|
}
|
|
|
|
|
2015-10-11 05:34:12 +00:00
|
|
|
go func() {
|
|
|
|
router.subrouter.Route(message, context)
|
|
|
|
}()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|