postgres

package
v0.0.0-...-227a949 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: EUPL-1.2 Imports: 7 Imported by: 0

Documentation

Overview

Package postgres contains a client for a PostgreSQL Cloudburst backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSenML

func NewSenML(pgRow pgx.Rows) (m senml.Measurement, err error)

NewSenML creates a new SenML measurement from an PostgreSQL row.

Types

type Client

type Client struct {
	*pgxpool.Pool
	// contains filtered or unexported fields
}

Client is an extended Postgres pool.

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

NewClient returns a Client for the given configuration.

func (*Client) Close

func (c *Client) Close() error

Close all connections to the InfluxDB server gracefully.

func (*Client) Name

func (c *Client) Name() string

Name returns the name of the backend.

func (*Client) Query

func (c *Client) Query(name, host string, from, to time.Time, last bool) (measurements []senml.Measurement, err error)

Query builds a query based on the given parameters and returns the result as SenML.

func (*Client) Write

func (c *Client) Write(name, host string, data ...senml.Measurement) error

Write a series of SenML measurements to Postgres.

type ClientConfig

type ClientConfig struct {
	URL   string `yaml:"url"`
	Table string `yaml:"table"`
}

ClientConfig contains Postgres client configuration.

type SenMLRow

type SenMLRow struct {
	Host       string
	Name       string
	Time       time.Time
	UpdateTime float64
	Unit       string
	Bool       *bool
	Data       []byte
	String     *string
	Sum        *float64
	Value      *float64
}

SenMLRow contains a database row representing a SenML measurement.

func NewSenMLRow

func NewSenMLRow(measurement senml.Measurement) *SenMLRow

NewSenMLRow returns a SenMLRow for a senml.Measurement.

func (*SenMLRow) Attrs

func (r *SenMLRow) Attrs() senml.Attributes

Attrs returns the SenML attributes for a SenMLRow.

Jump to

Keyboard shortcuts

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