resource

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceDir = "resources"
	MainScript  = "resources.js"
)

Variables

This section is empty.

Functions

func AllScripts

func AllScripts() []string

func AllTypes

func AllTypes() map[db.ResourceType]string

func GraphiteTimestamp

func GraphiteTimestamp(t time.Time) string

GraphiteTimestamp converts t to a value suitable for use as the from or until argument to the Graphite render API.

Types

type Graphite

type Graphite struct{}

func (Graphite) Id

func (Graphite) Id() db.ResourceType

func (Graphite) Name

func (Graphite) Name() string

func (Graphite) Scripts

func (Graphite) Scripts() []string

func (Graphite) Templates

func (Graphite) Templates() string

type GraphiteDaemon

type GraphiteDaemon struct {
	// Base is the URL where the server can be found. Base should have a
	// trailing slash, with the expectation that the render API endpoint is
	// at Base + "render".
	Base string
}

GraphiteDaemon represents a remote Graphite server. For more information, see http://graphite.readthedocs.org/ .

func (GraphiteDaemon) Query

func (g GraphiteDaemon) Query(target string, from, until time.Time) ([]GraphiteSeries, error)

Query retrieves data stored in Graphite for the given time period.

func (GraphiteDaemon) QueryRecent

func (g GraphiteDaemon) QueryRecent(target string, d time.Duration) ([]GraphiteSeries, error)

QueryRecent retrieves data stored in Graphite for the most recent d time.

func (GraphiteDaemon) RenderURL

func (g GraphiteDaemon) RenderURL(targets []string, args map[string]string) string

RenderURL builds a Graphite render API URL for the given targets. The key-value pairs in args are added to the URL.

type GraphiteResource

type GraphiteResource struct {
	Graphite
	URL string
}

func (GraphiteResource) Serialize

func (g GraphiteResource) Serialize() (string, error)

func (GraphiteResource) Type

func (g GraphiteResource) Type() ResourceType

func (GraphiteResource) Validate

func (g GraphiteResource) Validate() []string

type GraphiteResourceDBModel

type GraphiteResourceDBModel struct {
	URL string
}

Eventually implemented in DB layer

type GraphiteSeries

type GraphiteSeries struct {
	Name       string
	Start, End time.Time
	Step       time.Duration
	Values     []float64
}

GraphiteSeries encapsulates the data returned by Graphite for a particular series. The values in Values correspond to the times between Start and End, inclusive, that are Step times apart. Null values are represented by NaN.

XXX(eefi): It is possible to store NaN in Graphite, and encoding nulls as NaN makes those cases indistinguishable. However, actual NaNs should be rare, and encoding nulls as NaN removes the need for an extra layer of pointer indirection.

type Resource

type Resource interface {
	ResourceType
	Serialize() (string, error)
	Type() ResourceType
	Validate() []string
}

func Blank

func Blank(id db.ResourceType) (Resource, error)

func Default

func Default() (Resource, error)

func LoadFromDB

func LoadFromDB(id db.ResourceType, dsJson string) (Resource, error)

func LoadFromParams

func LoadFromParams(id db.ResourceType, dsParams string) (Resource, error)

type ResourceType

type ResourceType interface {
	Id() db.ResourceType
	Name() string

	Templates() string
	Scripts() []string
	// contains filtered or unexported methods
}

ResourceType and Resource define a common display abstraction for all Resources.

type VM

type VM struct {
	Resource
	ResourceParams string
	ResourceType   db.ResourceType
	ResourceID     db.ResourceID
	Delete         bool
}

The VM struct is practically identical in purpose to its counterparts in the vm package, as it represents the intermediate structure between Revere's DB representation of the Resource and its front end representation of the Resource.

func All

func All(DB *db.DB) ([]*VM, error)

func AllOfTypes

func AllOfTypes(DB *db.DB, ids []db.ResourceType) ([]*VM, error)

func (*VM) ComponentName

func (*VM) ComponentName() string

func (*VM) Id

func (vm *VM) Id() int64

func (*VM) IsCreate

func (vm *VM) IsCreate() bool

func (*VM) IsDelete

func (vm *VM) IsDelete() bool

func (*VM) Save

func (vm *VM) Save(tx *db.Tx) error

func (*VM) Validate

func (vm *VM) Validate() (errs []string)

Jump to

Keyboard shortcuts

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