config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

func Set

func Set(c *Config)

Types

type Config

type Config struct {
	Servers       []*Server
	CurrentServer int `yaml:"currentServer"`
	Settings      Settings
	Log           *Log
}

func Get

func Get() *Config

func (*Config) Write

func (c *Config) Write() error

type Log

type Log struct {
	Output   string
	Level    string
	Format   string
	Rotation *LogRotation
}

type LogRotation

type LogRotation struct {
	// MaxSize is the maximum size in megabytes of the log file before it gets
	// rotated. It defaults to 100 megabytes.
	MaxSize int `yaml:"maxSize,omitempty" json:"maxSize,omitempty"`
	// MaxAge is the maximum number of days to retain old log files based on the
	// timestamp encoded in their filename.  Note that a day is defined as 24
	// hours and may not exactly correspond to calendar days due to daylight
	// savings, leap seconds, etc. The default is not to remove old log files
	// based on age.
	MaxAge int `yaml:"maxAge,omitempty" json:"maxAge,omitempty"`
	// MaxBackups is the maximum number of old log files to retain.  The default
	// is to retain all old log files (though MaxAge may still cause them to get
	// deleted.)
	MaxBackups int `yaml:"maxBackups,omitempty" json:"maxBackups,omitempty"`
	// LocalTime determines if the time used for formatting the timestamps in
	// backup files is the computer's local time. The default is to use UTC
	// time.
	LocalTime bool `yaml:"localTime,omitempty" json:"localTime,omitempty"`
	// Compress determines if the rotated log files should be compressed
	// using gzip. The default is not to perform compression.
	Compress bool `yaml:"compress,omitempty" json:"compress,omitempty"`
}

type Server

type Server struct {
	Name     string
	URL      string        `yaml:"url"`
	Username string        `yaml:",omitempty"`
	Password string        `yaml:",omitempty"`
	Interval time.Duration `yaml:",omitempty"`
	Timeout  time.Duration `yaml:",omitempty"`
	AutoSave string        `yaml:",omitempty"`
	Readonly bool          `yaml:",omitempty"`
	// contains filtered or unexported fields
}

func CurrentServer

func CurrentServer() *Server

func (*Server) AddEvent

func (s *Server) AddEvent(event ServerEvent)

func (*Server) Events

func (s *Server) Events() []ServerEvent

func (*Server) SetState

func (s *Server) SetState(state ServerState)

func (*Server) State

func (s *Server) State() ServerState

type ServerEvent

type ServerEvent struct {
	Time time.Time
	Msg  string
}

type ServerState

type ServerState string
const (
	ServerReady ServerState = "ready"
	ServerError ServerState = "error"
)

type Settings

type Settings struct {
	Lang  string
	Theme string
}

Jump to

Keyboard shortcuts

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