config

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	C = &Config{}
)

Functions

func InitConfigWithViper

func InitConfigWithViper()

Types

type Cache added in v0.7.0

type Cache struct {
	RefreshTime time.Duration `default:"2m" yaml:"refreshTime"`
}

type Config

type Config struct {
	LogLevel string `default:"DEBUG" yaml:"logLevel"`
	Mode     string `default:"debug" yaml:"mode"`

	Sentry  Sentry  `yaml:"sentry"`
	Tracing Tracing `yaml:"tracing"`

	HTTP     HTTP     `yaml:"http"`
	GRPC     GRPC     `yaml:"grpc"`
	Database Database `yaml:"database"`
	NATS     NATS     `yaml:"nats"`
	JWT      JWT      `yaml:"jwt"`
	OAuth2   OAuth2   `yaml:"oauth2"`
	Cache    Cache    `yaml:"cache"`

	Game Game `yaml:"game"`
}

type Database

type Database struct {
	// refer to https://github.com/go-sql-driver/mysql#dsn-data-source-name for details
	DSN    string `yaml:"dsn"`
	DBName string `yaml:"dbName"`

	MaxOpenConns    int           `default:"32" yaml:"maxOpenConns"`
	MaxIdleConns    int           `default:"5" yaml:"maxIdleConns"`
	ConnMaxIdleTime time.Duration `default:"15m" yaml:"connMaxIdleTime"`
	ConnMaxLifetime time.Duration `default:"60m" yaml:"connMaxLifetime"`
}

type GRPC

type GRPC struct {
	Listen string `default:":9090" yaml:"listen"`
}

type Game

type Game struct {
	SuperuserGroups    []string      `yaml:"superuserGroups"`
	UnemployedJob      UnemployedJob `yaml:"unemployedJob"`
	PublicJobs         []string      `yaml:"publicJobs"`
	Livemap            Livemap       `yaml:"livemap"`
	DefaultPermissions []Perm        `yaml:"defaultPermissions"`
}

type HTTP

type HTTP struct {
	Listen   string   `default:":8080" yaml:"listen"`
	Sessions Sessions `yaml:"sessions"`
}

type JWT

type JWT struct {
	Secret string `yaml:"secret"`
}

type Livemap added in v0.5.0

type Livemap struct {
	RefreshTime time.Duration `default:"3s850ms" yaml:"refreshTime"`
	Jobs        []string      `yaml:"jobs"`
}

type NATS added in v0.5.1

type NATS struct {
	URL         string `default:"nats://localhost:4222" yaml:"url"`
	WorkerCount int    `default:"5" yaml:"workerCount"`
}

type OAuth2

type OAuth2 struct {
	Providers []*OAuth2Provider
}

type OAuth2Endpoints

type OAuth2Endpoints struct {
	AuthURL     string `yaml:"authURL"`
	TokenURL    string `yaml:"tokenURL"`
	UserInfoURL string `yaml:"userInfoURL"`
}

type OAuth2Mapping

type OAuth2Mapping struct {
	ID       string `yaml:"id"`
	Username string `yaml:"username"`
	Avatar   string `yaml:"avatar"`
}

type OAuth2Provider

type OAuth2Provider struct {
	Name          string             `yaml:"name"`
	Label         string             `yaml:"label"`
	Homepage      string             `yaml:"homepage"`
	Type          OAuth2ProviderType `yaml:"type"`
	DefaultAvatar string             `yaml:"defaultAvatar"`
	RedirectURL   string             `yaml:"redirectURL"`
	ClientID      string             `yaml:"clientID"`
	ClientSecret  string             `yaml:"clientSecret"`
	Scopes        []string           `yaml:"scopes"`
	Endpoints     OAuth2Endpoints    `yaml:"endpoints"`
	Mapping       *OAuth2Mapping     `yaml:"omitempty,mapping"`
}

type OAuth2ProviderType

type OAuth2ProviderType string
const (
	OAuth2ProviderGeneric OAuth2ProviderType = "generic"
	OAuth2ProviderDiscord OAuth2ProviderType = "discord"
)

type Perm

type Perm struct {
	Category string `yaml:"category"`
	Name     string `yaml:"name"`
}

type Sentry

type Sentry struct {
	ServerDSN   string `yaml:"serverDSN"`
	Environment string `default:"dev" yaml:"environment"`
	ClientDSN   string `default:"" yaml:"clientDSN"`
}

type Sessions

type Sessions struct {
	CookieSecret string `yaml:"cookieSecret"`
	Domain       string `default:"localhost" yaml:"domain"`
}

type Tracing

type Tracing struct {
	Enabled     bool   `default:"false" yaml:"enabled"`
	URL         string `yaml:"url"`
	Environment string `default:"dev" yaml:"environment"`
}

type UnemployedJob

type UnemployedJob struct {
	Name  string `default:"unemployed" yaml:"job"`
	Grade int32  `default:"1" yaml:"grade"`
}

Jump to

Keyboard shortcuts

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