config

package
v0.0.0-...-9eaf9d2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCORS

func InitCORS(cfg *CORSConfig) cors.Config

func InitDB

func InitDB(cfg *DBConfig) (*gorm.DB, *sql.DB, error)

func InitLog

func InitLog(env string, cfg *LogConfig) error

func InitTracerProvider

func InitTracerProvider(cfg *Config) (*sdktrace.TracerProvider, error)

Types

type AppConfig

type AppConfig struct {
	Name          string `yaml:"name" validate:"required"`
	HTTPPort      int    `yaml:"httpPort" validate:"required"`
	MetricsPort   int    `yaml:"metricsPort" validate:"required"`
	OwnerPassword string `yaml:"ownerPassword" validate:"required"`
	TestUserEmail string `yaml:"testUserEmail" validate:"required"`
}

type AuthConfig

type AuthConfig struct {
	SigningKey          string `yaml:"signingKey"`
	AccessTokenTTLMin   int    `yaml:"accessTokenTtlMin" validate:"gte=1"`
	RefreshTokenTTLHour int    `yaml:"refreshTokenTtlHour" validate:"gte=1"`
	GoogleCallbackURL   string `yaml:"googleCallbackUrl" validate:"required"`
	GoogleClientID      string `yaml:"googleClientId" validate:"required"`
	GoogleClientSecret  string `yaml:"googleClientSecret" validate:"required"`
	APITimeoutSec       int    `yaml:"apiTimeoutSec" validate:"gte=1"`
}

type CORSConfig

type CORSConfig struct {
	AllowOrigins []string `yaml:"allowOrigins"`
}

type Config

type Config struct {
	App         *AppConfig         `yaml:"app" validate:"required"`
	DB          *DBConfig          `yaml:"db" validate:"required"`
	Auth        *AuthConfig        `yaml:"auth" validate:"required"`
	Translator  *TranslatorConfig  `yaml:"translator" validate:"required"`
	Tatoeba     *TatoebaConfig     `yaml:"tatoeba" validate:"required"`
	Synthesizer *SynthesizerConfig `yaml:"synthesizer" validate:"required"`
	Trace       *TraceConfog       `yaml:"trace" validate:"required"`
	CORS        *CORSConfig        `yaml:"cors" validate:"required"`
	Shutdown    *ShutdownConfig    `yaml:"shutdown" validate:"required"`
	Log         *LogConfig         `yaml:"log" validate:"required"`
	Swagger     *SwaggerConfig     `yaml:"swagger" validate:"required"`
	Debug       *DebugConfig       `yaml:"debug"`
}

func LoadConfig

func LoadConfig(env string) (*Config, error)

type DBConfig

type DBConfig struct {
	DriverName string         `yaml:"driverName"`
	SQLite3    *SQLite3Config `yaml:"sqlite3"`
	MySQL      *MySQLConfig   `yaml:"mysql"`
}

type DebugConfig

type DebugConfig struct {
	GinMode bool `yaml:"ginMode"`
	Wait    bool `yaml:"wait"`
}

type JaegerConfig

type JaegerConfig struct {
	Endpoint string `yaml:"endpoint" validate:"required"`
}

type LogConfig

type LogConfig struct {
	Level string `yaml:"level"`
}

type MySQLConfig

type MySQLConfig struct {
	Username string `yaml:"username" validate:"required"`
	Password string `yaml:"password" validate:"required"`
	Host     string `yaml:"host" validate:"required"`
	Port     int    `yaml:"port" validate:"required"`
	Database string `yaml:"database" validate:"required"`
}

type SQLite3Config

type SQLite3Config struct {
	File string `yaml:"file" validate:"required"`
}

type ShutdownConfig

type ShutdownConfig struct {
	TimeSec1 int `yaml:"timeSec1" validate:"gte=1"`
	TimeSec2 int `yaml:"timeSec2" validate:"gte=1"`
}

type SwaggerConfig

type SwaggerConfig struct {
	Enabled bool   `yaml:"enabled"`
	Host    string `yaml:"host"`
	Schema  string `yaml:"schema"`
}

type SynthesizerConfig

type SynthesizerConfig struct {
	Endpoint   string `yaml:"endpoint" validate:"required"`
	TimeoutSec int    `yaml:"timeoutSec" validate:"gte=1"`
	Username   string `yaml:"username" validate:"required"`
	Password   string `yaml:"password" validate:"required"`
}

type TatoebaConfig

type TatoebaConfig struct {
	Endpoint   string `yaml:"endpoint" validate:"required"`
	TimeoutSec int    `yaml:"timeoutSec" validate:"gte=1"`
	Username   string `yaml:"username" validate:"required"`
	Password   string `yaml:"password" validate:"required"`
}

type TraceConfog

type TraceConfog struct {
	Exporter string        `yaml:"exporter" validate:"required"`
	Jaeger   *JaegerConfig `yaml:"jaeger"`
}

type TranslatorConfig

type TranslatorConfig struct {
	Endpoint   string `yaml:"endpoint" validate:"required"`
	TimeoutSec int    `yaml:"timeoutSec" validate:"gte=1"`
	Username   string `yaml:"username" validate:"required"`
	Password   string `yaml:"password" validate:"required"`
	GRPCAddr   string `yaml:"grpcAddr" validate:"required"`
}

Jump to

Keyboard shortcuts

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