messagecollector

package
v0.0.0-...-9a08fb1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound error = fmt.Errorf("not found")

Functions

This section is empty.

Types

type AggrResult

type AggrResult struct {
	Average *float64 `json:"avg,omitempty"`
	Total   *float64 `json:"sum,omitempty"`
	Minimum *float64 `json:"min,omitempty"`
	Maximum *float64 `json:"max,omitempty"`
	Count   *uint64  `json:"count,omitempty"`
}

type Measurement

type Measurement struct {
	DeviceID    string    `json:"deviceID"`
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Tenant      string    `json:"tenant"`
	Timestamp   time.Time `json:"timestamp"`
	Urn         string    `json:"urn"`
	BoolValue   *bool     `json:"vb,omitempty"`
	Lat         float64   `json:"lat"`
	Lon         float64   `json:"lon"`
	StringValue string    `json:"vs,omitempty"`
	Unit        string    `json:"unit,omitempty"`
	Value       *float64  `json:"v,omitempty"`
}

func NewMeasurement

func NewMeasurement(ts time.Time, id, deviceID, name, urn, tenant string) Measurement

type MeasurementResult

type MeasurementResult struct {
	ID           string     `json:"id,omitempty"`
	DeviceID     string     `json:"deviceID,omitempty"`
	Name         string     `json:"name,omitempty"`
	Urn          string     `json:"urn,omitempty"`
	Lat          *float64   `json:"lat,omitempty"`
	Lon          *float64   `json:"lon,omitempty"`
	LastObserved *time.Time `json:"lastObserved,omitempty"`
	Values       []Value    `json:"values"`
	Tenant       string     `json:"tenant,omitempty"`
}

type MeasurementRetriever

type MeasurementRetriever interface {
	Query(ctx context.Context, q QueryParams, tenants []string) QueryResult
	QueryDevice(ctx context.Context, deviceID string, tenants []string) QueryResult
	QueryObject(ctx context.Context, deviceID, urn string, tenants []string) QueryResult
}

type MeasurementStorer

type MeasurementStorer interface {
	Save(ctx context.Context, m Measurement) error
	SaveMany(ctx context.Context, m []Measurement) error
}

type MessageCollector

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

func (*MessageCollector) Start

func (mc *MessageCollector) Start(ctx context.Context)

type QueryParams

type QueryParams map[string][]string

func ParseQuery

func ParseQuery(q map[string][]string) QueryParams

func (QueryParams) GetBool

func (q QueryParams) GetBool(key string) (bool, bool)

func (QueryParams) GetString

func (q QueryParams) GetString(key string) (string, bool)

func (QueryParams) GetTime

func (q QueryParams) GetTime(key string) (time.Time, bool)

func (QueryParams) GetUint64

func (q QueryParams) GetUint64(key string) (uint64, bool)

func (QueryParams) GetUint64OrDefault

func (q QueryParams) GetUint64OrDefault(key string, i uint64) uint64

type QueryResult

type QueryResult struct {
	Data       any
	Count      uint64
	Offset     uint64
	Limit      uint64
	TotalCount uint64
	Error      error
}

type Value

type Value struct {
	ID          *string   `json:"id,omitempty"`
	Name        *string   `json:"n,omitempty"`
	BoolValue   *bool     `json:"vb,omitempty"`
	StringValue string    `json:"vs,omitempty"`
	Value       *float64  `json:"v,omitempty"`
	Unit        string    `json:"unit,omitempty"`
	Timestamp   time.Time `json:"timestamp"`
	Link        *string   `json:"link,omitempty"`
	Sum         *float64  `json:"sum,omitempty"`
	Urn         *string   `json:"urn,omitempty"`
}

Jump to

Keyboard shortcuts

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