PT-1706 Made mongo tools compile with Go 1.12

- Removed t.parallel from tests
- Added lock to stats  pkg
- Fixed timeout channels usage in stats pkg
- Removed non-compatible dependency (badfix/slice) and its dependencies
- Made code improvements for linter
This commit is contained in:
Carlos Salguero
2019-03-31 04:20:31 -03:00
parent 39aa1f88f0
commit cdea59e688
8 changed files with 202 additions and 114 deletions

View File

@@ -57,7 +57,7 @@ func NewProfiler(iterator pmgo.IterManager, filters []filter.Filter, ticker <-ch
// internal
docsChan: make(chan proto.SystemProfile, DocsBufferSize),
timeoutsChan: nil,
timeoutsChan: make(chan time.Time),
keyFilters: []string{"^shardVersion$", "^\\$"},
}
}
@@ -97,9 +97,6 @@ func (p *Profile) Stop() {
func (p *Profile) TimeoutsChan() <-chan time.Time {
p.lock.Lock()
defer p.lock.Unlock()
if p.timeoutsChan == nil {
p.timeoutsChan = make(chan time.Time)
}
return p.timeoutsChan
}
@@ -129,14 +126,15 @@ func (p *Profile) getDocs() {
for p.iterator.Next(&doc) || p.iterator.Timeout() {
if p.iterator.Timeout() {
if p.timeoutsChan != nil {
p.timeoutsChan <- time.Now().UTC()
select {
case p.timeoutsChan <- time.Now().UTC():
default:
}
continue
}
valid := true
for _, filter := range p.filters {
if filter(doc) == false {
if !filter(doc) {
valid = false
break
}