config

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Developer mode, running at debugger.
	DevMode bool
	// AppName is name of this application without extension.
	AppName = util.PathName(os.Args[0])
	// Executable path.
	ExePath string
	// Configuration file with path.
	CfgFile string
	// Configuration path.
	CfgPath string
	// SQLite-files path.
	SqlPath string
)
View Source
var (
	XormStorage *xorm.Engine
	XormSpinlog *xorm.Engine
)
View Source
var (
	// compiled binary version, sets by compiler with command
	//    go build -ldflags="-X 'github.com/slotopol/server/config.BuildVers=%buildvers%'"
	BuildVers string

	// compiled binary build date, sets by compiler with command
	//    go build -ldflags="-X 'github.com/slotopol/server/config.BuildTime=%buildtime%'"
	BuildTime string
)
View Source
var Cfg = &Config{
	CfgJwtAuth: CfgJwtAuth{
		AccessTTL:    1 * 24 * time.Hour,
		RefreshTTL:   3 * 24 * time.Hour,
		AccessKey:    "skJgM4NsbP3fs4k7vh0gfdkgGl8dJTszdLxZ1sQ9ksFnxbgvw2RsGH8xxddUV479",
		RefreshKey:   "zxK4dUnuq3Lhd1Gzhpr3usI5lAzgvy2t3fmxld2spzz7a5nfv0hsksm9cheyutie",
		NonceTimeout: 150 * time.Second,
	},
	CfgGameplay: CfgGameplay{
		AdjunctLimit:    100000,
		MaxSpinAttempts: 300,
	},
	CfgXormDrv: CfgXormDrv{
		XormDriverName: "sqlite3",
	},
}

Instance of common service settings. Inits default values if config is not found.

View Source
var (
	ErrNoCfgFile = errors.New("configyration file was not found")
)

Functions

func AbsDir

func AbsDir(dir string) (string, error)

func AddDir

func AddDir(list []string, dirs ...string) ([]string, error)

func DirExists

func DirExists(fpath string) (bool, error)

DirExists check up directory existence.

func FileExists

func FileExists(fpath string) (bool, error)

FileExists check up file existence.

func InitConfig

func InitConfig()

func LookupDir

func LookupDir(list []string, fname string) string

func LookupInLocations

func LookupInLocations(env, sub, fname string) (fpath string)

func StringInSlice

func StringInSlice(a string, list []string) bool

Types

type CfgGameplay

type CfgGameplay struct {
	// Maximum value to add to wallet by one transaction.
	AdjunctLimit float64 `json:"adjunct-limit" yaml:"adjunct-limit" mapstructure:"adjunct-limit"`
	// Maximum number of spin attempts at bad bank balance.
	MaxSpinAttempts int `json:"max-spin-attempts" yaml:"max-spin-attempts" mapstructure:"max-spin-attempts"`
}

type CfgJwtAuth

type CfgJwtAuth struct {
	AccessTTL    time.Duration `json:"access-ttl" yaml:"access-ttl" mapstructure:"access-ttl"`
	RefreshTTL   time.Duration `json:"refresh-ttl" yaml:"refresh-ttl" mapstructure:"refresh-ttl"`
	AccessKey    string        `json:"access-key" yaml:"access-key" mapstructure:"access-key"`
	RefreshKey   string        `json:"refresh-key" yaml:"refresh-key" mapstructure:"refresh-key"`
	NonceTimeout time.Duration `json:"nonce-timeout" yaml:"nonce-timeout" mapstructure:"nonce-timeout"`
}

type CfgXormDrv

type CfgXormDrv struct {
	// Provides XORM driver name.
	XormDriverName string `json:"xorm-driver-name" yaml:"xorm-driver-name" mapstructure:"xorm-driver-name"`
}

type Config

type Config struct {
	CfgJwtAuth  `json:"authentication" yaml:"authentication" mapstructure:"authentication"`
	CfgGameplay `json:"gameplay" yaml:"xorm" mapstructure:"gameplay"`
	CfgXormDrv  `json:"xorm" yaml:"xorm" mapstructure:"xorm"`
}

Config is common service settings.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL