types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MemberStatusRejected  = 0
	MemberStatusApproved  = 1
	MemberStatusInvited   = 2
	MemberStatusRequested = 3
)
View Source
const (
	DashboardSystemId = 1
	DashboardDemoId   = 2
)
View Source
const (
	RoleAdmin  = 1
	RoleUser   = 2
	RoleViewer = 3
	RoleDemo   = 4
)
View Source
const (
	ProviderGithub = 1
	ProviderGoogle = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Avg

type Avg struct {
	Sum float64 `db:"avg_sum" json:"avg_sum,omitempty"`
	Num int     `db:"avg_num" json:"avg_num,omitempty"`
}

func (*Avg) Value

func (a *Avg) Value() float64

type Claims

type Claims struct {
	Id                int    `json:"id"`
	Role              int    `json:"role"`
	GihubId           int64  `json:"github_id"`
	Username          string `json:"username"`
	AccessToken       string `json:"access_token,omitempty"`
	AccessTokenCipher string `json:"access_token_cipher"`
	jwt.StandardClaims
}

func (*Claims) DecryptAccessToken

func (p *Claims) DecryptAccessToken() error

func (*Claims) EncryptAccessToken

func (p *Claims) EncryptAccessToken() error

type Count

type Count struct {
	sync.RWMutex
	DashId    int    `db:"dash_id"   json:"dash_id,omitempty"`
	Timestamp int64  `db:"timestamp" json:"timestamp"`
	Hostname  string `db:"hostname"  json:"hostname,omitempty"`
	Logname   string `db:"logname"   json:"logname,omitempty"`
	Keyname   string `db:"keyname"   json:"keyname"`
	Version   string `db:"version"   json:"version,omitempty"`
	Metrics   `json:"metrics"`
}

func (*Count) AsVector

func (c *Count) AsVector() []interface{}

func (*Count) Avg

func (c *Count) Avg(num float64) *Count

func (*Count) Decrypt

func (c *Count) Decrypt(cipherText string, priv string) error

func (*Count) Encrypt

func (c *Count) Encrypt(priv string) (string, error)

func (*Count) Inc

func (c *Count) Inc(num float64) *Count

func (*Count) Max

func (c *Count) Max(num float64) *Count

func (*Count) Min

func (c *Count) Min(num float64) *Count

func (*Count) Per

func (c *Count) Per(taken float64, total float64) *Count

func (*Count) Time

func (c *Count) Time(duration time.Duration) func() time.Duration

type Counts

type Counts []*Count

func (Counts) Format

func (cs Counts) Format() Series

type DashKey

type DashKey struct {
	Id         int    `db:"id"          json:"id"`
	DashId     int    `db:"dash_id"     json:"dash_id"`
	Name       string `db:"name"        json:"name"`
	PublicKey  string `db:"public_key"  json:"public_key"`
	PrivateKey string `db:"private_key" json:"private_key"`
}

type DashKeys

type DashKeys []*DashKey

type DashMember

type DashMember struct {
	Id     int   `db:"id"      json:"id"`
	DashId int   `db:"dash_id" json:"dash_id"`
	UserId int   `db:"user_id" json:"user_id"`
	Status int   `db:"status"  json:"status"`
	User   *User `json:"user"`
}

type DashMembers

type DashMembers []*DashMember

func (DashMembers) ApprovedOnly

func (dm DashMembers) ApprovedOnly() DashMembers

func (DashMembers) ByDashId

func (ds DashMembers) ByDashId() map[int]*DashMember

func (DashMembers) ByUserId

func (ds DashMembers) ByUserId() map[int]*DashMember

func (DashMembers) DashIds

func (dm DashMembers) DashIds() []int

func (DashMembers) HasDash

func (ds DashMembers) HasDash(dashId int) *DashMember

func (DashMembers) HasUser

func (ds DashMembers) HasUser(userId int) *DashMember

type DashStatRow

type DashStatRow struct {
	DashId   int    `db:"dash_id"  json:"dash_id,omitempty"`
	Hostname string `db:"hostname" json:"hostname,omitempty"`
	Logname  string `db:"logname"  json:"logname"`
	Level    string `db:"level"    json:"level,omitempty"`
	Version  string `db:"version"  json:"version,omitempty"`
	Cnt      int    `db:"cnt"      json:"cnt"`
	Updated  int64  `db:"updated"  json:"updated,omitempty"`
}

type DashStatRows

type DashStatRows []*DashStatRow

type Dashboard

type Dashboard struct {
	Id      int         `db:"id"          json:"id"`
	OwnerId int         `db:"owner_id"    json:"owner_id"`
	Name    string      `db:"name"        json:"name"`
	Keys    DashKeys    `json:"keys"`
	Members DashMembers `json:"members"`
	Owner   *User       `json:"owner"`
}

type Dashboards

type Dashboards []*Dashboard

func (Dashboards) ByPrimary

func (ds Dashboards) ByPrimary() map[int]*Dashboard

func (Dashboards) Ids

func (ds Dashboards) Ids() []int

type Filter

type Filter struct {
	DashId    int      `json:"dash_id"`
	Hostname  string   `json:"hostname"`
	Logname   string   `json:"logname"`
	Level     string   `json:"level"`
	Pid       int      `json:"pid"`
	Version   string   `json:"version"`
	Message   string   `json:"message"`
	Timestamp [2]int64 `json:"timestamp"`
	Pattern   string   `json:"pattern"`
	Offset    int64    `json:"offset"`
	Limit     int      `json:"limit"`
	Keyname   string   `json:"keyname"`
}

func (*Filter) Match

func (f *Filter) Match(log *Log) bool

func (*Filter) ToSql

func (f *Filter) ToSql() (string, []interface{}, error)

type Inc

type Inc struct {
	Val float64 `db:"inc,omitempty" json:"inc,omitempty"`
}

func (*Inc) Value

func (i *Inc) Value() float64

type Log

type Log struct {
	DashId    int    `db:"dash_id"   json:"dash_id"`
	Timestamp int64  `db:"timestamp" json:"timestamp,string"`
	Hostname  string `db:"hostname"  json:"hostname"`
	Logname   string `db:"logname"   json:"logname"`
	Level     string `db:"level"     json:"level"`
	Message   string `db:"message"   json:"message"`
	Pid       int    `db:"pid"       json:"pid"`
	Version   string `db:"version"   json:"version,omitempty"`
	Initiator string `db:"initiator" json:"initiator,omitempty"`
}

func (*Log) Decrypt

func (log *Log) Decrypt(cipherText string, priv string) error

func (*Log) Encrypt

func (log *Log) Encrypt(priv string) (string, error)

type LogPackage

type LogPackage struct {
	DashId      int    `json:"dash_id,omitempty"`
	PublicKey   string `json:"public_key"`
	CipherLog   string `json:"cipher_log,omitempty"`
	CipherCount string `json:"cipher_count,omitempty"`
	*Log        `json:"log,omitempty"`
	*Count      `json:"count,omitempty"`
}

func (*LogPackage) DecryptCount

func (lp *LogPackage) DecryptCount(priv string) error

func (*LogPackage) DecryptLog

func (lp *LogPackage) DecryptLog(priv string) error

type Logs

type Logs []*Log

type Max

type Max struct {
	Val float64 `db:"max,omitempty" json:"max,omitempty"`
}

func (*Max) Value

func (m *Max) Value() float64

type Metrics

type Metrics struct {
	*Inc
	*Max
	*Min
	*Avg
	*Per
	*Time
}

func (Metrics) ToMap

func (m Metrics) ToMap() map[string]interface{}

type Min

type Min struct {
	Val float64 `db:"min,omitempty" json:"min,omitempty"`
}

func (*Min) Value

func (m *Min) Value() float64

type Per

type Per struct {
	Taken float64 `db:"per_tkn" json:"per_tkn,omitempty"`
	Total float64 `db:"per_ttl" json:"per_ttl,omitempty"`
}

func (*Per) Value

func (p *Per) Value() float64

type Serie

type Serie struct {
	Hostname string           `json:"hostname"`
	Keyname  string           `json:"keyname"`
	Kind     string           `json:"kind"`
	Data     [][2]interface{} `json:"data"`
}

type Series

type Series []*Serie

type Sock

type Sock struct {
	sync.RWMutex
	SockId          string         `json:"sock_id"`
	Listeners       map[string]int `json:"listeners"`
	Paused          bool           `json:"paused"`
	*User           `json:"user"`
	*Filter         `json:"filter"`
	*Claims         `json:"claims"`
	*websocket.Conn `json:"conn"`
}

func (*Sock) AddListener

func (s *Sock) AddListener(path string)

func (*Sock) RemoveListener

func (s *Sock) RemoveListener(path string)

func (*Sock) SendLog

func (s *Sock) SendLog(lg *Log) error

func (*Sock) SetFilter

func (s *Sock) SetFilter(f *Filter)

func (*Sock) SetPaused

func (s *Sock) SetPaused(state bool)

type SockMap

type SockMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*SockMap) Delete

func (sm *SockMap) Delete(userId int, uid string) bool

func (*SockMap) Get

func (sm *SockMap) Get(userId int, sockId string) *Sock

func (*SockMap) Info

func (sm *SockMap) Info() string

func (*SockMap) PushLog

func (sm *SockMap) PushLog(lg *Log) int

func (*SockMap) Set

func (sm *SockMap) Set(s *Sock)

func (*SockMap) SetFilter

func (sm *SockMap) SetFilter(userId int, sockId string, filter *Filter) bool

func (*SockMap) SetPaused

func (sm *SockMap) SetPaused(userId int, sockId string, state bool) bool

type SockMessage

type SockMessage struct {
	Action  string      `json:"action,omitempty"`
	Path    string      `json:"path"`
	Payload interface{} `json:"payload"`
}

type States

type States struct {
	Data map[string]string
	sync.Mutex
}

func (States) Get

func (s States) Get(state string) (string, bool)

func (States) Insert

func (s States) Insert(v string) string

func (States) Set

func (s States) Set(k string, v string)

type Time

type Time struct {
	Duration int64 `db:"time_dur" json:"time_dur,omitempty"`
}

func (*Time) Value

func (t *Time) Value() int64

type User

type User struct {
	Id        int        `db:"id"         json:"id"`
	GithubId  int64      `db:"github_id"  json:"github_id"`
	Username  string     `db:"username"   json:"username"`
	Role      int        `db:"role"       json:"role"`
	LoginAt   *time.Time `db:"login_at"   json:"login_at"`
	CreatedAt *time.Time `db:"created_at" json:"created_at"`
}

type Users

type Users []*User

Jump to

Keyboard shortcuts

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