logcore

package
v0.0.0-...-9cffafa Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt32

func AbsInt32(n int32) int32

AbsInt32 returns an sbsolute value of an int32

func AbsInt64

func AbsInt64(n int64) int64

AbsInt64 returns an absolute value of an int64

func BToMB

func BToMB(b uint64) uint64

BToMB divides the given number by (1024*1024)

func ComparePasswordHash

func ComparePasswordHash(hash, p string) bool

ComparePasswordHash compares the password hash generated by HashPassword() with the given plaintext password string.

func HashPassword

func HashPassword(p string) string

HashPassword hashes a plaintext string password into a format which can be inserted into the database.

func HaversineDistance

func HaversineDistance(lat1, lng1, lat2, lng2 float64) float64

HaversineDistance returns the distance in km between two coordinate pairs. See https://en.wikipedia.org/wiki/Haversine_formula .

func InInt32Array

func InInt32Array(x int32, a []int32) bool

InInt32Array checks to see if an int32 is in a []int32.

func InInt32ArraySorted

func InInt32ArraySorted(x int32, a []int32) bool

func InInt64Array

func InInt64Array(x int64, a []int64) bool

InInt64Array checks to see if an int64 is in a []int64.

func InIntArray

func InIntArray(x int, a []int) bool

IsIntArray checks to see if an int is in a []int.

func InStringArray

func InStringArray(s string, a []string) bool

InStringArray checks to see if a string is in a []string

func InStringArraySorted

func InStringArraySorted(s string, a []string) bool

InStringArraySorted checks to see if a string is in a sorted []string

func InitRandom

func InitRandom()

Seeds the math.Rand() generator.

func InsertSortedString

func InsertSortedString(s string, a []string) (a2 []string)

func IntArrayToString

func IntArrayToString(x []int, delim string, open string, end string) string

IntArrayToString takes an []int and returns a string which consists of the integers converted to strings, delimited with delim, and prepended and appended with the specified open and end strings.

func SplitStringWords

func SplitStringWords(s string, maxLen int) (result []string)

func WriteCeruleanConfig

func WriteCeruleanConfig(fileName string, cfg CeruleanConfig) (err error)

Types

type BasicGelfMessage

type BasicGelfMessage struct {
	Version           string             `json:"version"`
	Host              string             `json:"host"`
	Facility          string             `json:"facility"`
	ShortMessage      string             `json:"short_message"`
	FullMessage       string             `json:"full_message"`
	Timestamp         uint32             `json:"timestamp"`
	AdditionalStrings map[string]string  `json:"-"`
	AdditionalNumbers map[string]float64 `json:"-"`
}

func ParseGelfMessage

func ParseGelfMessage(data []byte) (msg BasicGelfMessage, err error)

type CeruleanConfig

type CeruleanConfig struct {
	SQLiteJournalMode       string            `json:"sqlite_journal_mode"`
	ShardTimeSpecString     string            `json:"shard_time_spec"`
	ShardTimeSpec           ShardTimeSpecType `json:"-"`
	MemoryBufferTimeSeconds uint32            `json:"memory_buffer_time_seconds"`
	IndexFieldList          []string          `json:"index_field_list"`
}

func NewCeruleanConfig

func NewCeruleanConfig() (cfg CeruleanConfig)

func ReadCeruleanConfig

func ReadCeruleanConfig(fileName string) (cfg CeruleanConfig, err error)

func (CeruleanConfig) GetShardNameID

func (c CeruleanConfig) GetShardNameID(ts uint32) (name string, id uint32)

GetShardName returns a name and a unique ID (the name and the ID are locally unique and date-based) for a shard which contains data for the given timestamp.

func (CeruleanConfig) GetShardNameIDsTimeSpan

func (c CeruleanConfig) GetShardNameIDsTimeSpan(timeFrom, timeTo uint32) (list []spanNameID)

func (CeruleanConfig) ShardNameToTsID

func (c CeruleanConfig) ShardNameToTsID(name string) (ts, id uint32, err error)

type CeruleanInstance

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

func NewCeruleanInstance

func NewCeruleanInstance(dataDir string) *CeruleanInstance

func (*CeruleanInstance) AddMessage

func (ci *CeruleanInstance) AddMessage(msg BasicGelfMessage) (err error)

func (*CeruleanInstance) Committer

func (ci *CeruleanInstance) Committer()

func (*CeruleanInstance) Query

func (ci *CeruleanInstance) Query(timeFrom, timeTo, limit uint32, query string) (result DbShardQueryResult, err error)

type DbShard

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

type DbShardCollection

type DbShardCollection struct {
	WithRWMutex
	// contains filtered or unexported fields
}

func NewDbShardCollection

func NewDbShardCollection(i *CeruleanInstance) (sc DbShardCollection, err error)

func (*DbShardCollection) CommitMessageToShard

func (sc *DbShardCollection) CommitMessageToShard(tx *sql.Tx, msg *BasicGelfMessage) (err error)

func (*DbShardCollection) CommitMessagesToShards

func (sc *DbShardCollection) CommitMessagesToShards(messages *[]BasicGelfMessage) (err error)

func (DbShardCollection) EarlieastShard

func (sc DbShardCollection) EarlieastShard() (name string, ts, id uint32, err error)

func (*DbShardCollection) GetShard

func (sc *DbShardCollection) GetShard(ts uint32) (shard *DbShard, err error)

func (*DbShardCollection) Query

func (sc *DbShardCollection) Query(timeFrom, timeTo, limit uint32, query string) (result DbShardQueryResult, err error)

type DbShardQueryResult

type DbShardQueryResult []map[string]interface{}

type MsgBuffer

type MsgBuffer struct {
	WithMutex
	Messages     []BasicGelfMessage
	LastSwapTime time.Time
	// contains filtered or unexported fields
}

func NewMsgBuffer

func NewMsgBuffer(i *CeruleanInstance) (mb MsgBuffer)

type ShardTimeSpecType

type ShardTimeSpecType uint32
const (
	ShardTimeSpecYear ShardTimeSpecType = iota
	ShardTimeSpecMonth
	ShardTimeSpecWeek
	ShardTimeSpecDay
)

type SortedStringSlice

type SortedStringSlice sort.StringSlice

func (*SortedStringSlice) Insert

func (ss *SortedStringSlice) Insert(s string)

func (*SortedStringSlice) Sort

func (ss *SortedStringSlice) Sort()

type WithMutex

type WithMutex struct {
	sync.Mutex
}

WithMutex extends the Mutex type with the convenient .With(func) function

func (*WithMutex) WithLock

func (m *WithMutex) WithLock(f func())

WithLock executes the given function with the mutex locked

type WithRWMutex

type WithRWMutex struct {
	sync.RWMutex
}

WithRWMutex extends the RWMutex type with convenient .With(func) functions

func (*WithRWMutex) WithRLock

func (m *WithRWMutex) WithRLock(f func())

WithRLock executes the given function with the mutex rlocked

func (*WithRWMutex) WithWLock

func (m *WithRWMutex) WithWLock(f func())

WithWLock executes the given function with the mutex wlocked

Jump to

Keyboard shortcuts

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