base

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	HeaderErrorMessage = "X-Warp10-Error-Message"
	HeaderElapsed      = "X-Warp10-Elapsed"
	HeaderErrorLine    = "X-Warp10-Error-Line"
	HeaderFetched      = "X-Warp10-Fetched"
	HeaderOperations   = "X-Warp10-Ops"
)

Variables

View Source
var (
	NoReadTokenError  = errors.New("this Warp10 call need a READ token access on the data")
	NoWriteTokenError = errors.New("this Warp10 call need a WRITE token access on the data")
)

Functions

This section is empty.

Types

type Attributes

type Attributes map[string]string

Attributes is a string key/value definition

type Client

type Client struct {
	Host         string
	Warp10Header string

	ExecPath   string
	UpdatePath string
	MetaPath   string
	FetchPath  string
	FindPath   string
	DeletePath string

	ReadToken  string
	WriteToken string

	HTTPClient *http.Client
}

Client is a Warp10 client

func NewClient

func NewClient(host string) *Client

NewClient return a configured Warp10 Client

func (*Client) Delete

func (c *Client) Delete(selector Selector, start time.Time, stop time.Time) ([]byte, error)

Delete execute a WarpScript on the backend, returning resultat as byte array if start and end are nil, assume user want to delete all datapoints Enhance parse response

func (*Client) Exec

func (c *Client) Exec(warpScript string) ([]byte, error)

Exec execute a WarpScript on the backend, returning resultat as byte array

func (*Client) Fetch

func (c *Client) Fetch(selector Selector, start time.Time, stop time.Time) ([]byte, error)

Fetch execute a WarpScript on the backend, returning resultat as byte array Enhance parse response

func (*Client) Find

func (c *Client) Find(selector Selector) ([]byte, error)

Find execute a WarpScript on the backend, returning resultat as byte array Enhance parse response

func (*Client) Meta

func (c *Client) Meta(gtsList GTSList) ([]byte, error)

Meta execute a WarpScript on the backend, returning resultat as byte array Enhance parse response

func (*Client) Update

func (c *Client) Update(gts GTSList) error

Update execute a WarpScript on the backend, returning resultat as byte array

type Datapoints

type Datapoints [][]interface{}

Datapoints is the sensision datapoints representation

func (*Datapoints) Add

func (dps *Datapoints) Add(ts time.Time, value interface{}) *Datapoints

Add a new point to a GTS

func (*Datapoints) AddWithGeo

func (dps *Datapoints) AddWithGeo(ts time.Time, lattitude, longitude, altitude float64, value interface{}) *Datapoints

AddWithGeo a new point to a GTS with geolocation

func (*Datapoints) Has

func (dps *Datapoints) Has(ts time.Time) bool

Has look for datapoint at this time

func (*Datapoints) Remove

func (dps *Datapoints) Remove(ts time.Time) *Datapoints

Remove datapoint at this time (only the first)

type GTS

type GTS struct {
	// Name of the time serie
	ClassName string `json:"c"`
	// Key/value of the GTS labels (changing one key or his value create a new GTS)
	Labels Labels `json:"l"`
	// Key/value of the GTS attributes (can be setted/updated/removed without creating a new GTS)
	Attributes Attributes `json:"a"`
	// Timestamp of the last datapoint received on this GTS (% last activity window)
	LastActivity int64 `json:"la"`
	// Array of datapoints of this GTS
	Values Datapoints `json:"v"`
}

GTS is the Warp10 representation of a GeoTimeSerie (GTS)

func NewEmptyGTS

func NewEmptyGTS() *GTS

NewEmptyGTS return an empty GTS

func NewGTS

func NewGTS(className string) *GTS

NewGTS return a nammed GTS

func NewGTSWithLabels

func NewGTSWithLabels(className string, labels Labels) *GTS

NewGTSWithLabels return a nammed and labelized GTS

func ParseGTSFromBytes

func ParseGTSFromBytes(in []byte) (*GTS, error)

ParseGTSFromBytes parse sensision format into a new GTS

func ParseGTSFromString

func ParseGTSFromString(sensisionLine string) (*GTS, error)

ParseGTSFromString parse an unique sensision format line into a new GTS

func (*GTS) Sensision

func (gts *GTS) Sensision() string

Sensision return the sensision format of the GTS

func (*GTS) SensisionSelector

func (gts *GTS) SensisionSelector(withAttributes bool) string

SensisionSelector return the GTS selector (class + labels (+ attributes) )

type GTSList

type GTSList []*GTS

GTSList is an array of GTS

func ParseGTSArrayFromBytes

func ParseGTSArrayFromBytes(in []byte) (GTSList, error)

ParseGTSArrayFromBytes parse sensision format into a new GTS array

func ParseGTSArrayFromString

func ParseGTSArrayFromString(in string) (GTSList, error)

ParseGTSArrayFromString parse sensision format into a new GTS array

func (GTSList) Sensision

func (gtsList GTSList) Sensision() string

Sensision return the sensision format of all GTS

func (GTSList) SensisionSelectors

func (gtsList GTSList) SensisionSelectors(withAttributes bool) string

SensisionSelectors return the GTSList selectors (class + labels (+ attributes) )

type Labels

type Labels map[string]string

Labels is a string key/value definition

type Selector

type Selector string

Selector is a Warp10 selector

const (
	// WildCardSelector select all available GTS
	WildCardSelector Selector = "~.*{}"
)

func NewSelector

func NewSelector(className string, labels Labels) Selector

NewSelector Build a new Selector

Jump to

Keyboard shortcuts

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