boot

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2021 License: MIT Imports: 8 Imported by: 0

README

boot基础框架

1.mysql

1.1 使用group

初始化group

    option := mysql.GroupOption{
		RetryInterval: 60,
		Masters:       []mysql.PoolOption{
			{
				Dsn:`{userName}:{password}@tcp({host}:{port})/{dbName}?timeout=5s&readTimeout=6s`,
				MaxConnLifetime: 600,
				MaxOpenConns: 50,
				MaxIdleConns: 10,
			},
		},
		Slaves:        []mysql.PoolOption{
			{
				Dsn:`{userName}:{password}@tcp({host}:{port})/{dbName}?timeout=5s&readTimeout=6s`,
				MaxConnLifetime: 600,
				MaxOpenConns: 50,
				MaxIdleConns: 10,
			},
		},
	}
	group = mysql.NewGroup(&option)

从yaml配置文件加载group

  • yaml配置文件内容
boot:
    retryInterval: 60
    masters:
      - dsn: root:123456@tcp(127.0.0.1:3306)/test?timeout=5s&readTimeout=6s
        maxConnLifetime: 600
        maxOpenConns: 50
        maxIdleConns: 10

      - dsn: root:123456@tcp(127.0.0.2:3306)/test?timeout=5s&readTimeout=6s
        maxConnLifetime: 600
        maxOpenConns: 50
        maxIdleConns: 10

    slaves:
      - dsn: root:123456@tcp(127.0.0.3:3306)/test?timeout=5s&readTimeout=6s
        maxConnLifetime: 600
        maxOpenConns: 50
        maxIdleConns: 10
  • 初始化group
    type Config struct {
        Boot mysql.GroupOption `yaml:"boot" json:"boot"`
    }

    config = &Config{}
	//加载配置
	boot.Yaml("app.yml", config)
	
	//初始化mysqlGroup
	group = mysql.NewGroup(&config.Boot)

Documentation

Index

Constants

View Source
const (
	Success                     = 1
	DefaultPersonasCacheTimeout = 60
	DefaultPersonasMax          = 512
	DefaultPersonasRedisPrefix  = "boot:pns:"
)
View Source
const (
	Ok = "OK"
)

Variables

View Source
var (
	Decr = -1

	SetValue = struct{}{}

	AcquireArgs = func() []interface{} {
		return argsPool.Get().([]interface{})
	}

	ReleaseArgs = func(args []interface{}) {
		if args == nil {
			return
		}

		args = args[:0]
		argsPool.Put(args)
	}
)

Functions

func Bytes2Int64

func Bytes2Int64(data []byte) (num int64)

func HashOrNumber

func HashOrNumber(key interface{}) (value uint32)

func Json

func Json(filePath string, out interface{})

func Yaml

func Yaml(filePath string, out interface{})

Types

type CanHash

type CanHash interface {
	HashCode() (hashValue uint32)
}

type DoubleNode

type DoubleNode struct {
	Value interface{}
	Left  unsafe.Pointer
	Right unsafe.Pointer
}

func NewDoubleNode

func NewDoubleNode(value interface{}, left unsafe.Pointer, right unsafe.Pointer) (node *DoubleNode)

type Node

type Node struct {
	Value interface{}
}

func NewNode

func NewNode(value interface{}) *Node

type SingleNode

type SingleNode struct {
	Value interface{}
	Right unsafe.Pointer
}

func NewSingleNode

func NewSingleNode(value interface{}, right unsafe.Pointer) (node *SingleNode)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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