config

package
v0.0.0-...-b3f3fbb Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2015 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package config provides a system-wide configuration facility

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteConfig

func WriteConfig(w io.Writer, cfg Config) error

WriteConfig will write the given config to the given Writer as JSON (pretty printed

Types

type Config

type Config struct {
	// Payment config
	Payment struct {
		// Prime for obfuscating payment IDs
		PaymentIDEncPrime int64
		// XOR value to be applied to obfuscated primes
		PaymentIDEncXOR int64
	}
	// Database config
	Database struct {
		// Maximum number of retries on transaction lock errors
		TransactionMaxRetries int
		// Maximum number of database connections
		MaxOpenConns int
		// Maximum number of idle connections in the connection pool
		MaxIdleConns int
		// Principal database
		Principal struct {
			Write    DatabaseConfig
			ReadOnly DatabaseConfig
		}
		// Payment database
		Payment struct {
			Write    DatabaseConfig
			ReadOnly DatabaseConfig
		}
	}
	// API server config
	API struct {
		// Should the API server be activated?
		Active bool
		// API service config
		Service ServiceConfig
		// Service timeout
		Timeout Duration

		// Should the API server provide administrative endpoints?
		ServeAdmin bool
		// SSL?
		Secure bool
		// Cookie-based authentication settings
		Cookie struct {
			// Should the API allow cookie-based authentication?
			AllowCookieAuth bool
			HTTPOnly        bool
		}

		// serve the adminpanel gui files (fullfill same origin policy)
		AdminGUIPubWWWDir string

		AuthKeys []string
	}
	// Web server config
	Web struct {
		// Whether the WWW-service should be active
		Active bool
		// The URL under which the WWW-service is served
		URL string
		// WWW service config
		Service ServiceConfig
		// Service timeout
		Timeout Duration

		// Public WWW directory
		PubWWWDir string
		// Template (base-)directory
		TemplateDir string

		// Whether the WWW-service is served securely
		Secure bool

		// Cookie config
		Cookie struct {
			// Whether so serve cookies as HTTPOnly
			HTTPOnly bool
		}
		// Web auth keys for encrypting cookie auth containers
		AuthKeys []string
	}
	Provider struct {
		URL string

		ProviderTemplateDir string
	}
}

Config represents a full configuration for any paymentd related applications

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a default configuration

func ReadConfig

func ReadConfig(r io.Reader) (Config, error)

ReadConfig reads the JSON from the given reader into a new Config

func (*Config) ReadConfig

func (c *Config) ReadConfig(r io.Reader) error

ReadConfig reads a JSON from the given reader into the config

type DatabaseConfig

type DatabaseConfig map[string]string

DatabaseConfig represents a single database DSN It is a map, so the JSON representation can include the backend type and the DSN, e.g.

{
  "mysql": "paymentd@tcp(localhost:3306)/fritzpay"
}

func NewDatabaseConfig

func NewDatabaseConfig() DatabaseConfig

NewDatabaseConfig creates a new DatabaseConfig

func (DatabaseConfig) DSN

func (d DatabaseConfig) DSN() string

DSN returns the DSN

func (DatabaseConfig) Type

func (d DatabaseConfig) Type() string

Type returns the DB backend type

type Duration

type Duration string

func (Duration) Duration

func (d Duration) Duration() (time.Duration, error)

type ServiceConfig

type ServiceConfig struct {
	Address        string
	ReadTimeout    Duration
	WriteTimeout   Duration
	MaxHeaderBytes int
}

ServiceConfig represents a configuration for an HTTP server for a service

Jump to

Keyboard shortcuts

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