config

package
v0.0.0-alpha.0...-306d899 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package config loads config data from file or creates the file if it does not exist.

Overview

Types with a New method are meant to be used to load/save program config.

Types without a New method are meant to be embedded or used in another config struct.

If you make any changes in the config within the program, you must then use the MustUpdate method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcctSrv

type AcctSrv struct {
	Title   string
	Service // toml "Service"
	Acct    Connect
}

AcctSrv is the config interface for WAN server.

func NewAcctSrv

func NewAcctSrv() AcctSrv

NewAcctSrv creates acctsrv with saved or default values.

func (*AcctSrv) Default

func (as *AcctSrv) Default()

Default AcctSrv receives title string.

func (*AcctSrv) MustUpdate

func (as *AcctSrv) MustUpdate()

MustUpdate saves config, panics on fail.

type Cert

type Cert struct {
	HostName string
	CertFile string
	KeyFile  string
}

func (*Cert) Default

func (ct *Cert) Default(name string)

func (*Cert) Generate

func (ct *Cert) Generate() (err error)

func (*Cert) Validate

func (ct *Cert) Validate()

type Connect

type Connect struct {
	Host     string
	Port     uint16
	Database string
	User     string
	Password string
}

Connect base config interface to connect. This type is to be embedded or used in a config struct.

func (*Connect) ConnectionStr

func (cn *Connect) ConnectionStr() string

ConnectionStr returns a string from the Connect type.

func (*Connect) Default

func (cn *Connect) Default(choice string)

Default Connect receives choice of databases.

func (*Connect) MustOpenDatabase

func (cn *Connect) MustOpenDatabase() *sql.DB

MustOpenDatabase returns pointer to an sql.DB, panics on fail.

Usage:

db := cn.MustOpenDatabase()
defer db.close()

func (*Connect) OpenDatabase

func (cn *Connect) OpenDatabase() (*sql.DB, error)

OpenDatabase returns pointer to pointer to an sql.DB and error.

type ConsoleClient

type ConsoleClient struct {
	Title string
	Owner
	Service
	Game Server
}

ConsoleClient contains all config data to start program.

func NewConsoleClient

func NewConsoleClient() ConsoleClient

NewConsoleClient creates ConsoleClient with saved or default values.

func (*ConsoleClient) Default

func (cc *ConsoleClient) Default()

Default ConsoleClient.

func (*ConsoleClient) MustUpdate

func (cc *ConsoleClient) MustUpdate()

MustUpdate saves config, panics on fail.

type GameSrv

type GameSrv struct {
	Title string
	Service
	Acct Server
	Game Connect
}

gameserver config interface for LAN server.

func NewGameSrv

func NewGameSrv() GameSrv

NewGameSrv creates gameserver with saved or default values.

func (*GameSrv) Default

func (gs *GameSrv) Default()

Default gameserver

func (*GameSrv) MustUpdate

func (gs *GameSrv) MustUpdate()

MustUpdate saves config, panics on fail.

type GuiClient

type GuiClient struct {
	Title string
	Owner
	Game Server
}

guiclient contains all config data to start program.

func NewGuiClient

func NewGuiClient() GuiClient

NewGuiClient creates guiclient with saved or default values.

func (*GuiClient) Default

func (gc *GuiClient) Default()

Default guiclient.

func (*GuiClient) MustUpdate

func (gc *GuiClient) MustUpdate()

MustUpdate saves config, panics on fail.

type Owner

type Owner struct {
	Id uint64 // 'toml:"OwnerId"'
	// contains filtered or unexported fields
}

Owner base config interface for clients. This type is to be embedded or used in a config struct.

func (*Owner) Default

func (o *Owner) Default()

Default Owner.

type Ports

type Ports struct {
	Http  uint16
	Https uint16
	Rpc   uint16
}

Ports base config interface for server io. This type is to be embedded or used in a config struct.

func (*Ports) Default

func (pt *Ports) Default()

Default Ports.

type Server

type Server struct {
	Host string
	Ports
}

Server base config interface to find server. This type is to be embedded or used in a config struct.

func (*Server) Default

func (srv *Server) Default(choice string)

Default Server receives choice string for host.

func (*Server) RpcConn

func (srv *Server) RpcConn() net.Conn

RpcConn returns a net.Conn to the RPC server. TODO(ds) This may not work on Unix as Unix wants a file system path.

type Service

type Service struct {
	Cert
	Ports
}

Type Service embeds Cert and Port.

func (*Service) Default

func (sv *Service) Default(name string)

Function Default receives name string and sets default values.

func (*Service) Start

func (sv *Service) Start(mux *http.ServeMux) (err error)

Function Start

type TestSrv

type TestSrv struct {
	Title      string
	GameServer Ports
	AcctServer Ports
	Game       Connect
	Acct       Connect
}

TestSrv config interface for test server.

func NewTestSrv

func NewTestSrv() TestSrv

NewTestSrv creates TestSrv with saved or default values.

func (*TestSrv) Default

func (ts *TestSrv) Default()

Default TestSrv receives title string.

func (*TestSrv) MustUpdate

func (ts *TestSrv) MustUpdate()

MustUpdate saves config, panics on fail.

type WebClient

type WebClient struct {
	Title string
	Owner
	Game Server
}

ConsoleClient contains all config data to start program.

func NewWebClient

func NewWebClient() WebClient

NewWebClient creates webclient with saved or default values.

func (*WebClient) Default

func (wc *WebClient) Default()

Default webclient.

func (*WebClient) MustUpdate

func (wc *WebClient) MustUpdate()

MustUpdate saves config, panics on fail.

Jump to

Keyboard shortcuts

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