domain

package
v0.0.0-...-bb39121 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataQuery

type DataQuery struct {
	Metric []string `json:"metric"`
	Start  int64    `json:"start"`
	End    int64    `json:"end"`
	Limit  int64    `json:"limit"`
	Tags   Tags     `json:"tags"`
}

type DataSet

type DataSet struct {
	Metric
	Tags   Tags        `json:"tags"`
	Values []DataValue `json:"dps"`
}
DataSet JSON:
{
	"name": "metric_name",
	"tags": {"tag1": "val", "tag2": "val"},
	"dps": [
		["t": 123123, v: 0],
		["t": 123124, v: 0]
	]
}

type DataValue

type DataValue struct {
	Timestamp int64 `json:"t" db:"time"`
	Value     int64 `json:"v" db:"value"` // just ints for now - better to be interface{} to account for floats?
}

type Metric

type Metric struct {
	Name string `json:"name" db:"name"`
	Desc string `json:"desc,omitempty" db:"desc,omitempty"`
}

type Store

type Store interface {
	SaveDataSet(ds DataSet) error
	GetDataSet(q DataQuery) ([]DataSet, error)
	CreateMetric(m Metric) error
	GetMetric(metric string) (Metric, error)
	UpdateMetric(m Metric) error
	DeleteMetric(metric string) error
}
An assumption is that SaveDataSet() and GetDataSet() will be involving

* stucts of small enough size that using copies rather than pointers is * appropriate.

type Tags

type Tags map[string]string

func (Tags) String

func (tags Tags) String() string

type UnixTime

type UnixTime struct {
	time.Time
}

func NewUnixTime

func NewUnixTime(v interface{}) *UnixTime

func (UnixTime) MarshalJSON

func (u UnixTime) MarshalJSON() ([]byte, error)

MarshalJSON turns our time.Time back into an int

func (*UnixTime) Scan

func (u *UnixTime) Scan(v interface{}) error

accept an int64 or RFC3339 timestamp or nil

func (*UnixTime) UnmarshalJSON

func (u *UnixTime) UnmarshalJSON(b []byte) error

UnmarshalJSON is the method that satisfies the Unmarshaller interface

Jump to

Keyboard shortcuts

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