Closed PeterlitsZo closed 9 months ago
hello?
I appreciate your work here, but your feature request seems like a lot of code changes, and I don't see why a good deal of code changes are required to be added to ants
when a simple wrapper outside ants
will also work, something like:
type PoolWrapper struct {
pool *ants.Pool
}
func (p *PoolWrapper) Submit(task func(), info *MoreInfomation) error {
p.pool.Submit(func() {
defer func() {
if err := recover(); err != nil {
handlePanic(info.ctx, info.logger, err)
}
}()
task()
})
}
func handlePanic(ctx context.Context, logger Logger, err any) {
logger.Error(ctx, map[string]any{"err", err})
}
Yes, you are right. Thanks for your great work.
Description of new feature
WithPanicHandlerBuilder
option.panicHandler
by those (panicHandlerBuilder
and the more infomation), and then handle the panic.Scenarios for new feature
In my opinion,
panicHandlerBuilder
will be much helpful. Here is my view:ants
already did it well.ants
already did, ant it even give us thepanicHandler
flag to leave better logs (or something else).ants
: we cannot give the infomation about trace to the panicHandler (can we?).So, I think if we can have
panicHandlerBuilder
.Breaking changes or not?
Yes
Code snippets (optional)
Alternatives for new feature
I do not think it looks pretty - If we have
panicHandler
, why not havepanicHandlerBuilder
?Additional context (optional)
I think I am able to send a PR (maybe...).