models

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2016 License: MIT Imports: 27 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthTokenExpiredErr = errors.New("auth token expired.")
View Source
var CheckSumInvalidErr = errors.New("invalid checksum.")
View Source
var DB *gorm.DB
View Source
var HashLen = 16
View Source
var HistoryLength = 100
View Source
var IndexClient *Client
View Source
var IndexTypeActivities = "activities"
View Source
var IndexTypeMessages = "messages"
View Source
var InternalTags = []string{"_ip"}
View Source
var KeepAlive = "5m"
View Source
var Salt = "Cc4D5xBlbCBqYTuimuNPGsio7YoMo8d8"
View Source
var ScrollSize = 2000
View Source
var SeriesAggName = "series_agg"
View Source
var SupportedDataTypes = []string{"float", "int", "boolean", "string"}
View Source
var SupportedOperators = []string{"eq", "ne", "lt", "gt", "le", "ge"}
View Source
var SupportedSummaryTypes = []string{"avg", "min", "max", "sum", "last"}
View Source
var ValueAggName = "value_agg"

Functions

func CloseDB

func CloseDB() error

func CloseIndexClient

func CloseIndexClient() error

func DecodeHashId

func DecodeHashId(hash string) int

func FetchCachedChannelIndexStatsById

func FetchCachedChannelIndexStatsById(id int) (*elastic.IndicesStatsResponse, bool)

func GlobalIndexName

func GlobalIndexName(ch *Channel) string

func InitializeDB

func InitializeDB() error

func InitializeIndexClient

func InitializeIndexClient() error

func TimedIndexName

func TimedIndexName(ch *Channel, ts time.Time) string

func TimedIndices

func TimedIndices(ch *Channel, tStart, tEnd time.Time) string

Types

type AuthToken

type AuthToken struct {
	Username    string    `json:"username"`
	TokenString string    `json:"token_string"`
	CreatedAt   time.Time `json:"created_at"`
	ExpiresAt   time.Time `json:"expires_at"`
}

func DecryptAuthToken

func DecryptAuthToken(str string) (*AuthToken, error)

func NewAuthToken

func NewAuthToken(u, p string) (*AuthToken, error)

func (*AuthToken) Encrypt

func (t *AuthToken) Encrypt() (string, error)

type Channel

type Channel struct {
	Id              int         `sql:"type:integer primary key autoincrement" json:"-"`
	Name            string      `sql:"type:varchar(255);unique_index" json:"name"`
	Description     string      `sql:"type:text" json:"description"`
	Tags            StringSlice `sql:"type:text" json:"tags"`
	Fields          StringMap   `sql:"type:text" json:"fields"`
	MessageHandlers StringSlice `sql:"type:text" json:"-"`
	AccessTokens    StringSlice `sql:"type:text" json:"access_tokens"`
}

func FetchCachedChannelById

func FetchCachedChannelById(id int) (*Channel, bool)

func (*Channel) BeforeCreate

func (c *Channel) BeforeCreate() error

func (*Channel) BeforeUpdate

func (c *Channel) BeforeUpdate() error

func (*Channel) Create

func (c *Channel) Create() error

func (*Channel) Delete

func (c *Channel) Delete() error

func (*Channel) DeleteIndices

func (c *Channel) DeleteIndices() error

func (*Channel) FindById

func (c *Channel) FindById(id int) bool

func (*Channel) HashId

func (c *Channel) HashId() (string, error)

func (*Channel) IndexStats

func (c *Channel) IndexStats() (*elastic.IndicesStatsResponse, error)

func (*Channel) Indices

func (c *Channel) Indices() []string

func (*Channel) Update

func (c *Channel) Update() error

type ConnectionHistory

type ConnectionHistory struct {
	Activity       string    `json:"activity"`
	Timestamp      time.Time `json:"timestamp"`
	ConnectionType string    `json:"connection_type"`
	Duration       *int64    `json:"duration,omitempty"`
}

type ConnectionStatus

type ConnectionStatus struct {
	ChannelName  string                 `json:"channel"`
	Status       string                 `json:"status"`
	ConnectedAt  *time.Time             `json:"connected_at,omitempty"`
	LastPingedAt *time.Time             `json:"last_pinged_at,omitempty"`
	Identifier   string                 `json:"identifier"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
	Histories    []*ConnectionHistory   `json:"histories,omitempty"`
}

func FindConnectionStatus

func FindConnectionStatus(ch *Channel, devId string, withHistory bool) *ConnectionStatus

type Dashboard

type Dashboard struct {
	Id          int    `sql:"type:integer" json:"id"`
	Name        string `sql:"type:varchar(255)" json:"name"`
	Description string `sql:"type:text" json:"description"`
	Definition  string `sql:"type:text" json:"definition"`
}

func (*Dashboard) BeforeSave

func (d *Dashboard) BeforeSave() error

func (*Dashboard) Create

func (d *Dashboard) Create() error

func (*Dashboard) Delete

func (d *Dashboard) Delete() error

func (*Dashboard) FindById

func (d *Dashboard) FindById(id int) bool

func (*Dashboard) Update

func (d *Dashboard) Update() error

type Point

type Point struct {
	Id        string
	Timestamp time.Time
	Tags      map[string]string
	Fields    map[string]interface{}
	// contains filtered or unexported fields
}

func NewPoint

func NewPoint(id string, ch *Channel, conn Connection, m *Message) (*Point, error)

func (*Point) IndexType

func (p *Point) IndexType() string

func (*Point) MarshalJSON

func (p *Point) MarshalJSON() ([]byte, error)

extra information about a point is mixed in here

func (*Point) Metadata

func (p *Point) Metadata(meta map[string]string)

type RawQuery

type RawQuery struct {
	Channel   *Channel
	Tags      map[string]string
	TimeStart time.Time
	TimeEnd   time.Time
	Nop       bool
}

func (*RawQuery) Parse

func (q *RawQuery) Parse(params map[string]string) error

func (*RawQuery) QueryES

func (q *RawQuery) QueryES() (interface{}, error)

type SeriesQuery

type SeriesQuery struct {
	Channel      *Channel
	Field        string
	Tags         map[string]string
	SummaryType  string
	TimeStart    time.Time
	TimeEnd      time.Time
	TimeInterval string
}

func (*SeriesQuery) Parse

func (q *SeriesQuery) Parse(params map[string]string) error

func (*SeriesQuery) QueryES

func (q *SeriesQuery) QueryES() (interface{}, error)

type StatsQuery

type StatsQuery struct {
	Channel   *Channel
	TimeStart time.Time
	TimeEnd   time.Time
}

func (*StatsQuery) Parse

func (q *StatsQuery) Parse(params map[string]string) error

func (*StatsQuery) QueryES

func (q *StatsQuery) QueryES() (interface{}, error)

type StringMap

type StringMap map[string]string

func (*StringMap) Scan

func (m *StringMap) Scan(value interface{}) error

func (StringMap) Value

func (m StringMap) Value() (driver.Value, error)

type StringSlice

type StringSlice []string

func (*StringSlice) Scan

func (s *StringSlice) Scan(src interface{}) error

func (StringSlice) Value

func (s StringSlice) Value() (driver.Value, error)

type ValueQuery

type ValueQuery struct {
	Channel     *Channel
	Field       string
	Tags        map[string]string
	SummaryType string
	TimeStart   time.Time
	TimeEnd     time.Time
}

func (*ValueQuery) Parse

func (q *ValueQuery) Parse(params map[string]string) error

func (*ValueQuery) QueryES

func (q *ValueQuery) QueryES() (interface{}, error)

Jump to

Keyboard shortcuts

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