config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config uses Viper to load all configuration from the yml config file.

Index

Constants

View Source
const (
	// APIUser represents the group of user management API
	APIUser = API + "/user"
	// APIUserLogin represents the API to login by authentication
	APIUserLogin = APIUser + "/login"
	APIUserList  = APIUser + "/list"
	APIUserInfo  = APIUser + "/info"
)
View Source
const (
	APIRole       = API + "/role"
	APIRoleList   = APIRole + "/list"
	APIRoleCreate = APIRole + "/create"
	APIRoleUpdate = APIRole + "/update/:roleId"
)
View Source
const (
	APIConversation            = "/api/conversation"
	APIConversationList        = APIConversation + "/list"
	APIConversationInfo        = APIConversation + "/:conversationId"
	APIMessageFeedback         = APIConversation + "/message_feedback"
	APIConversationBatchDelete = APIConversation + "/delete/batch"
	APIConversationWS          = APIConversation + "/ws"
	APIConversationBase        = APIConversation + "/base"
)
View Source
const (
	APICode         = "/api/code"
	APICodeGenerate = APICode + "/generate"
)
View Source
const (
	APILLM     = "/api/llm"
	APILLMList = APILLM + "/list"
)
View Source
const (
	// API represents the group of API
	API = "/api"
)
View Source
const (
	APIHealth = API + "/health"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfiguration

type AuthConfiguration struct {
	JwtKey    string `mapstructure:"jwt-key" json:"jwtKey"`
	Expires   uint   `mapstructure:"expires" json:"expires"`
	RuleTable string `mapstructure:"rule-table" json:"ruleTable"`
}

type Configuration

type Configuration struct {
	System   SystemConfiguration   `mapstructure:"system" json:"system"`
	Logs     LogsConfiguration     `mapstructure:"logs" json:"logs"`
	Database DatabaseConfiguration `mapstructure:"database" json:"database"`
	Auth     AuthConfiguration     `mapstructure:"auth" json:"auth"`
	Consul   ConsulConfiguration   `mapstructure:"consul" json:"consul"`
}

Configuration represents the composition of yml settings. Viper has a built-in mapstructure, and the yml file uses "-" to distinguish words.

func LoadAppConfig

func LoadAppConfig(filename string) (*Configuration, error)

LoadAppConfig reads the settings written to the yml file

type ConsulConfiguration

type ConsulConfiguration struct {
	Address string `mapstructure:"address" json:"address"`
	Port    int    `mapstructure:"port" json:"port"`
}

type DatabaseConfiguration

type DatabaseConfiguration struct {
	Dialect     string `mapstructure:"dialect" json:"dialect"`
	Username    string `mapstructure:"username" json:"username"`
	Password    string `mapstructure:"password" json:"password"`
	Dbname      string `mapstructure:"dbname" json:"dbname"`
	Host        string `mapstructure:"host" json:"host"`
	Port        int    `mapstructure:"port" json:"port"`
	Query       string `mapstructure:"query" json:"query"`
	LogMode     bool   `mapstructure:"log-mode" json:"logMode"`
	TablePrefix string `mapstructure:"table-prefix" json:"tablePrefix"`
	Charset     string `mapstructure:"charset" json:"charset"`
	Collation   string `mapstructure:"collation" json:"collation"`
	Migration   bool   `mapstructure:"migration" json:"migration"`
	InitData    bool   `mapstructure:"init-data" json:"initData"`
}

type LogsConfiguration

type LogsConfiguration struct {
	Encoding   string        `mapstructure:"encoding" json:"encoding"`
	Level      zapcore.Level `mapstructure:"level" json:"level"`
	Path       string        `mapstructure:"path" json:"path"`
	MaxSize    int           `mapstructure:"max-size" json:"maxSize"`
	MaxBackups int           `mapstructure:"max-backups" json:"maxBackups"`
	MaxAge     int           `mapstructure:"max-age" json:"maxAge"`
	Compress   bool          `mapstructure:"compress" json:"compress"`
}

type SystemConfiguration

type SystemConfiguration struct {
	ApiVersion  string `mapstructure:"api-version" json:"apiVersion"`
	WaitTimeout int    `mapstructure:"wait-timeout" json:"waitTimeout"`
}

Jump to

Keyboard shortcuts

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