type FunnelContext interface {
context.Context
logger.Logger
}
type RequestHandler struct {
// No context specific fields here, instance stays reusable across requests
}
func (RequestHandler) Handle(ctx FunnelContext) {}
And as the common idiom is to not include Context in struct but pass as the first argument, the logger should be inserted into that Context.
[1] https://peter.bourgon.org/go-best-practices-2016/#logging-and-instrumentation
I've read about this context.Value topic on several occasion and in your blog post you say context is only for cancelation. But how should one cope with real goroutine specific data, unfortunately i missed always a correct solution for this problem.
Any proposal is welcome
Cheers snmed
How do you code for storing a logger in context.Value? The same usual issues with lacking a shared logger interface happens or did I miss something neat?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi DaveI've read about this context.Value topic on several occasion and in your blog post you say context is only for cancelation. But how should one cope with real goroutine specific data, unfortunately i missed always a correct solution for this problem.