setting and scenario in chat stat
This commit is contained in:
@@ -15,11 +15,16 @@ var MongoClient *mongo.Client
|
|||||||
func ConnectMongo() {
|
func ConnectMongo() {
|
||||||
var err error
|
var err error
|
||||||
opts := options.Client()
|
opts := options.Client()
|
||||||
host, exists := os.LookupEnv("MONGO_HOST")
|
host, ok := os.LookupEnv("MONGO_HOST")
|
||||||
if !exists {
|
if !ok {
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
}
|
}
|
||||||
opts = opts.ApplyURI(fmt.Sprintf("mongodb://%s:%s@%s:27017", os.Getenv("MONGO_USER"), os.Getenv("MONGO_PASS"), host))
|
opts = opts.ApplyURI(fmt.Sprintf(
|
||||||
|
"mongodb://%s:%s@%s:27017",
|
||||||
|
os.Getenv("MONGO_USER"),
|
||||||
|
os.Getenv("MONGO_PASS"),
|
||||||
|
host,
|
||||||
|
))
|
||||||
opts = opts.SetCompressors([]string{"snappy", "zlib", "zstd"})
|
opts = opts.SetCompressors([]string{"snappy", "zlib", "zstd"})
|
||||||
MongoClient, err = mongo.Connect(opts)
|
MongoClient, err = mongo.Connect(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user