storage

package
v0.0.0-...-5cd6fb3 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 14 Imported by: 0

README

Storage component

This component contains different backends for storing CCEvent and CCLog messages. The this in only a short term storage, so all backends have a notion of retention time to delete older entries.

Configuration

{
    "retention_time": "48h",
    "flush_time": "10s",
    "backend" : {
        "type" : "backend-type"
        // backend specific configuration
    }
}

The events are only kept retention_time long, then they get deleted. Every flush_time, all arrived messages are flushed to the storage backend.

Available storage backends

Each backend uses it's own configuration file entries. Check the backend-specific page for more information.

Documentation

Overview

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	EVENT_FIELD_KEY  = `event`
	HOSTNAME_TAG_KEY = `hostname`
	CLUSTER_TAG_KEY  = `cluster`
	TYPE_TAG_KEY     = `type`
	TYPEID_TAG_KEY   = `type-id`
	STYPE_TAG_KEY    = `stype`
	STYPEID_TAG_KEY  = `stype-id`
	LOG_FIELD_KEY    = `log`
)

Variables

View Source
var AvailableStorageBackends map[string]Storage = map[string]Storage{
	"sqlite":   new(sqliteStorage),
	"postgres": new(postgresStorage),
}
View Source
var MetricToSchema map[string]string = map[string]string{
	EVENT_FIELD_KEY:  "field",
	LOG_FIELD_KEY:    "field",
	HOSTNAME_TAG_KEY: "hostname",
	TYPEID_TAG_KEY:   "typeid",
	STYPEID_TAG_KEY:  "stypeid",
	TYPE_TAG_KEY:     "type",
	STYPE_TAG_KEY:    "stype",
	CLUSTER_TAG_KEY:  "",
}

Functions

This section is empty.

Types

type QueryCondition

type QueryCondition struct {
	Pred      string
	Operation string
	Args      []any
}

type QueryRequest

type QueryRequest struct {
	Event      string
	Hostname   string
	Cluster    string
	Conditions []QueryCondition
	From       int64
	To         int64
	QueryType  QueryRequestType
}

type QueryRequestType

type QueryRequestType int
const (
	QueryTypeEvent QueryRequestType = 0
	QueryTypeLog   QueryRequestType = 1
)

type QueryResult

type QueryResult struct {
	Error   error
	Results []QueryResultEvent
}

type QueryResultEvent

type QueryResultEvent struct {
	Event     string
	Timestamp int64
}

type Storage

type Storage interface {
	Init(config json.RawMessage, stats *storageStats) error
	Query(request QueryRequest) (QueryResult, error)
	Write(msg []lp.CCMessage) error
	Delete(to int64) error
	GetName() string
	Close()
}

type StorageBuffer

type StorageBuffer interface {
	Lock()
	Unlock()
	Add(msg lp.CCMessage)
	Get() []lp.CCMessage
	Clear()
	Len() int
}

func NewStorageBuffer

func NewStorageBuffer(cap int) (StorageBuffer, error)

type StorageManager

type StorageManager interface {
	Close()
	Start()
	Query(request QueryRequest) (QueryResult, error)
	SetInput(input chan lp.CCMessage)
	GetInput() chan lp.CCMessage
	Stats() StorageManagerStats
}

func NewStorageManager

func NewStorageManager(wg *sync.WaitGroup, rawConfig json.RawMessage) (StorageManager, error)

type StorageManagerStats

type StorageManagerStats struct {
	Manager storageStats      `json:"manager"`
	Backend storageStats      `json:"backend"`
	Info    map[string]string `json:"info"`
}

type StorageStats

type StorageStats interface {
	Init() error
	Close()
	ResetError(key string)
	UpdateError(key string, value int64)
	ResetStats(key string)
	UpdateStats(key string, value int64)
}

Jump to

Keyboard shortcuts

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