configx

package
v0.0.0-...-890f6be Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	C = new(Config)

	A = new(Application)
)

Functions

func Load

func Load(path string, name string) error

Load loads config from path.

func ReplaceApplication

func ReplaceApplication(app Application)

ReplaceApplication replaces the application.

Types

type Application

type Application struct {
	Name         string `json:"name" yaml:"name"`
	Version      string `json:"version" yaml:"version"`
	ClientID     string `json:"client_id" yaml:"clientID"`
	ClientSecret string `json:"client_secret" yaml:"clientSecret"`
	Token        string `json:"token" yaml:"token"`

	Log     logging.Config `json:"log" yaml:"log"`
	HTTP    HTTP           `json:"http" yaml:"http"`
	LineBot LineBot        `json:"line_bot" yaml:"lineBot"`
	Storage struct {
		Mongodb struct {
			DSN string `json:"dsn" yaml:"dsn"`
		} `json:"mongodb" yaml:"mongodb"`
		Influxdb struct {
			URL   string `json:"url" yaml:"url"`
			Token string `json:"token" yaml:"token"`
		} `json:"influxdb" yaml:"influxdb"`
		Redis struct {
			Addr     string `json:"addr" yaml:"addr"`
			Password string `json:"password" yaml:"password"`
			DB       int    `json:"db" yaml:"db"`
		} `json:"redis" yaml:"redis"`
	} `json:"storage" yaml:"storage"`
	MessageQueue struct {
		Kafka struct {
			Brokers  []string `json:"brokers" yaml:"brokers"`
			GroupID  string   `json:"group_id" yaml:"groupID"`
			Topic    string   `json:"topic" yaml:"topic"`
			Username string   `json:"username" yaml:"username"`
			Password string   `json:"password" yaml:"password"`
		} `json:"kafka" yaml:"kafka"`
	} `json:"mq" yaml:"mq" mapstructure:"mq"`
}

Application defines the application struct.

func (*Application) String

func (a *Application) String() string

type Config

type Config struct {
	Log        logging.Config `json:"log" yaml:"log"`
	HTTP       HTTP           `json:"http" yaml:"http"`
	GRPC       GRPC           `json:"grpc" yaml:"grpc"`
	Cronjob    Cronjob        `json:"cronjob" yaml:"cronjob"`
	Storage    Storage        `json:"storage" yaml:"storage"`
	LineNotify LineNotify     `json:"line_notify" yaml:"lineNotify"`

	ShortenURL Application `json:"shorten_url" yaml:"shortenURL"`
	Ekko       Application `json:"ekko" yaml:"ekko"`
	Stringx    Application `json:"stringx" yaml:"stringx"`
	Orianna    Application `json:"orianna" yaml:"orianna"`
	Sion       Application `json:"sion" yaml:"sion"`
	ReURL      Application `json:"reurl" yaml:"reurl"`

	Finmind Application `json:"finmind" yaml:"finmind"`
	IRent   Application `json:"irent" yaml:"irent"`
}

Config defines the config struct.

func (*Config) String

func (c *Config) String() string

type Cronjob

type Cronjob struct {
	Interval int `json:"interval" yaml:"interval"`
}

Cronjob defines the cronjob config struct.

type GRPC

type GRPC struct {
	Host string `json:"host" yaml:"host"`
	Port int    `json:"port" yaml:"port"`
}

GRPC defines the grpc config struct.

func (*GRPC) GetAddr

func (g *GRPC) GetAddr() string

GetAddr will get the grpc address.

type HTTP

type HTTP struct {
	URL  string `json:"url" yaml:"url"`
	Host string `json:"host" yaml:"host"`
	Port int    `json:"port" yaml:"port"`
	Mode string `json:"mode" yaml:"mode"`
}

HTTP defines the http config struct.

func (*HTTP) GetAddr

func (http *HTTP) GetAddr() string

GetAddr will get the http address.

type LineBot

type LineBot struct {
	Secret string `json:"secret" yaml:"secret"`
	Token  string `json:"token" yaml:"token"`
}

LineBot defines the line bot config struct.

type LineNotify

type LineNotify struct {
	Endpoint    string `json:"endpoint" yaml:"endpoint"`
	AccessToken string `json:"access_token" yaml:"accessToken"`
}

LineNotify defines the line notify config struct.

type Storage

type Storage struct {
	DSN   string `json:"dsn" yaml:"dsn"`
	Conns int    `json:"conns" yaml:"conns"`
}

Storage defines the storage config struct.

Jump to

Keyboard shortcuts

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