feat: refactor go.mod.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
"github.com/tx7do/kratos-bootstrap/utils"
|
||||
)
|
||||
|
||||
func NewCassandraClient(cfg *conf.Bootstrap, l *log.Helper) *gocql.Session {
|
||||
@@ -27,7 +28,35 @@ func NewCassandraClient(cfg *conf.Bootstrap, l *log.Helper) *gocql.Session {
|
||||
clusterConfig.Keyspace = cfg.Data.Cassandra.Keyspace
|
||||
|
||||
// 设置ssl
|
||||
clusterConfig.SslOpts = &gocql.SslOptions{Config: &tls.Config{MinVersion: tls.VersionTLS12}}
|
||||
if cfg.Data.Cassandra.Tls != nil {
|
||||
var tlsCfg *tls.Config
|
||||
var err error
|
||||
|
||||
if cfg.Data.Cassandra.Tls.File != nil {
|
||||
if tlsCfg, err = utils.LoadServerTlsConfigFile(
|
||||
cfg.Data.Cassandra.Tls.File.GetKeyPath(),
|
||||
cfg.Data.Cassandra.Tls.File.GetCertPath(),
|
||||
cfg.Data.Cassandra.Tls.File.GetCaPath(),
|
||||
cfg.Data.Cassandra.Tls.InsecureSkipVerify,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if tlsCfg == nil && cfg.Data.Cassandra.Tls.Config != nil {
|
||||
if tlsCfg, err = utils.LoadServerTlsConfig(
|
||||
cfg.Data.Cassandra.Tls.Config.GetKeyPem(),
|
||||
cfg.Data.Cassandra.Tls.Config.GetCertPem(),
|
||||
cfg.Data.Cassandra.Tls.Config.GetCaPem(),
|
||||
cfg.Data.Cassandra.Tls.InsecureSkipVerify,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
if tlsCfg != nil {
|
||||
clusterConfig.SslOpts = &gocql.SslOptions{Config: tlsCfg}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置超时时间
|
||||
clusterConfig.ConnectTimeout = cfg.Data.Cassandra.ConnectTimeout.AsDuration()
|
||||
|
||||
@@ -9,7 +9,8 @@ replace github.com/tx7do/kratos-bootstrap/api => ../../api
|
||||
require (
|
||||
github.com/go-kratos/kratos/v2 v2.8.2
|
||||
github.com/gocql/gocql v1.7.0
|
||||
github.com/tx7do/kratos-bootstrap/api v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/api v0.0.6
|
||||
github.com/tx7do/kratos-bootstrap/utils v0.1.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@@ -27,6 +27,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/tx7do/kratos-bootstrap/utils v0.1.0 h1:nY1VtIVnnGsOSj4HVhjFBk3qTxjIKDPV7lVR8ZT+gFk=
|
||||
github.com/tx7do/kratos-bootstrap/utils v0.1.0/go.mod h1:AuXQsL0dtIoOKmAaxiJnBg/9inx7kXX/z7YQeLJ1qmw=
|
||||
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
|
||||
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
||||
|
||||
Reference in New Issue
Block a user