Skip to content

Commit

Permalink
chore: properly check interface type for nil
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <[email protected]>
  • Loading branch information
rustatian committed Sep 5, 2024
1 parent 1aa04db commit 7b69ed7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ linters: # All available linters list: <https://golangci-lint.run/usage/linters/
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- errorlint # find code that will cause problems with the error wrapping scheme introduced in Go 1.13
- exhaustive # check exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- copyloopvar # checks for pointers to enclosing loop variables
- gochecknoglobals # Checks that no globals are present in Go code
- gochecknoinits # Checks that no init functions are present in Go code
- goconst # Finds repeated strings that could be replaced by a constant
Expand Down
10 changes: 9 additions & 1 deletion plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

jobsApi "github.com/roadrunner-server/api/v4/plugins/v4/jobs"
"github.com/roadrunner-server/pool/pool/static_pool"
jprop "go.opentelemetry.io/contrib/propagators/jaeger"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
Expand Down Expand Up @@ -224,7 +225,14 @@ func (p *Plugin) Stop(ctx context.Context) error {
// workers' pool should be stopped
p.mu.Lock()
if p.workersPool != nil {
p.workersPool.Destroy(ctx)
switch pp := p.workersPool.(type) {
case *static_pool.Pool:
if pp != nil {
pp.Destroy(ctx)
}
default:
// pool is nil, nothing to do
}
}
p.mu.Unlock()
}()
Expand Down
1 change: 0 additions & 1 deletion rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func (r *rpc) Destroy(req *jobsProto.Pipelines, resp *jobsProto.Pipelines) error

var destroyed []string
for i := 0; i < len(req.GetPipelines()); i++ {
i := i
errg.Go(func() error {
ctx, span := r.p.tracer.Tracer(spanName).Start(context.Background(), "destroy_pipeline", trace.WithSpanKind(trace.SpanKindServer))
err := r.p.Destroy(ctx, req.GetPipelines()[i])
Expand Down

0 comments on commit 7b69ed7

Please sign in to comment.