add grpc support
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
)
|
||||
|
||||
@ -16,12 +17,14 @@ func (a *App) run() {
|
||||
case <-a.AppContext.Done():
|
||||
a.l.Warn().Str("reason", a.AppContext.Err().Error()).
|
||||
Msg("shutting down on context done")
|
||||
case <-a.HTTP.httpDone:
|
||||
case <-a.HTTP.HTTPDone: // TODO: return error on this channel
|
||||
a.l.Warn().Msg("shutting down early on http server done")
|
||||
case err := <-a.GRPC.GRPCDone:
|
||||
a.l.Warn().Err(err).Msg("shutting down early on grpc server done")
|
||||
}
|
||||
a.Shutdown()
|
||||
|
||||
a.appDone <- nil
|
||||
a.Shutdown() // Run through all shutdown funcs
|
||||
a.appDone <- nil // Notify app
|
||||
}
|
||||
|
||||
// Typically invoked when AppContext is done
|
||||
@ -48,6 +51,8 @@ func (a *App) Shutdown() {
|
||||
doneCtx, span := a.tracer.Start(doneCtx, "shutdown")
|
||||
defer span.End()
|
||||
|
||||
span.SetAttributes(attribute.Int("shutdown.funcs", len(a.shutdownFuncs)))
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(len(a.shutdownFuncs))
|
||||
|
||||
|
Reference in New Issue
Block a user