mirror of
https://github.com/rancher/norman.git
synced 2025-09-25 14:46:57 +00:00
Try to address goroutine leak in subscribe
This commit is contained in:
@@ -120,29 +120,15 @@ func streamStore(ctx context.Context, eg *errgroup.Group, apiContext *types.APIC
|
|||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
opts := parse.QueryOptions(apiContext, schema)
|
opts := parse.QueryOptions(apiContext, schema)
|
||||||
events, err := schema.Store.Watch(apiContext, schema, &opts)
|
events, err := schema.Store.Watch(apiContext, schema, &opts)
|
||||||
if err != nil {
|
if err != nil || events == nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if events == nil {
|
for e := range events {
|
||||||
return nil
|
result <- e
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
return nil
|
||||||
select {
|
|
||||||
case e, ok := <-events:
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case result <- e:
|
|
||||||
case <-ctx.Done():
|
|
||||||
return ctx.Err()
|
|
||||||
}
|
|
||||||
case <-ctx.Done():
|
|
||||||
return ctx.Err()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user