context

package
v0.0.0-...-3d42942 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: Apache-2.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cors

func Cors() gin.HandlerFunc

//// 跨域

func GetCurrentDirectory

func GetCurrentDirectory(dir string) (string, error)

func LoadCfg

func LoadCfg(dir string, inter interface{})

func LoadEnvCfg

func LoadEnvCfg(dir, env string, inter interface{})

func LoadEnvFileName

func LoadEnvFileName(dir, env string) string

func LoadFileName

func LoadFileName(dir string) string

Types

type BasePlugin

type BasePlugin struct {
	MysqlDb      map[string]*gorm.DB
	PostDb       map[string]*gorm.DB
	RedisDb      map[string]*redis.Client
	MgoDb        map[string]*mgo.Database
	RestTemplate map[string]*rest.RestTemplate
}

func NewBasePlugin

func NewBasePlugin() *BasePlugin

func (*BasePlugin) Close

func (d *BasePlugin) Close()

func (*BasePlugin) DefaultMgo

func (d *BasePlugin) DefaultMgo() *mgo.Database

func (*BasePlugin) DefaultMysql

func (d *BasePlugin) DefaultMysql() *gorm.DB

func (*BasePlugin) DefaultPost

func (d *BasePlugin) DefaultPost() *gorm.DB

func (*BasePlugin) DefaultRedis

func (d *BasePlugin) DefaultRedis() *redis.Client

func (BasePlugin) DefaultRest

func (d BasePlugin) DefaultRest() *rest.RestTemplate

func (*BasePlugin) Health

func (d *BasePlugin) Health() error

func (*BasePlugin) InterfaceName

func (d *BasePlugin) InterfaceName() string

func (*BasePlugin) Mgo

func (d *BasePlugin) Mgo(name string) *mgo.Database

func (*BasePlugin) Mysql

func (d *BasePlugin) Mysql(name string) *gorm.DB

func (*BasePlugin) Open

func (d *BasePlugin) Open(injector *inject.Injector) error

func (*BasePlugin) Post

func (d *BasePlugin) Post(name string) *gorm.DB

func (*BasePlugin) Redis

func (d *BasePlugin) Redis(name string) *redis.Client

func (*BasePlugin) Rest

func (d *BasePlugin) Rest(name string) *rest.RestTemplate

type Boot

type Boot struct {
	Cron *cron.Cron
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance() *Boot

func (*Boot) AddApply

func (b *Boot) AddApply(pointers ...interface{}) *Boot

func (*Boot) AddApplyCfg

func (b *Boot) AddApplyCfg(pointers ...interface{}) *Boot

func (*Boot) AddAsyncFun

func (b *Boot) AddAsyncFun(fun func(injector *inject.Injector)) *Boot

func (*Boot) AddFun

func (b *Boot) AddFun(fun func(injector *inject.Injector)) *Boot

func (*Boot) AddPlugins

func (b *Boot) AddPlugins(plugins ...Plugin)

func (*Boot) AddTask

func (b *Boot) AddTask(name, cron string, fun func()) *Boot

func (*Boot) BindHttp

func (b *Boot) BindHttp(r ...func(router *gin.RouterGroup, injector *inject.Injector))

func (*Boot) Close

func (b *Boot) Close()

func (*Boot) GetInject

func (b *Boot) GetInject() *inject.Injector

func (*Boot) Start

func (b *Boot) Start(dir, env string) *Boot

func (*Boot) StartAndDir

func (b *Boot) StartAndDir(dir string) *Boot

type Cmd

type Cmd struct {
	Params map[string]*string
	Cmd    map[string]func()
}

func (*Cmd) Http

func (c *Cmd) Http(b *Boot)

func (*Cmd) PutCmd

func (c *Cmd) PutCmd(name string, fun func())

func (*Cmd) PutFlagString

func (c *Cmd) PutFlagString(name string, value string, usage string)

func (*Cmd) Start

func (c *Cmd) Start(b *Boot, dir, env string)

type Config

type Config struct {
	Jewel struct {
		Log              string `json:"log" yaml:"log"`
		Max_Open_Conns   int    `json:"max-open-conns" yaml:"max-open-conns"`
		Max_Idle_Conns   int    `json:"max-idle-conns" yaml:"max-idle-conns" xml:"max-idle-conns"`
		SqlShow          bool   `json:"sql_show" yaml:"sql_show" xml:"sql_show"`
		Mysql            string `json:"mysql" yaml:"mysql" xml:"mysql"`
		Mgo              string `json:"mgo" yaml:"mgo" xml:"mgo"`
		MgoDb            string `json:"mgo_db" yaml:"mgo_db" xml:"mgo_db"`
		Name             string `json:"name" yaml:"name" xml:"name"`
		Port             int    `json:"port" yaml:"port" xml:"port"`
		Postgres         string `json:"postgres" yaml:"postgres" xml:"postgres"`
		Amqp             string `json:"amqp" yaml:"amqp" xml:"amqp"`
		Amqp_Max_Channel int    `json:"amqp_max_channel" yaml:"amqp_max_channel" xml:"amqp_max_channel"`
		Amqp_Vhost       string `json:"amqp_vhost" yaml:"amqp_vhost" xml:"amqp_vhost"`
		Profiles         struct {
			Active string `json:"active"`
		} `json:"profiles" yaml:"profiles" xml:"profiles"`
		Redis struct {
			Db       int    `json:"db"`
			Host     string `json:"host"`
			Password string `json:"password"`
		} `json:"redis" yaml:"redis" xml:"redis"`
		JsonRpc struct {
			Enabled  *bool  `json:"enabled"`
			UserName string `json:"username"`
			Password string `json:"password"`
		} `json:"jsonrpc" yaml:"jsonrpc" xml:"jsonrpc"`
		Sqlite3 string `json:"sqlite3" yaml:"sqlite3" xml:"sqlite3"`
	} `json:"jewel" yaml:"jewel" xml:"jewel"`
}

func (*Config) Load

func (config *Config) Load(fileName string)

type ConfigStruct

type ConfigStruct struct {
}

func (*ConfigStruct) Load

func (config *ConfigStruct) Load(fileName string, inter interface{})

type Cron

type Cron struct {
	Name string
	Cron string
	Fun  func()
}

type IService

type IService interface {
	Load(fun func(c Config))
}

type Info

type Info struct {
	Port     int    `json:"port"`
	Name     string `json:"name"`
	Env      string `json:"env"`
	BootTime string `json:"boot_time"`
}

type Jewel

type Jewel struct {
	Name     string                     `json:"name" yaml:"name" xml:"name"`
	Log      Log                        `json:"log" yaml:"log" xml:"log"`
	Server   ServerProperties           `json:"server" yaml:"server" xml:"server"`
	Profiles Profiles                   `json:"profiles" yaml:"profiles" xml:"profiles"`
	MySql    map[string]SqlDataSource   `json:"mysql" yaml:"mysql" xml:"mysql"`
	Postgres map[string]SqlDataSource   `json:"postgres" yaml:"postgres" xml:"postgres"`
	Redis    map[string]RedisDataSource `json:"redis" yaml:"redis" xml:"redis"`
	Mgo      map[string]MgoDataSource   `json:"mgo" yaml:"mgo" xml:"mgo"`
	Rest     map[string]RestProperties  `json:"rest" yaml:"rest" xml:"rest"`
}

type JewelProperties

type JewelProperties struct {
	Jewel Jewel `json:"jewel" yaml:"jewel" xml:"jewel"`
}

type Log

type Log struct {
	Level string `json:"level" yaml:"level" xml:"level"`
}

type Manager

type Manager struct {
	User     *string `json:"user" yaml:"user" xml:"user"`
	Password *string `json:"password" yaml:"password" xml:"password"`
	Enabled  *bool   `json:"enabled" yaml:"enabled" xml:"enabled"`
}

type MgoDataSource

type MgoDataSource struct {
	Address        *string `json:"address" yaml:"address" xml:"address"`
	Database       *string `json:"database" yaml:"database" xml:"database"`
	Direct         *bool   `json:"direct" yaml:"direct" xml:"direct"`
	FailFast       *bool   `json:"fail_fast" yaml:"fail_fast" xml:"fail_fast"`
	Password       *string `json:"password" yaml:"password" xml:"password"`
	PoolLimit      *int    `json:"pool_limit" yaml:"pool_limit" xml:"pool_limit"`
	ReplicaSetName *string `json:"replica_set_name" yaml:"replica_set_name" xml:"replica_set_name"`
	Service        *string `json:"service" yaml:"service" xml:"service"`
	ServiceHost    *string `json:"service_host" yaml:"service_host" xml:"service_host"`
	Source         *string `json:"source" yaml:"source" xml:"source"`
	Timeout        *int    `json:"timeout" yaml:"timeout" xml:"timeout"`
	UserName       *string `json:"user_name" yaml:"user_name" xml:"user_name"`
	Enabled        *bool   `json:"enabled" yaml:"enabled" xml:"enabled"`
}

func (*MgoDataSource) Create

func (ds *MgoDataSource) Create() (*mgo.Database, error)

type Plugin

type Plugin interface {
	Open(injector *inject.Injector) error
	Health() error
	Close()
	InterfaceName() string
}

type Profiles

type Profiles struct {
	Active string `yaml:"active" xml:"active" json:"active"`
}

type Properties

type Properties struct {
	// contains filtered or unexported fields
}

func NewProperties

func NewProperties() *Properties

func (*Properties) Load

func (prop *Properties) Load(fileName string, inter interface{})

type RedisDataSource

type RedisDataSource struct {
	Addr               *string `json:"addr" yaml:"addr" xml:"addr"`
	Db                 *int    `json:"db" yaml:"db" xml:"db"`
	DialTimeout        *int    `json:"dial_timeout" yaml:"dial_timeout" xml:"dial_timeout"`
	IdleCheckFrequency *int    `json:"idle_check_frequency" yaml:"idle_check_frequency" xml:"idle_check_frequency"`
	IdleTimeout        *int    `json:"idle_timeout" yaml:"idle_timeout" xml:"idle_timeout"`
	MaxRetries         *int    `json:"max_retries" yaml:"max_retries" xml:"max_retries"`
	MaxRetryBackOff    *int    `json:"max_retry_back_off" yaml:"max_retry_back_off" xml:"max_retry_back_off"`
	MinRetryBackOff    *int    `json:"min_retry_back_off" yaml:"min_retry_back_off" xml:"min_retry_back_off"`
	Network            *string `json:"network" yaml:"network" xml:"network"`
	Password           *string `json:"password" yaml:"password" xml:"password"`
	PoolSize           *int    `json:"pool_size" yaml:"pool_size" xml:"pool_size"`
	PoolTimeout        *int    `json:"pool_timeout" yaml:"pool_timeout" xml:"pool_timeout"`
	ReadTimeout        *int    `json:"read_timeout" yaml:"read_timeout" xml:"read_timeout"`
	TLS                *bool   `json:"tls" yaml:"tls" xml:"tls"`
	WriteTimeout       *int    `json:"write_timeout" yaml:"write_timeout" xml:"write_timeout"`
	Enabled            *bool   `json:"enabled" yaml:"enabled" xml:"enabled"`
}

func (*RedisDataSource) Create

func (ds *RedisDataSource) Create() (*redis.Client, error)

type RestProperties

type RestProperties struct {
	Authorization      *string `json:"authorization" yaml:"authorization" xml:"authorization"`
	DisableCompression *bool   `json:"disable_compression" yaml:"disable_compression" xml:"disable_compression"`
	IdleConnTimeout    *int    `json:"idle_conn_timeout" yaml:"idle_conn_timeout" xml:"idle_conn_timeout"`
	MaxIdleConns       *int    `json:"max_idle_conns" yaml:"max_idle_conns" xml:"max_idle_conns"`
	ReplyCount         *int    `json:"reply_count" yaml:"reply_count" xml:"reply_count"`
	SocketTimeout      *int    `json:"socket_timeout" yaml:"socket_timeout" xml:"socket_timeout"`
	Enabled            *bool   `json:"enabled" yaml:"enabled" xml:"enabled"`
}

func (*RestProperties) Create

func (restOptions *RestProperties) Create() (*rest.RestTemplate, error)

type ServerProperties

type ServerProperties struct {
	GinMode     *string `json:"gin_mode" yaml:"gin_mode" xml:"gin_mode"`
	EnablePprof *bool   `json:"enable_pprof" yaml:"enable_pprof" xml:"enable_pprof"`
	ContextPath *string `json:"context_path" yaml:"context_path" xml:"context_path"`

	Port int64 `json:"port" yaml:"port" xml:"port"`

	Templates *string `json:"templates" yaml:"templates" xml:"templates"`

	EnableTls *bool `json:"enable_tls" yaml:"enable_tls" xml:"enable_tls"`

	X509KeyPairServerPem *string `json:"x509_key_pair_server_pem" yaml:"x509_key_pair_server_pem" xml:"x509_key_pair_server_pem"`

	X509KeyPairServerKey *string `json:"x509_key_pair_server_key" yaml:"x509_key_pair_server_key" xml:"x509_key_pair_server_key"`

	ReadTimeout *int64 `json:"read_timeout" yaml:"read_timeout" xml:"read_timeout"`

	ReadHeaderTimeout *int64 `json:"read_header_timeout" yaml:"read_header_timeout" xml:"read_header_timeout"`

	WriteTimeout *int64 `json:"write_timeout" yaml:"write_timeout" xml:"write_timeout"`

	IdleTimeout *int64 `json:"idle_timeout" yaml:"idle_timeout" xml:"idle_timeout"`

	MaxHeaderBytes *int `json:"max_header_bytes" yaml:"max_header_bytes" xml:"max_header_bytes"`

	Manager Manager `json:"manager" yaml:"manager" xml:"max_header_bytes"`
}

func (*ServerProperties) Create

func (serverProperties *ServerProperties) Create() (*http.Server, error)

type SqlDataSource

type SqlDataSource struct {
	ConnMaxLifeTime *int    `json:"conn_max_life_time" yaml:"conn_max_life_time" xml:"conn_max_life_time"`
	MaxIdleConns    *int    `json:"max_idle_conns" yaml:"max_idle_conns" xml:"max_idle_conns"`
	MaxOpenConns    *int    `json:"max_open_conns" yaml:"max_open_conns" xml:"max_open_conns"`
	SqlShow         *bool   `json:"sql_show" yaml:"show_sql" xml:"show_sql"`
	URL             *string `json:"url" yaml:"url" xml:"url"`
	Enabled         *bool   `json:"enabled" yaml:"enabled" xml:"enabled"`
}

func (*SqlDataSource) Create

func (ds *SqlDataSource) Create(name string) (*gorm.DB, error)

Jump to

Keyboard shortcuts

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