Skip to content

Commit

Permalink
Fixing my sql logs and etcd
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Schendel <amitschendel@gmail.com>
  • Loading branch information
amitschendel committed Jan 30, 2024
1 parent 2bbbd43 commit b030889
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/kubescape/kubescape-network-scanner/pkg/networkscanner/servicediscovery"
clientv3 "go.etcd.io/etcd/client/v3"
"go.uber.org/zap"
"google.golang.org/grpc/grpclog"
)

Expand Down Expand Up @@ -42,9 +43,15 @@ func (d *EtcdDiscovery) Protocol() string {

func (d *EtcdDiscovery) Discover(sessionHandler servicediscovery.ISessionHandler, presentationLayerDiscoveryResult servicediscovery.IPresentationDiscoveryResult) (servicediscovery.IApplicationDiscoveryResult, error) {
endpoints := []string{fmt.Sprintf("%s:%d", sessionHandler.GetHost(), sessionHandler.GetPort())}
zapLogger := zap.NewNop()
config := clientv3.Config{
Endpoints: endpoints,
DialTimeout: 3 * time.Second,
Logger: zapLogger,
LogConfig: &zap.Config{
Level: zap.NewAtomicLevelAt(zap.ErrorLevel),
Development: false,
},
}

client, err := clientv3.New(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/binary"
"fmt"
"strings"
"time"

_ "github.com/go-sql-driver/mysql"

Expand Down Expand Up @@ -54,6 +55,8 @@ func (d *MysqlDiscovery) Discover(sessionHandler servicediscovery.ISessionHandle
}
defer db.Close()
db.SetMaxIdleConns(0)
db.SetMaxOpenConns(1)
db.SetConnMaxLifetime(time.Second * 10)

// Ping the server
err = db.Ping()
Expand Down

0 comments on commit b030889

Please sign in to comment.