add Wait option

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-09-20 15:48:07 +03:00
parent 5787a1afb8
commit 9b11ea527a

View File

@ -46,6 +46,7 @@ type Options struct {
// TLSConfig specifies tls.Config for secure serving
TLSConfig *tls.Config
Wait *sync.WaitGroup
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
@ -234,13 +235,10 @@ func WithRouter(r Router) Option {
// wait against it on stop.
func Wait(wg *sync.WaitGroup) Option {
return func(o *Options) {
if o.Context == nil {
o.Context = context.Background()
}
if wg == nil {
wg = new(sync.WaitGroup)
}
o.Context = context.WithValue(o.Context, "wait", wg)
o.Wait = wg
}
}