// NewMongoUserDao creates instance of MongoUserDao
NewMongoUserDao creates instance of MongoUserDao
// NewMongoUserDao creates instance of MongoUserDao
func NewMongoUserDao(URL string, databaseName string) *MongoUserDao {
	ctx, cancel := context.WithCancel(context.Background())
	client, err := mongo.Connect(ctx, options.Client().ApplyURI(URL))
	if err != nil {
		logger.Logf("ERROR Failed to dial mongo url: '%s'", URL)
		panic(err)
	}
	logger.Logf("INFO Connected to MongoDB")
	sigChan := make(chan os.Signal)
	go func() {
		for range sigChan {
			logger.Logf("INFO disconnecting from MongoDB")
			client.Disconnect(ctx)
			logger.Logf("INFO disconnected from MongoDB")
			cancel()
		}
	}()
	signal.Notify(sigChan, syscall.SIGTERM)
	return &MongoUserDao{Client: client, DatabaseName: databaseName, Ctx: ctx}
}
func NewMongoUserDao ( URL string , databaseName string ) * MongoUserDao { ctx , cancel := context . WithCancel ( context . Background ( ) ) client , err := mongo . Connect ( ctx , options . Client ( ) . ApplyURI ( URL ) ) if err != nil { logger . Logf ( " " , URL ) panic ( err ) } logger . Logf ( " " ) sigChan := make ( chan os . Signal ) go func ( ) { for range sigChan { logger . Logf ( " " ) client . Disconnect ( ctx ) logger . Logf ( " " ) cancel ( ) } } ( ) signal . Notify ( sigChan , syscall . SIGTERM ) return & MongoUserDao { Client : client , DatabaseName : databaseName , Ctx : ctx } }
NewMongoUserDao creates instance of MongoUserDao
NewMongoUserDao creates instance of MongoUserDao