config

package
v0.0.0-...-52f8398 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ENV = cli.StringFlag{
	Name:   "environment, e",
	Value:  "development",
	Usage:  "Specifies the environment to run this server under (test/development/production).",
	EnvVar: "ENV",
}

ENV 运行模式

Functions

func Action

func Action(fn func(*Model, *cli.Context) error) func(*cli.Context)

Action config action

func DbAction

func DbAction(fn func(*gorm.DB, *cli.Context) error) func(*cli.Context)

DbAction database action

func EnvAction

func EnvAction(fn func(string, *cli.Context) error) func(*cli.Context)

EnvAction by env arg

func InvokeAction

func InvokeAction(hd martini.Handler) func(*cli.Context)

InvokeAction ivonke action

func IocAction

func IocAction(fn func(*martini.ClassicMartini, *cli.Context) error) func(*cli.Context)

IocAction ioc action

func RedisAction

func RedisAction(fn func(*redis.Pool, *cli.Context) error) func(*cli.Context)

RedisAction redis action

Types

type Database

type Database struct {
	Type string            `toml:"type"`
	Args map[string]string `toml:"args"`
}

Database model

func (*Database) Console

func (p *Database) Console() (string, []string)

Console execute console command

func (*Database) Execute

func (p *Database) Execute(sql string) (string, []string)

Execute execute sql script

func (*Database) Open

func (p *Database) Open() (*gorm.DB, error)

Open open database connection

type ElasticSearch

type ElasticSearch struct {
	Host  string `toml:"host"`
	Port  int    `toml:"port"`
	Index string `toml:"index"`
}

ElasticSearch model

func (*ElasticSearch) Open

func (p *ElasticSearch) Open() (*elastic.Client, error)

Open open connection

func (*ElasticSearch) URL

func (p *ElasticSearch) URL() string

URL connection url

type HTTP

type HTTP struct {
	Host string `toml:"host"`
	Port int    `toml:"port"`
	Ssl  bool   `toml:"ssl"`
}

HTTP 配置信息

type Model

type Model struct {
	Env           string        `toml:"-"`
	Secrets       string        `toml:"secrets"`
	HTTP          HTTP          `toml:"http"`
	Database      Database      `toml:"database"`
	Redis         Redis         `toml:"redis"`
	ElasticSearch ElasticSearch `toml:"elastic_search"`
	Workers       Workers       `toml:"workers"`
}

Model model

func (*Model) Home

func (p *Model) Home() string

Home home url

func (*Model) IsProduction

func (p *Model) IsProduction() bool

IsProduction is production mode ?

func (*Model) Key

func (p *Model) Key(i, l int) ([]byte, error)

Key get key

type Redis

type Redis struct {
	Host string `toml:"host"`
	Port int    `toml:"port"`
	Db   int    `toml:"db"`
}

Redis 配置信息

func (*Redis) Open

func (p *Redis) Open() *redis.Pool

Open open redis connection

func (*Redis) URL

func (p *Redis) URL() string

URL url

type Workers

type Workers struct {
	ID     string         `toml:"id"`
	Pool   int            `toml:"pool"`
	Queues map[string]int `toml:"queues"`
}

Workers model

Jump to

Keyboard shortcuts

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