feat: add worker_pool
This commit is contained in:
parent
8442e50139
commit
26a14a8a9c
|
@ -0,0 +1,140 @@
|
|||
run:
|
||||
timeout: 3m
|
||||
# Exit code when at least one issue was found.
|
||||
# Default: 1
|
||||
issues-exit-code: 2
|
||||
# Include test files or not.
|
||||
# Default: true
|
||||
tests: false
|
||||
|
||||
# Reference URL: https://golangci-lint.run/usage/linters/
|
||||
linters:
|
||||
# Disable everything by default so upgrades to not include new - default
|
||||
# enabled- linters.
|
||||
disable-all: true
|
||||
# Specifically enable linters we want to use.
|
||||
enable:
|
||||
# - depguard
|
||||
- errcheck
|
||||
# - godot
|
||||
- gofmt
|
||||
- goimports
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- revive
|
||||
# - staticcheck
|
||||
- typecheck
|
||||
- unused
|
||||
# - wsl
|
||||
- asasalint
|
||||
- asciicheck
|
||||
- bidichk
|
||||
- bodyclose
|
||||
# - containedctx
|
||||
- contextcheck
|
||||
# - cyclop
|
||||
# - varnamelen
|
||||
# - gci
|
||||
- wastedassign
|
||||
- whitespace
|
||||
# - wrapcheck
|
||||
- thelper
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unparam
|
||||
- usestdlibvars
|
||||
- tenv
|
||||
- testableexamples
|
||||
- stylecheck
|
||||
- sqlclosecheck
|
||||
- nosprintfhostport
|
||||
- paralleltest
|
||||
- prealloc
|
||||
- predeclared
|
||||
- promlinter
|
||||
- reassign
|
||||
- rowserrcheck
|
||||
- nakedret
|
||||
- nestif
|
||||
- nilerr
|
||||
- nilnil
|
||||
- nlreturn
|
||||
- noctx
|
||||
- nolintlint
|
||||
- nonamedreturns
|
||||
- decorder
|
||||
- dogsled
|
||||
# - dupl
|
||||
- dupword
|
||||
- durationcheck
|
||||
- errchkjson
|
||||
- errname
|
||||
- errorlint
|
||||
# - execinquery
|
||||
- exhaustive
|
||||
- exportloopref
|
||||
- forbidigo
|
||||
- forcetypeassert
|
||||
# - gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
# - godox
|
||||
# - goerr113
|
||||
# - gofumpt
|
||||
- goheader
|
||||
- gomoddirectives
|
||||
# - gomodguard always failed
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- grouper
|
||||
- importas
|
||||
- interfacebloat
|
||||
# - ireturn
|
||||
- lll
|
||||
- loggercheck
|
||||
- maintidx
|
||||
- makezero
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- funlen
|
||||
- goconst
|
||||
- interfacer
|
||||
- dupl
|
||||
- lll
|
||||
- goerr113
|
||||
- errcheck
|
||||
- gocritic
|
||||
- cyclop
|
||||
- wrapcheck
|
||||
- gocognit
|
||||
- contextcheck
|
||||
|
||||
linters-settings:
|
||||
gci:
|
||||
sections:
|
||||
- standard # Standard section: captures all standard packages.
|
||||
- default # Default section: contains all imports that could not be matched to another section type.
|
||||
gocognit:
|
||||
# Minimal code complexity to report.
|
||||
# Default: 30 (but we recommend 10-20)
|
||||
min-complexity: 40
|
||||
nestif:
|
||||
# Minimal complexity of if statements to report.
|
||||
# Default: 5
|
||||
min-complexity: 10
|
||||
lll:
|
||||
# Max line length, lines longer will be reported.
|
||||
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
|
||||
# Default: 120.
|
||||
line-length: 200
|
||||
# Tab width in spaces.
|
||||
# Default: 1
|
||||
tab-width: 1
|
|
@ -0,0 +1,9 @@
|
|||
.PHONY: test
|
||||
test: # 進行測試
|
||||
go test -v --cover ./...
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: # 格式優化
|
||||
$(GOFMT) -w $(GOFILES)
|
||||
goimports -w ./
|
||||
|
8
go.work
8
go.work
|
@ -1,5 +1,7 @@
|
|||
go 1.22.3
|
||||
|
||||
use ./errors
|
||||
use ./validator
|
||||
use worker_pool
|
||||
use (
|
||||
./errors
|
||||
./validator
|
||||
./worker_pool
|
||||
)
|
||||
|
|
|
@ -2,6 +2,7 @@ package required
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package worker_pool
|
||||
package workerpool
|
||||
|
||||
import (
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"sync"
|
||||
|
||||
"github.com/panjf2000/ants/v2"
|
||||
)
|
||||
|
||||
const defaultWorkerPoolSize = 2000
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package worker_pool
|
||||
package workerpool
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewWorkerPool(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue