package config

import (
	"context"
	"fmt"
	"local/storage"
	"sync"
)

var config Config
var lock = &sync.RWMutex{}

type Config struct {
	db               string
	DB               storage.DB
	Port             string
	Addr             string
	Username         string
	Password         string
	DefaultNamespace string
	Ctx              context.Context
	Can              context.CancelFunc
}

func Values() Config {
	lock.RLock()
	defer lock.RUnlock()
	return config
}

func (c Config) String() string {
	return fmt.Sprintf(
		"port:%v db:%v addr:%v user:*** pass:*** ns:%s",
		c.Port,
		c.db,
		c.Addr,
		c.DefaultNamespace,
	)
}
