Skip to content

Commit 3b24c6c

Browse files
fix golint issues
1 parent 79288c8 commit 3b24c6c

File tree

9 files changed

+20
-15
lines changed

9 files changed

+20
-15
lines changed

doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// Package go_concurrency_limits provides primitives for concurrency control in complex systems.
2-
package go_concurrency_limits
1+
// Package provides primitives for concurrency control in complex systems.
2+
package main

metric_registry/doc.go

Lines changed: 0 additions & 2 deletions
This file was deleted.

patterns/pool/example_fixed_pool_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
)
1111

1212
func ExampleFixedPool() {
13-
var JobKey = "job_id"
13+
type JobKey string
14+
var JobKeyID = JobKey("job_id")
1415

1516
l := 1000 // limit to 1000 concurrent requests.
1617
// create a new pool
@@ -35,7 +36,7 @@ func ExampleFixedPool() {
3536
for i := 0; i <= l*3; i++ {
3637
go func(c int) {
3738
defer wg.Done()
38-
ctx := context.WithValue(context.Background(), JobKey, c)
39+
ctx := context.WithValue(context.Background(), JobKeyID, c)
3940
// this will block until timeout or token was acquired.
4041
listener, ok := pool.Acquire(ctx)
4142
if !ok {

patterns/pool/example_generic_pool_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
)
1313

1414
func ExamplePool() {
15-
var JobKey = "job_id"
15+
type JobKey string
16+
var JobKeyID = JobKey("job_id")
1617

1718
l := 1000 // limit to adjustable 1000 concurrent requests.
1819
delegateLimit := limit.NewDefaultAIMLimit(
@@ -54,7 +55,7 @@ func ExamplePool() {
5455
for i := 0; i <= l*3; i++ {
5556
go func(c int) {
5657
defer wg.Done()
57-
ctx := context.WithValue(context.Background(), JobKey, c)
58+
ctx := context.WithValue(context.Background(), JobKeyID, c)
5859
// this will block until timeout or token was acquired.
5960
listener, ok := pool.Acquire(ctx)
6061
if !ok {

patterns/pool/example_lifo_fixed_pool_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
)
1111

1212
func ExampleLIFOFixedPool() {
13-
var JobKey = "job_id"
13+
type JobKey string
14+
var JobKeyID = JobKey("job_id")
1415

1516
l := 1000 // limit to 1000 concurrent requests.
1617
// create a new pool
@@ -36,7 +37,7 @@ func ExampleLIFOFixedPool() {
3637
for i := 0; i <= l*3; i++ {
3738
go func(c int) {
3839
defer wg.Done()
39-
ctx := context.WithValue(context.Background(), JobKey, c)
40+
ctx := context.WithValue(context.Background(), JobKeyID, c)
4041
// this will block until timeout or token was acquired.
4142
listener, ok := pool.Acquire(ctx)
4243
if !ok {

patterns/pool/fixed_pool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestFixedPool(t *testing.T) {
3333
wg.Add(1)
3434
go func(c int) {
3535
defer wg.Done()
36-
l, _ := p.Acquire(context.WithValue(context.Background(), "id", fmt.Sprint(c)))
36+
l, _ := p.Acquire(context.WithValue(context.Background(), testKeyID, fmt.Sprint(c)))
3737
log.Printf("acquired now, sleeping - %d\n", c)
3838
time.Sleep(time.Millisecond * 100)
3939
l.OnSuccess()

patterns/pool/generic_pool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestGenericPool(t *testing.T) {
4343
wg.Add(1)
4444
go func(c int) {
4545
defer wg.Done()
46-
l, _ := p.Acquire(context.WithValue(context.Background(), "id", fmt.Sprint(c)))
46+
l, _ := p.Acquire(context.WithValue(context.Background(), testKeyID, fmt.Sprint(c)))
4747
log.Printf("acquired now, sleeping - %d\n", c)
4848
time.Sleep(time.Millisecond * 100)
4949
l.OnSuccess()

patterns/pool/lifo_fixed_pool_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
)
1313

14+
type testKey string
15+
16+
const testKeyID = testKey("id")
17+
1418
func TestLIFOFixedPool(t *testing.T) {
1519
asrt := assert.New(t)
1620
p, err := NewLIFOFixedPool(
@@ -34,7 +38,7 @@ func TestLIFOFixedPool(t *testing.T) {
3438
wg.Add(1)
3539
go func(c int) {
3640
defer wg.Done()
37-
l, _ := p.Acquire(context.WithValue(context.Background(), "id", fmt.Sprint(c)))
41+
l, _ := p.Acquire(context.WithValue(context.Background(), testKeyID, fmt.Sprint(c)))
3842
log.Printf("acquired now, sleeping - %d\n", c)
3943
time.Sleep(time.Millisecond * 100)
4044
l.OnSuccess()

strategy/precise.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ func (s *PreciseStrategy) TryAcquire(ctx context.Context) (token core.StrategyTo
4848
s.metricListener.AddSample(float64(s.inFlight))
4949
return core.NewNotAcquiredStrategyToken(int(s.inFlight)), false
5050
}
51-
s.inFlight += 1
51+
s.inFlight++
5252
s.metricListener.AddSample(float64(s.inFlight))
5353
return core.NewAcquiredStrategyToken(int(s.inFlight), s.releaseHandler), true
5454
}
5555

5656
func (s *PreciseStrategy) releaseHandler() {
5757
s.mu.Lock()
58-
s.inFlight -= 1
58+
s.inFlight--
5959
s.mu.Unlock()
6060
}
6161

0 commit comments

Comments
 (0)