ginflux

package module
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

README

ginflux

a influxdb orm

Documentation

Index

Constants

View Source
const (
	TAG       = "tag"
	Field     = "field"
	FieldName = "name"
	TAGTime   = "time"
	FieldJSON = "json"
)

Keywords

View Source
const (
	//TimeZone ...
	TimeZone = "Asia/Shanghai"
	//Custom ...
	Custom = "2006-01-02 15:04:05"
)
View Source
const TAGKey = "influx"

TAGKey ...

View Source
const Version = "v0.0.1"

Version ...

Variables

View Source
var (
	//ErrMaxOpen ...
	ErrMaxOpen = errors.New("连接数超出最大限制")
	ErrTimeout = errors.New("从池中获取连接超时")
)
View Source
var (
	DefOpts = Options{
		HttpConf: ic.HTTPConfig{
			Addr:               "http://127.0.0.1:8086",
			Username:           "",
			Password:           "",
			UserAgent:          "",
			Timeout:            time.Second * 3,
			InsecureSkipVerify: false,
			TLSConfig:          nil,
			Proxy:              nil,
		},
		MinOpen: 2,
		MaxOpen: 100,
	}
)
View Source
var (
	//ErrEmpty ...
	ErrEmpty = errors.New("empty")
)
View Source
var LintGonicMapper = GonicMapper{
	"API":   true,
	"ASCII": true,
	"CPU":   true,
	"CSS":   true,
	"DNS":   true,
	"EOF":   true,
	"GUID":  true,
	"HTML":  true,
	"HTTP":  true,
	"HTTPS": true,
	"ID":    true,
	"IP":    true,
	"JSON":  true,
	"LHS":   true,
	"QPS":   true,
	"RAM":   true,
	"RHS":   true,
	"RPC":   true,
	"SLA":   true,
	"SMTP":  true,
	"SSH":   true,
	"TLS":   true,
	"TTL":   true,
	"UI":    true,
	"UID":   true,
	"UUID":  true,
	"URI":   true,
	"URL":   true,
	"UTF8":  true,
	"VM":    true,
	"XML":   true,
	"XSRF":  true,
	"XSS":   true,
}

LintGonicMapper that contains a list of common initialisms taken from golang/lint

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString convert []byte type to string type.

func CamelString

func CamelString(s string) string

CamelString converts the accepted string to a camel string (xx_yy to XxYy)

func IsSliceContainsStr

func IsSliceContainsStr(sl []string, str string) bool

IsSliceContainsStr returns true if the string exists in given slice, ignore case.

func ObjectName

func ObjectName(obj interface{}) string

ObjectName gets the type name of the object

func SetTimeZone added in v1.2.0

func SetTimeZone()

SetTimeZone ...

func SnakeString

func SnakeString(s string) string

SnakeString converts the accepted string to a snake string (XxYy to xx_yy)

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes convert string type to []byte type. NOTE: panic if modify the member value of the []byte.

func ToStr

func ToStr(value interface{}, args ...int) (s string)

ToStr Convert any type to string.

Types

type CacheMapper

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

CacheMapper ...

func NewCacheMapper

func NewCacheMapper(mapper IMapper) *CacheMapper

NewCacheMapper ...

func (*CacheMapper) Obj2Table

func (m *CacheMapper) Obj2Table(o string) string

Obj2Table ...

func (*CacheMapper) Table2Obj

func (m *CacheMapper) Table2Obj(t string) string

Table2Obj ...

type Conversion

type Conversion interface {
	FromDB(data []byte) error
	ToDB() (b []byte, err error)
}

Conversion ...

type Database

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

Database ...

func (*Database) Insert

func (d *Database) Insert(bean interface{}) error

Insert ...

func (*Database) Query

func (d *Database) Query(str string, bean ...interface{}) (s *Search, err error)

Query 查询时包裹时区

func (*Database) QueryRaw added in v1.6.2

func (d *Database) QueryRaw(str string, bean ...interface{}) (s *Search, err error)

QueryRaw 执行原始查询语句

func (*Database) SetBatchPointConf

func (d *Database) SetBatchPointConf(batchPointConf ic.BatchPointsConfig) *Database

SetBatchPointConf ...

func (*Database) SetBpsFunc

func (d *Database) SetBpsFunc(bpsFunc bpsActionFunc) *Database

SetBpsFunc ...

func (*Database) SetName

func (d *Database) SetName(name string) *Database

SetName ...

type Engine

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

Engine ...

func NewEngine

func NewEngine(opts Options) (eg *Engine, err error)

NewEngine ...

func (*Engine) Acquire

func (e *Engine) Acquire() (cl *OClient, err error)

Acquire ...

func (*Engine) DB

func (e *Engine) DB(name string) *Database

DB ...

func (*Engine) NewDB

func (e *Engine) NewDB(name string) (dbInstance *Database, err error)

NewDB ...

func (*Engine) NewSession

func (e *Engine) NewSession() (session *Session, err error)

NewSession ...

func (*Engine) Session

func (e *Engine) Session() *Session

Session ...

func (*Engine) SyncDB

func (e *Engine) SyncDB(beans ...RetentionPolicy) (err error)

SyncDB ...

type GonicMapper

type GonicMapper map[string]bool

GonicMapper implements IMapper. It will consider initialisms when mapping names. E.g. id -> ID, user -> User and to table names: UserID -> user_id, MyUID -> my_uid

func (GonicMapper) Obj2Table

func (mapper GonicMapper) Obj2Table(name string) string

Obj2Table ...

func (GonicMapper) Table2Obj

func (mapper GonicMapper) Table2Obj(name string) string

Table2Obj ...

type IMapper

type IMapper interface {
	Obj2Table(string) string
	Table2Obj(string) string
}

IMapper name translation between struct, fields names and table, column names

type InterfaceTable

type InterfaceTable interface {
	Measurement() string
}

InterfaceTable ...

type InterfaceTime

type InterfaceTime interface {
	Time() time.Time
}

InterfaceTime ...

type JSONTime

type JSONTime time.Time

JSONTime ...

func Must2JSONTimeAddr added in v0.0.5

func Must2JSONTimeAddr(in string) *JSONTime

Must2JSONTimeAddr maybe panic

func ToDatetime

func ToDatetime(in string) (JSONTime, error)

ToDatetime ...

func (JSONTime) Addr added in v0.0.5

func (p JSONTime) Addr() *JSONTime

Addr ...

func (*JSONTime) Convert2Time

func (p *JSONTime) Convert2Time() time.Time

Convert2Time ...

func (*JSONTime) FromDB

func (p *JSONTime) FromDB(data []byte) error

FromDB ...

func (*JSONTime) GobDecode

func (p *JSONTime) GobDecode(data []byte) error

GobDecode implements the gob.GobDecoder interface.

func (JSONTime) GobEncode

func (p JSONTime) GobEncode() ([]byte, error)

GobEncode implements the gob.GobEncoder interface.

func (JSONTime) MarshalJSON

func (p JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*JSONTime) Scan

func (p *JSONTime) Scan(v interface{}) error

Scan valueof time.Time

func (*JSONTime) SetByTime

func (p *JSONTime) SetByTime(timeVal time.Time)

SetByTime ...

func (JSONTime) String

func (p JSONTime) String() string

String ...

func (*JSONTime) Time

func (p *JSONTime) Time() time.Time

Time ...

func (*JSONTime) ToDB

func (p *JSONTime) ToDB() (b []byte, err error)

ToDB ...

func (*JSONTime) UnmarshalJSON

func (p *JSONTime) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

func (JSONTime) Value

func (p JSONTime) Value() (driver.Value, error)

Value insert timestamp into mysql need this function.

type Map

type Map map[string]interface{}

Map ...

type MapString

type MapString map[string]string

MapString ...

type OClient

type OClient struct {
	ic.Client
	// contains filtered or unexported fields
}

OClient ...

func (*OClient) GetInfluxClient

func (o *OClient) GetInfluxClient() ic.Client

GetInfluxClient ...

func (*OClient) Release

func (o *OClient) Release()

Release ...

type OPool

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

OPool ...

func NewOPool

func NewOPool(opt Options) *OPool

NewOPool ...

func (*OPool) Acquire

func (o *OPool) Acquire() (cl *OClient, err error)

Acquire ...

func (*OPool) CurrentOpen

func (o *OPool) CurrentOpen() int64

CurrentOpen ...

func (*OPool) Increment

func (o *OPool) Increment(n int64)

Increment ...

type Options

type Options struct {
	HttpConf ic.HTTPConfig
	//从池中取资源的超时时间
	GetTimeout time.Duration
	MinOpen    int
	MaxOpen    int
}

Options ...

type PrefixMapper

type PrefixMapper struct {
	Mapper IMapper
	Prefix string
}

PrefixMapper provide prefix table name support

func NewPrefixMapper

func NewPrefixMapper(mapper IMapper, prefix string) PrefixMapper

NewPrefixMapper ...

func (PrefixMapper) Obj2Table

func (mapper PrefixMapper) Obj2Table(name string) string

Obj2Table ...

func (PrefixMapper) Table2Obj

func (mapper PrefixMapper) Table2Obj(name string) string

Table2Obj ...

type RetentionPolicy

type RetentionPolicy struct {
	DBName        string
	RPName        string
	Duration      string
	Replication   int
	ShardDuration string
	Default       bool
}

RetentionPolicy ...

type SameMapper

type SameMapper struct {
}

SameMapper implements IMapper and provides same name between struct and database table

func (SameMapper) Obj2Table

func (m SameMapper) Obj2Table(o string) string

Obj2Table ...

func (SameMapper) Table2Obj

func (m SameMapper) Table2Obj(t string) string

Table2Obj ...

type Search struct {
	Database *Database

	Result *ic.Response
	Err    error
	// contains filtered or unexported fields
}

Search ...

type Session

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

Session ...

func (*Session) Client

func (s *Session) Client() *OClient

Client ...

func (*Session) CreateDB

func (s *Session) CreateDB(name string) error

CreateDB ...

func (*Session) CreateRetentionPolicy

func (s *Session) CreateRetentionPolicy(rp RetentionPolicy) error

CreateRetentionPolicy ...

func (*Session) NewDB

func (s *Session) NewDB(name string) (dbInstance *Database)

NewDB ...

func (*Session) Release

func (s *Session) Release()

Release ...

func (*Session) SetClient

func (s *Session) SetClient(client *OClient) *Session

SetClient ...

type SnakeMapper

type SnakeMapper struct {
}

SnakeMapper implements IMapper and provides name transaltion between struct and database table

func (SnakeMapper) Obj2Table

func (mapper SnakeMapper) Obj2Table(name string) string

Obj2Table ...

func (SnakeMapper) Table2Obj

func (mapper SnakeMapper) Table2Obj(name string) string

Table2Obj ...

type StringVal

type StringVal string

StringVal ...

func (StringVal) Bind

func (s StringVal) Bind(fieldValue *reflect.Value) (err error)

Bind ...

func (StringVal) MapInterfaceToStruct

func (s StringVal) MapInterfaceToStruct(dstVal *reflect.Value) (err error)

Deprecated MapInterfaceToStruct ...

type StructBean

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

StructBean ...

func NewStructBean

func NewStructBean(bean interface{}) *StructBean

NewStructBean ...

func (*StructBean) Point

func (s *StructBean) Point() models.Point

Point ...

type SuffixMapper

type SuffixMapper struct {
	Mapper IMapper
	Suffix string
}

SuffixMapper provide suffix table name support

func NewSuffixMapper

func NewSuffixMapper(mapper IMapper, suffix string) SuffixMapper

NewSuffixMapper ...

func (SuffixMapper) Obj2Table

func (mapper SuffixMapper) Obj2Table(name string) string

Obj2Table ...

func (SuffixMapper) Table2Obj

func (mapper SuffixMapper) Table2Obj(name string) string

Table2Obj ...

Jump to

Keyboard shortcuts

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