Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Tobias Gesellchen <tobias@gesellix.de>
  • Loading branch information
obaudys and gesellix committed Aug 24, 2019
1 parent cdfa65b commit 4ea8210
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion couchdb-exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func init() {
}),
altsrc.NewUintFlag(cli.UintFlag{
Name: "database.concurrent.requests",
Usage: "maximum concurrent calls to couchDB, or 0 for unlimited",
Usage: "maximum concurrent calls to CouchDB, or 0 for unlimited",
Value: 0,
Hidden: false,
Destination: &exporterConfig.databaseConcurrentRequests,
Expand Down
10 changes: 6 additions & 4 deletions lib/couchdb-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ func (c *CouchdbClient) enhanceWithViewUpdateSeq(dbStatsByDbName map[string]Data
for _, row := range designDocs.Rows {
row := row
go func() {
defer func() { done <- struct{}{} }()
defer func() {
done <- struct{}{}
}()
updateSeqByView := make(ViewStats)
type viewresult struct {
viewName string
Expand All @@ -366,7 +368,7 @@ func (c *CouchdbClient) enhanceWithViewUpdateSeq(dbStatsByDbName map[string]Data
err := semaphore.Acquire()
if err != nil {
// send something to parent coroutine so it doesn't block forever on receive
v <- viewresult{err: fmt.Errorf("Aborted view stats for /%s/%s/_view/%s", dbName, row.Doc.Id, viewName)}
v <- viewresult{err: fmt.Errorf("aborted view stats for /%s/%s/_view/%s", dbName, row.Doc.Id, viewName)}
return
}
query := strings.Join([]string{
Expand Down Expand Up @@ -579,7 +581,7 @@ func NewSemaphore(concurrency uint) Semaphore {
func (s Semaphore) Acquire() error {
select {
case <-s.abort:
return fmt.Errorf("Could not acquire semaphore")
return fmt.Errorf("could not acquire semaphore")
case <-s.sem:
return nil
}
Expand All @@ -594,7 +596,7 @@ func (s Semaphore) Release() {
}
}

// Signal abort for anyone waiting on the Semaphor
// Signal abort for anyone waiting on the Semaphore
func (s Semaphore) Abort() {
select {
case <-s.abort:
Expand Down
2 changes: 1 addition & 1 deletion lib/couchdb-client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestSerialSemaphore(t *testing.T) {
}
sem.Release()
time.Sleep(20 * time.Millisecond)
if len(results) > 20 { // should never complete this many in the alotted time
if len(results) > 20 { // should never complete this many in the allotted time
t.Error("Workers completed job too fast", len(results))
}
}
Expand Down

0 comments on commit 4ea8210

Please sign in to comment.