add grpc support

This commit is contained in:
2025-03-07 15:19:05 -05:00
parent 2cf15a4837
commit 00c8e2e4fc
8 changed files with 95 additions and 68 deletions

View File

@ -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))