setting and scenario in chat stat
This commit is contained in:
@@ -15,11 +15,16 @@ var MongoClient *mongo.Client
|
||||
func ConnectMongo() {
|
||||
var err error
|
||||
opts := options.Client()
|
||||
host, exists := os.LookupEnv("MONGO_HOST")
|
||||
if !exists {
|
||||
host, ok := os.LookupEnv("MONGO_HOST")
|
||||
if !ok {
|
||||
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"})
|
||||
MongoClient, err = mongo.Connect(opts)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user