storage

package
Version: v0.0.0-...-202a999 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GroupPrefix represents the source or metric group prefix.
	GroupPrefix = "group:"
)

Variables

View Source
var (
	// ErrEmptyGroup represents an empty group error.
	ErrEmptyGroup = errors.New("empty group")
	// ErrInvalidAlias represents an invalid alias error.
	ErrInvalidAlias = errors.New("invalid alias")
	// ErrInvalidID represents an invalid identifier error.
	ErrInvalidID = errors.New("invalid identifier")
	// ErrInvalidInterval represents an invalid interval error.
	ErrInvalidInterval = errors.New("invalid interval")
	// ErrInvalidName represents an invalid name error.
	ErrInvalidName = errors.New("invalid name")
	// ErrInvalidPattern represents an invalid pattern error.
	ErrInvalidPattern = errors.New("invalid pattern")
	// ErrInvalidPriority represents an invalid priority error.
	ErrInvalidPriority = errors.New("invalid priority")
	// ErrUnresolvableItem represents an unresolvable item error.
	ErrUnresolvableItem = errors.New("unresolvable item")
	// ErrUnscannableValue represents an unscannable value error.
	ErrUnscannableValue = errors.New("unscannable value")
)

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Item
	Entries    []*CollectionEntry `json:"entries,omitempty"`
	Link       *Collection        `json:"-"`
	LinkID     *string            `` /* 134-byte string literal not displayed */
	Attributes maputil.Map        `gorm:"type:text" json:"attributes,omitempty"`
	Alias      *string            `gorm:"type:varchar(128);unique_index" json:"alias,omitempty"`
	Options    maputil.Map        `gorm:"type:text" json:"options,omitempty"`
	Parent     *Collection        `json:"-"`
	ParentID   *string            `` /* 140-byte string literal not displayed */
	Template   bool               `gorm:"not null" json:"template"`
	// contains filtered or unexported fields
}

Collection represents a storage collection item instance.

func (*Collection) BeforeSave

func (c *Collection) BeforeSave(scope *gorm.Scope) error

BeforeSave handles the ORM 'BeforeSave' callback.

func (*Collection) Clone

func (c *Collection) Clone() *Collection

Clone returns a clone of the collection item instance.

func (*Collection) Expand

func (c *Collection) Expand(attrs maputil.Map) error

Expand expands the collection item instance using its linked instance.

func (*Collection) HasParent

func (c *Collection) HasParent() bool

HasParent returns whether or not the collection item has a parent instance.

func (*Collection) Resolve

func (c *Collection) Resolve(cache map[string]*Collection) error

Resolve resolves both the collection item linked and parent instances.

type CollectionEntry

type CollectionEntry struct {
	Index        int         `gorm:"type:int NOT NULL;primary_key" json:"-"`
	Collection   *Collection `json:"-"`
	CollectionID string      `` /* 135-byte string literal not displayed */
	Graph        *Graph      `json:"-"`
	GraphID      string      `` /* 129-byte string literal not displayed */
	Attributes   maputil.Map `gorm:"type:text" json:"attributes,omitempty"`
	Options      maputil.Map `gorm:"type:text" json:"options,omitempty"`
}

CollectionEntry represents a storage collection entry instance.

type CollectionTree

type CollectionTree []*CollectionTreeEntry

CollectionTree represents a storage collection tree instance.

func (CollectionTree) Len

func (c CollectionTree) Len() int

func (CollectionTree) Less

func (c CollectionTree) Less(i, j int) bool

func (CollectionTree) Swap

func (c CollectionTree) Swap(i, j int)

type CollectionTreeEntry

type CollectionTreeEntry struct {
	ID       string          `json:"id,omitempty"`
	Label    string          `json:"label,omitempty"`
	Alias    string          `json:"alias,omitempty"`
	Parent   string          `json:"parent,omitempty"`
	Children *CollectionTree `json:"children,omitempty"`
}

CollectionTreeEntry represents a storage collections tree entry instance.

type Graph

type Graph struct {
	Item
	Groups     SeriesGroups `gorm:"type:text;not null" json:"groups,omitempty"`
	Link       *Graph       `json:"-"`
	LinkID     *string      `` /* 129-byte string literal not displayed */
	Attributes maputil.Map  `gorm:"type:text" json:"attributes,omitempty"`
	Alias      *string      `gorm:"type:varchar(128);unique_index" json:"alias,omitempty"`
	Options    maputil.Map  `gorm:"type:text" json:"options,omitempty"`
	Template   bool         `gorm:"not null" json:"template"`
	// contains filtered or unexported fields
}

Graph represents a library graph item instance.

func (*Graph) BeforeSave

func (g *Graph) BeforeSave(scope *gorm.Scope) error

BeforeSave handles the ORM 'BeforeSave' callback.

func (*Graph) Clone

func (g *Graph) Clone() *Graph

Clone returns a clone of the graph item instance.

func (*Graph) Expand

func (g *Graph) Expand(attrs maputil.Map) error

Expand expands the graph item instance using its linked instance.

func (*Graph) Resolve

func (g *Graph) Resolve() error

Resolve resolves the graph item linked instance.

type GroupPatterns

type GroupPatterns []string

GroupPatterns represents a list of group patterns.

func (*GroupPatterns) Scan

func (gp *GroupPatterns) Scan(v interface{}) error

Scan unmarshals the group patterns retrieved from SQL drivers.

func (GroupPatterns) Value

func (gp GroupPatterns) Value() (driver.Value, error)

Value marshals the group patterns for compatibility with SQL drivers.

type Item

type Item struct {
	Type        string    `gorm:"-" json:"type,omitempty"`
	ID          string    `gorm:"type:varchar(36);not null;primary_key" json:"id"`
	Name        string    `gorm:"type:varchar(128);not null;unique_index" json:"name"`
	Description *string   `gorm:"type:text" json:"description"`
	Created     time.Time `gorm:"not null;default:current_timestamp" json:"created"`
	Modified    time.Time `gorm:"not null;default:current_timestamp" json:"modified"`
	// contains filtered or unexported fields
}

Item represents a storage item instance.

func (*Item) BeforeSave

func (i *Item) BeforeSave(scope *gorm.Scope) error

BeforeSave handles the ORM 'BeforeSave' callback.

func (*Item) SetStorage

func (i *Item) SetStorage(s *Storage)

SetStorage sets the item internal storage reference.

type MetricGroup

type MetricGroup struct {
	Item
	Patterns GroupPatterns `gorm:"type:text;not null" json:"patterns"`
}

MetricGroup represents a library metric group item instance.

func (*MetricGroup) BeforeSave

func (mg *MetricGroup) BeforeSave(scope *gorm.Scope) error

BeforeSave handles the ORM 'BeforeSave' callback.

func (MetricGroup) TableName

func (MetricGroup) TableName() string

TableName returns the table name to use in the database.

type Provider

type Provider struct {
	Item
	Connector       string          `gorm:"type:varchar(32);not null" json:"connector"`
	Settings        *maputil.Map    `gorm:"type:text" json:"settings"`
	Filters         ProviderFilters `gorm:"type:text" json:"filters"`
	RefreshInterval int             `gorm:"not null;default:0" json:"refresh_interval"`
	Priority        int             `gorm:"not null;default:0" json:"priority"`
	Enabled         bool            `gorm:"not null;default:true" json:"enabled"`
}

Provider represents a storage provider item instance.

func (*Provider) BeforeSave

func (p *Provider) BeforeSave(scope *gorm.Scope) error

BeforeSave handles the ORM 'BeforeSave' callback.

type ProviderFilter

type ProviderFilter struct {
	Action  string `json:"action"`
	Target  string `json:"target"`
	Pattern string `json:"pattern"`
	Into    string `json:"into"`
}

ProviderFilter represents a storage provider filter entry instance.

type ProviderFilters

type ProviderFilters []*ProviderFilter

ProviderFilters represents a list of storage provider filters.

func (*ProviderFilters) Scan

func (pf *ProviderFilters) Scan(v interface{}) error

Scan unmarshals the provider filter entries retrieved from SQL drivers.

func (ProviderFilters) Value

func (pf ProviderFilters) Value() (driver.Value, error)

Value marshals the provider filter entries for compatibility with SQL drivers.

type Series

type Series struct {
	Name    string      `json:"name"`
	Origin  string      `json:"origin"`
	Source  string      `json:"source"`
	Metric  string      `json:"metric"`
	Options maputil.Map `json:"options,omitempty"`
}

Series represents a library graph series entry instance.

func (Series) IsValid

func (s Series) IsValid() bool

IsValid checks whether or not the series instance is valid.

func (Series) String

func (s Series) String() string

String returns a string representation of the series instance.

type SeriesGroup

type SeriesGroup struct {
	Name        string      `json:"name"`
	Operator    int         `json:"operator"`
	Consolidate int         `json:"consolidate"`
	Series      []*Series   `json:"series"`
	Options     maputil.Map `json:"options,omitempty"`
}

SeriesGroup represents a library graph series group entry instance.

type SeriesGroups

type SeriesGroups []*SeriesGroup

SeriesGroups represents a list of library graph series groups.

func (*SeriesGroups) Scan

func (sg *SeriesGroups) Scan(v interface{}) error

Scan unmarshals the series groups retrieved from SQL drivers.

func (SeriesGroups) Value

func (sg SeriesGroups) Value() (driver.Value, error)

Value marshals the series groups for compatibility with SQL drivers.

type SourceGroup

type SourceGroup struct {
	Item
	Patterns GroupPatterns `gorm:"type:text;not null" json:"patterns"`
}

SourceGroup represents a library source group item instance.

func (*SourceGroup) BeforeSave

func (sg *SourceGroup) BeforeSave(scope *gorm.Scope) error

BeforeSave handles the ORM 'BeforeSave' callback.

func (SourceGroup) TableName

func (SourceGroup) TableName() string

TableName returns the table name to use in the database.

type Storage

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

Storage represents a storage instance.

func New

func New(config *maputil.Map, logger *logger.Logger) (*Storage, error)

New creates a new storage instance.

func (*Storage) Close

func (s *Storage) Close() error

Close closes the storage.

func (*Storage) NewCollection

func (s *Storage) NewCollection() *Collection

NewCollection creates a new collection item instance.

func (*Storage) NewCollectionTree

func (s *Storage) NewCollectionTree(root string) (*CollectionTree, error)

NewCollectionTree creates a new storage collection tree instance.

func (*Storage) NewGraph

func (s *Storage) NewGraph() *Graph

NewGraph creates a new storage graph item instance.

func (*Storage) NewMetricGroup

func (s *Storage) NewMetricGroup() *MetricGroup

NewMetricGroup creates a new storage metric group item instance.

func (*Storage) NewProvider

func (s *Storage) NewProvider() *Provider

NewProvider creates a new storage provider item instance.

func (*Storage) NewSourceGroup

func (s *Storage) NewSourceGroup() *SourceGroup

NewSourceGroup creates a new storage source group item instance.

func (*Storage) SQL

func (s *Storage) SQL() *sqlstorage.Storage

SQL returns the storage underlying SQL storage instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL