Files
QSfera/Server/vendor/go-micro.dev/v4/server/context.go
T
Курнат Андрей 2315f25754 Initial QSfera import
2026-06-07 10:20:04 +03:00

30 lines
490 B
Go

package server
import (
"context"
"sync"
)
type serverKey struct{}
type wgKey struct{}
func wait(ctx context.Context) *sync.WaitGroup {
if ctx == nil {
return nil
}
wg, ok := ctx.Value(wgKey{}).(*sync.WaitGroup)
if !ok {
return nil
}
return wg
}
func FromContext(ctx context.Context) (Server, bool) {
c, ok := ctx.Value(serverKey{}).(Server)
return c, ok
}
func NewContext(ctx context.Context, s Server) context.Context {
return context.WithValue(ctx, serverKey{}, s)
}