adjust / rmq

Message queue system written in Go and backed by Redis
MIT License
1.57k stars 206 forks source link

Use a global variable to hold the panic handler #63

Closed silasdavis closed 5 years ago

silasdavis commented 5 years ago

This keeps the current panic behaviour as the default but allows library users to override it if preferred.

fixes #61 (mostly)

wellle commented 5 years ago

Could you tell me how you would implement this function in your case?

silasdavis commented 5 years ago

Something like:

rmq.Panicf = func(format string, v... interface{}) {
    rmqErr := fmt.Errorf(format, v...)
    logger.Info("err", rmqErr , "component", "workers", "code", RMQPanicCode)
    // restart my worker queues but leave the rest of my app alone
    err := workers.Restart()
    if err != nil {
        panic(fmt.Errorf("could not restart workers after rmq panicked with %v: %v", rmqErr, err))
    }
}
silasdavis commented 5 years ago

Can we have some merge please sir?