Documentation ¶
Index ¶
- func AbsInt32(n int32) int32
- func AbsInt64(n int64) int64
- func BToMB(b uint64) uint64
- func ComparePasswordHash(hash, p string) bool
- func HashPassword(p string) string
- func HaversineDistance(lat1, lng1, lat2, lng2 float64) float64
- func InInt32Array(x int32, a []int32) bool
- func InInt32ArraySorted(x int32, a []int32) bool
- func InInt64Array(x int64, a []int64) bool
- func InIntArray(x int, a []int) bool
- func InStringArray(s string, a []string) bool
- func InStringArraySorted(s string, a []string) bool
- func InitRandom()
- func InsertSortedString(s string, a []string) (a2 []string)
- func IntArrayToString(x []int, delim string, open string, end string) string
- func SplitStringWords(s string, maxLen int) (result []string)
- func WriteCeruleanConfig(fileName string, cfg CeruleanConfig) (err error)
- type BasicGelfMessage
- type CeruleanConfig
- type CeruleanInstance
- type DbShard
- type DbShardCollection
- func (sc *DbShardCollection) CommitMessageToShard(tx *sql.Tx, msg *BasicGelfMessage) (err error)
- func (sc *DbShardCollection) CommitMessagesToShards(messages *[]BasicGelfMessage) (err error)
- func (sc DbShardCollection) EarlieastShard() (name string, ts, id uint32, err error)
- func (sc *DbShardCollection) GetShard(ts uint32) (shard *DbShard, err error)
- func (sc *DbShardCollection) Query(timeFrom, timeTo, limit uint32, query string) (result DbShardQueryResult, err error)
- type DbShardQueryResult
- type MsgBuffer
- type ShardTimeSpecType
- type SortedStringSlice
- type WithMutex
- type WithRWMutex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePasswordHash ¶
ComparePasswordHash compares the password hash generated by HashPassword() with the given plaintext password string.
func HashPassword ¶
HashPassword hashes a plaintext string password into a format which can be inserted into the database.
func HaversineDistance ¶
HaversineDistance returns the distance in km between two coordinate pairs. See https://en.wikipedia.org/wiki/Haversine_formula .
func InInt32Array ¶
InInt32Array checks to see if an int32 is in a []int32.
func InInt32ArraySorted ¶
func InInt64Array ¶
InInt64Array checks to see if an int64 is in a []int64.
func InIntArray ¶
IsIntArray checks to see if an int is in a []int.
func InStringArray ¶
InStringArray checks to see if a string is in a []string
func InStringArraySorted ¶
InStringArraySorted checks to see if a string is in a sorted []string
func InsertSortedString ¶
func IntArrayToString ¶
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 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 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 WithRWMutex ¶
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