server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: GPL-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultServerConfig = Config{
		Config: core.Config{
			Debug:          false,
			DbURL:          "127.0.0.1:27017",
			DbName:         "mirror",
			DockerEndpoint: "unix:///var/run/docker.sock",
		},
		Owner:                 fmt.Sprintf("%d:%d", os.Getuid(), os.Getgid()),
		LogDir:                "/var/log/yuki/",
		ListenAddr:            "127.0.0.1:9999",
		NamePrefix:            "syncing-",
		LogLevel:              logrus.InfoLevel,
		ImagesUpgradeInterval: "@every 1h",
	}
)

Functions

func NewValidator

func NewValidator() *validator.Validate

Types

type AppConfig

type AppConfig struct {
	Debug bool `mapstructure:"debug,omitempty" validate:"-"`
	// DbURL contains username and password
	DbURL          string `mapstructure:"db_url,omitempty" validate:"omitempty,mongodb"`
	DbName         string `mapstructure:"db_name,omitempty" validate:"omitempty,alpha"`
	FileSystem     string `mapstructure:"fs,omitempty" validate:"omitempty,eq=xfs|eq=zfs|eq=default"`
	DockerEndpoint string `mapstructure:"docker_endpoint,omitempty" validate:"omitempty,unix_addr|tcp_addr"`

	Owner                 string   `mapstructure:"owner,omitempty" validate:"-"`
	LogDir                string   `mapstructure:"log_dir,omitempty" validate:"-"`
	RepoConfigDir         string   `mapstructure:"repo_config_dir,omitempty" validate:"required"`
	LogLevel              string   `mapstructure:"log_level,omitempty" validate:"omitempty,eq=debug|eq=info|eq=warn|eq=error"`
	ListenAddr            string   `mapstructure:"listen_addr,omitempty" validate:"omitempty,hostport"`
	BindIP                string   `mapstructure:"bind_ip,omitempty" validate:"omitempty,ip"`
	NamePrefix            string   `mapstructure:"name_prefix,omitempty" validate:"-"`
	PostSync              []string `mapstructure:"post_sync,omitempty" validate:"-"`
	ImagesUpgradeInterval string   `mapstructure:"images_upgrade_interval,omitempty" validate:"omitempty,cron"`
}

type Config

type Config struct {
	core.Config
	Owner                 string
	LogDir                string
	RepoConfigDir         string
	LogLevel              logrus.Level
	ListenAddr            string
	BindIP                string
	NamePrefix            string
	PostSync              []string
	ImagesUpgradeInterval string
}

func LoadConfig

func LoadConfig() (*Config, error)

type FlushWriter

type FlushWriter interface {
	io.Writer
	Flush()
}

func NewFlushWriter

func NewFlushWriter(w FlushWriter) FlushWriter

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New() (*Server, error)

func NewWithConfig

func NewWithConfig(cfg *Config) (*Server, error)

func (*Server) Start

func (s *Server) Start(ctx context.Context)

Jump to

Keyboard shortcuts

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