engine

package
v0.0.0-...-e16d50f Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2015 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DevelopmentMode = 0

DevelopmentMode represents a config en set to DevelopementMode

View Source
const ProductionMode = 1

ProductionMode repesents a config env set to production

Variables

View Source
var DefaultConfig = Config{
	Addr:      ":8080",
	Env:       "dev",
	Static:    StaticConfig{Dir: "./static", StripPrefix: "static"},
	Heartbeat: "5m",
	Killbeat:  "2m",
	TemplatesConfig: assets.TemplateConfig{
		Dir:       "./templates",
		Extension: ".tmpl",
	},
}

DefaultConfig provides a default configuration for the app

Functions

func ConvertToInt

func ConvertToInt(target string, def int) int

ConvertToInt wraps the internal int coverter

Types

type Config

type Config struct {
	Name      string `yaml:"name"`
	APIToken  string `yaml:"api_token"`
	Addr      string `yaml:"addr"`
	Mode      int    `yaml:"-"`
	Env       string `yaml:"env"`
	Heartbeat string `yaml:"heartbeat"`
	//the timeout for graceful shutdown of server
	Killbeat        string                `yaml:"killbeat"`
	C               TLSConfig             `yaml:"tls"`
	Static          StaticConfig          `yaml:"static"`
	Db              Db                    `yaml:"db"`
	TemplatesConfig assets.TemplateConfig `yaml:"templates"`
}

Config provides configuration for Afro

func NewConfig

func NewConfig() *Config

NewConfig returns a new configuration file

func (*Config) Load

func (c *Config) Load(file string) error

Load loads the configuration from a yaml file

type Db

type Db struct {
	Type string `yaml:"type"` //can be 'sql','mgo
	Name string `yaml:"name"`
	Addr string `yaml:"addr"`
	User string `yaml:"user"`
	Pass string `yaml:"pass"`
}

Db provides a generic db configuration value

type Engine

type Engine struct {
	*relay.ChainRouter
	*Config

	Template *assets.TemplateDir
	//HeartBeats is run a constant rate every ms provided
	HeartBeats func(*Engine)
	//BeforeInit is run right before the server is started
	BeforeInit func(*Engine)
	//AfterInit is run right after the server is started
	AfterInit func(*Engine)
	//OnInit is runned immediate the server gets started
	OnInit  func(*Engine)
	OnClose func(*Engine)
	// contains filtered or unexported fields
}

Engine provides a base luncher for a service

func NewEngine

func NewEngine(c *Config, init func(*Engine)) *Engine

NewEngine returns a new app configuration

func (*Engine) Close

func (a *Engine) Close() error

Close closes and returns an error of the internal listener

func (*Engine) EngineAddr

func (a *Engine) EngineAddr() net.Addr

EngineAddr returns the address of the app

func (*Engine) Serve

func (a *Engine) Serve()

Serve serves the app and configuration and loads the routes and serivices settings

type StaticConfig

type StaticConfig struct {
	Dir         string `yaml:"dir"`
	StripPrefix string `yaml:"strip_prefix"`
}

StaticConfig provides the configuration details for the static files location and arguments

type TLSConfig

type TLSConfig struct {
	Certs *tls.Config
	Key   string `yaml:"key"`
	Cert  string `yaml:"cert"`
}

TLSConfig provides a base config for tls configuration

func (*TLSConfig) UnmarshalYAML

func (t *TLSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshalls the incoming data for use

Jump to

Keyboard shortcuts

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