summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-09-21 15:27:59 +0000
committerGitHub <[email protected]>2020-09-21 15:27:59 +0000
commit95f7dabcd6a3867d6a4619c0efa08fdfc3bc270d (patch)
tree981ee8b71f3fe31ef6d73593a0a9b6ae0b189216
parent0af502835616774a8b306596e4d1a8c5843b6bc8 (diff)
parentb02aa40700946d90ce9d5d5c3ead78f427bce7bf (diff)
Merge #360
360: Simplify watcher test, fix lgtm warinings and errors r=48d90782 a=48d90782 Co-authored-by: Valery Piashchynski <[email protected]>
-rwxr-xr-xservice/reload/213977608/file.txt0
-rwxr-xr-xservice/reload/423382903/file.txt0
-rw-r--r--service/reload/watcher.go11
-rw-r--r--static_pool.go2
-rw-r--r--worker.go2
5 files changed, 4 insertions, 11 deletions
diff --git a/service/reload/213977608/file.txt b/service/reload/213977608/file.txt
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/service/reload/213977608/file.txt
diff --git a/service/reload/423382903/file.txt b/service/reload/423382903/file.txt
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/service/reload/423382903/file.txt
diff --git a/service/reload/watcher.go b/service/reload/watcher.go
index 027d2d0d..721495c3 100644
--- a/service/reload/watcher.go
+++ b/service/reload/watcher.go
@@ -177,15 +177,6 @@ func (w *Watcher) retrieveFilesSingle(serviceName, path string) (map[string]os.F
// so, we will add files with goto pattern
outer:
for i := 0; i < len(fileInfoList); i++ {
- var pathToFile string
- // BCE check elimination
- // https://go101.org/article/bounds-check-elimination.html
- if len(fileInfoList) != 0 && len(fileInfoList) >= i {
- pathToFile = filepath.Join(pathToFile, fileInfoList[i].Name())
- } else {
- return nil, errors.New("file info list len")
- }
-
// if file in ignored --> continue
if _, ignored := w.watcherConfigs[serviceName].ignored[path]; ignored {
continue
@@ -199,7 +190,7 @@ outer:
}
}
- filesList[pathToFile] = fileInfoList[i]
+ filesList[fileInfoList[i].Name()] = fileInfoList[i]
}
return filesList, nil
diff --git a/static_pool.go b/static_pool.go
index c7cc6517..c4b6f42d 100644
--- a/static_pool.go
+++ b/static_pool.go
@@ -188,6 +188,7 @@ func (p *StaticPool) Destroy() {
// finds free worker in a given time interval. Skips dead workers.
func (p *StaticPool) allocateWorker() (w *Worker, err error) {
+ // TODO loop counts upward, but its variable is bounded downward.
for i := atomic.LoadInt64(&p.numDead); i >= 0; i++ {
// this loop is required to skip issues with dead workers still being in a ring
// (we know how many workers).
@@ -291,6 +292,7 @@ func (p *StaticPool) discardWorker(w *Worker, caused interface{}) {
}
// destroyWorker destroys workers and removes it from the pool.
+// TODO caused unused
func (p *StaticPool) destroyWorker(w *Worker, caused interface{}) {
go func() {
err := w.Stop()
diff --git a/worker.go b/worker.go
index 3740aee8..4fbf4369 100644
--- a/worker.go
+++ b/worker.go
@@ -250,7 +250,7 @@ func (w *Worker) execPayload(rqs *Payload) (rsp *Payload, err error) {
}
// add streaming support :)
- if rsp.Body, pr, err = w.rl.Receive(); err != nil {
+ if rsp.Body, _, err = w.rl.Receive(); err != nil {
return nil, errors.Wrap(err, "worker error")
}