Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix goroutine leak #70

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/iam-apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
package main

import (
_ "go.uber.org/automaxprocs"
"math/rand"
"time"

_ "go.uber.org/automaxprocs"

"github.com/marmotedu/iam/internal/apiserver"
)

Expand Down
6 changes: 4 additions & 2 deletions cmd/iam-authz-server/authzserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
package main

import (
"github.com/marmotedu/iam/internal/authzserver"
_ "go.uber.org/automaxprocs"
"math/rand"
"time"

_ "go.uber.org/automaxprocs"

"github.com/marmotedu/iam/internal/authzserver"
)

func main() {
Expand Down
3 changes: 2 additions & 1 deletion cmd/iam-pump/pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
package main

import (
_ "go.uber.org/automaxprocs"
"math/rand"
"time"

_ "go.uber.org/automaxprocs"

"github.com/marmotedu/iam/internal/pump"
)

Expand Down
3 changes: 2 additions & 1 deletion cmd/iam-watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
package main

import (
_ "go.uber.org/automaxprocs"
"math/rand"
"time"

_ "go.uber.org/automaxprocs"

"github.com/marmotedu/iam/internal/watcher"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/apiserver/service/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (u *userService) List(ctx context.Context, opts metav1.ListOptions) (*v1.Us
}

wg := sync.WaitGroup{}
errChan := make(chan error, 1)
errChan := make(chan error, len(users.Items))
finished := make(chan bool, 1)

var m sync.Map
Expand Down
6 changes: 3 additions & 3 deletions internal/apiserver/store/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func GetMySQLFactoryOr(opts *genericoptions.MySQLOptions) (store.Factory, error)
}

// cleanDatabase tear downs the database tables.
// nolint:unused // may be reused in the feature, or just show a migrate usage.
//nolint:unused // may be reused in the feature, or just show a migrate usage.
func cleanDatabase(db *gorm.DB) error {
if err := db.Migrator().DropTable(&v1.User{}); err != nil {
return errors.Wrap(err, "drop user table failed")
Expand All @@ -110,7 +110,7 @@ func cleanDatabase(db *gorm.DB) error {

// migrateDatabase run auto migration for given models, will only add missing fields,
// won't delete/change current data.
// nolint:unused // may be reused in the feature, or just show a migrate usage.
//nolint:unused // may be reused in the feature, or just show a migrate usage.
func migrateDatabase(db *gorm.DB) error {
if err := db.AutoMigrate(&v1.User{}); err != nil {
return errors.Wrap(err, "migrate user model failed")
Expand All @@ -126,7 +126,7 @@ func migrateDatabase(db *gorm.DB) error {
}

// resetDatabase resets the database tables.
// nolint:unused,deadcode // may be reused in the feature, or just show a migrate usage.
//nolint:unused,deadcode // may be reused in the feature, or just show a migrate usage.
func resetDatabase(db *gorm.DB) error {
if err := cleanDatabase(db); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (coder ErrCode) HTTPStatus() int {
return coder.HTTP
}

// nolint: unparam
//nolint: unparam
func register(code int, httpStatus int, message string, refs ...string) {
found, _ := gubrak.Includes([]int{200, 400, 401, 403, 404, 500}, httpStatus)
if !found {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/code/code_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/pkg/logger/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const NULL = "NULL"
var convertableTypes = []reflect.Type{reflect.TypeOf(time.Time{}), reflect.TypeOf(false), reflect.TypeOf([]byte{})}

// ExplainSQL explain a SQL.
// nolint: gocognit,gocyclo
//nolint: gocognit,gocyclo
func ExplainSQL(sql string, numericPlaceholder *regexp.Regexp, escaper string, avars ...interface{}) string {
var convertParams func(interface{}, int)
vars := make([]string, len(avars))
Expand Down
1 change: 0 additions & 1 deletion internal/pump/analytics/analytics_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ func (o *AnalyticsOptions) AddFlags(fs *pflag.FlagSet) {

fs.BoolVar(&o.EnableDetailedRecording, "analytics.enable-detailed-recording", o.EnableDetailedRecording,
"Set enable detailed recording")

}
2 changes: 1 addition & 1 deletion internal/pump/pumps/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package pumps

var availablePumps map[string]Pump

// nolint: gochecknoinits
//nolint: gochecknoinits
func init() {
availablePumps = make(map[string]Pump)

Expand Down
2 changes: 1 addition & 1 deletion internal/pump/pumps/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (k *KafkaPump) Init(config interface{}) error {
}

var tlsConfig *tls.Config
// nolint: nestif
//nolint: nestif
if k.kafkaConf.UseSSL {
if k.kafkaConf.SSLCertFile != "" && k.kafkaConf.SSLKeyFile != "" {
var cert tls.Certificate
Expand Down
4 changes: 2 additions & 2 deletions internal/pump/pumps/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ func mongoType(session *mgo.Session) MongoType {
return StandardMongo
}

// nolint: gocognit
//nolint: gocognit
func mongoDialInfo(conf BaseMongoConf) (dialInfo *mgo.DialInfo, err error) {
if dialInfo, err = mgo.ParseURL(conf.MongoURL); err != nil {
return dialInfo, errors.Wrap(err, "failed to parse mongo url")
}

// nolint: nestif
//nolint: nestif
if conf.MongoUseSSL {
dialInfo.DialServer = func(addr *mgo.ServerAddr) (net.Conn, error) {
tlsConfig := &tls.Config{}
Expand Down
2 changes: 1 addition & 1 deletion internal/pump/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func filterData(pump pumps.Pump, keys []interface{}) []interface{} {
if !filters.HasFilter() && !pump.GetOmitDetailedRecording() {
return keys
}
filteredKeys := keys[:] // nolint: gocritic
filteredKeys := keys[:] //nolint: gocritic
newLenght := 0

for _, key := range filteredKeys {
Expand Down
2 changes: 1 addition & 1 deletion internal/watcher/watcher/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package all

// nolint: golint
//nolint: golint
import (
_ "github.com/marmotedu/iam/internal/watcher/watcher/clean"
_ "github.com/marmotedu/iam/internal/watcher/watcher/task"
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/redis_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func singleton(cache bool) redis.UniversalClient {
return nil
}

// nolint: unparam
//nolint: unparam
func connectSingleton(cache bool, config *Config) bool {
if singleton(cache) == nil {
log.Debug("Connecting to redis cluster")
Expand Down
4 changes: 2 additions & 2 deletions tools/codegen/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ type Package struct {
// parsePackage exits if there is an error.
func (g *Generator) parsePackage(patterns []string, tags []string) {
cfg := &packages.Config{
// nolint: staticcheck
//nolint: staticcheck
Mode: packages.LoadSyntax,
// TODO: Need to think about constants in test files. Maybe write type_string_test.go
// in a separate pass? For later.
Expand Down Expand Up @@ -340,7 +340,7 @@ func (v *Value) ParseComment() (string, string) {
return groups[1], groups[2]
}

// nolint: gocognit
//nolint: gocognit
// genDecl processes one declaration clause.
func (f *File) genDecl(node ast.Node) bool {
decl, ok := node.(*ast.GenDecl)
Expand Down