Return []error from Stop() channel, allow recursive stop groups

This commit is contained in:
Justin Li
2018-09-09 11:14:24 -04:00
parent 21f500c93e
commit d95120c817
9 changed files with 76 additions and 57 deletions

View File

@@ -14,6 +14,7 @@ import (
"github.com/chihaya/chihaya/bittorrent"
"github.com/chihaya/chihaya/pkg/log"
"github.com/chihaya/chihaya/pkg/stop"
"github.com/chihaya/chihaya/pkg/timecache"
"github.com/chihaya/chihaya/storage"
)
@@ -707,8 +708,8 @@ func (ps *peerStore) collectGarbage(cutoff time.Time) error {
return nil
}
func (ps *peerStore) Stop() <-chan error {
c := make(chan error)
func (ps *peerStore) Stop() stop.Result {
c := make(stop.Channel)
go func() {
close(ps.closed)
ps.wg.Wait()
@@ -720,10 +721,10 @@ func (ps *peerStore) Stop() <-chan error {
}
ps.shards = shards
close(c)
c.Done()
}()
return c
return c.Result()
}
func (ps *peerStore) LogFields() log.Fields {