config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2018 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host      *string `yaml:"host"`
	Port      *int    `yaml:"port"`
	DBPath    *string `yaml:"db_path"`
	IndexPath *string `yaml:"index_path"`

	Dictionary *string `yaml:"dictionary"`
	StopTokens *string `yaml:"stop_tokens"`

	Source *Source `yaml:"source"`

	Logger *Logger `yaml:"logger"`
}

Config contains all config needed by xuanzang.

func New

func New() *Config

New will create a new config instance.

func (*Config) Check

func (c *Config) Check() error

Check will check if the config is valid.

func (*Config) LoadFromContent

func (c *Config) LoadFromContent(content []byte) error

LoadFromContent loads configuration from a given bytes. It returns error if yaml decode failed.

func (*Config) LoadFromFilePath

func (c *Config) LoadFromFilePath(filePath string) error

LoadFromFilePath loads configuration from a specified local path. It returns error if file not found or yaml decode failed.

type Logger

type Logger struct {
	Level  string `yaml:"level"`
	Output string `yaml:"output"`
}

Logger sotres the config for logger.

func (*Logger) Prepare

func (l *Logger) Prepare() error

Prepare will create logger instance.

type Source

type Source struct {
	Type     string `yaml:"type"`
	URL      string `yaml:"url"`
	Duration int    `yaml:"duration"`
}

Source will specify a source for xuanzang.

Jump to

Keyboard shortcuts

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