influx

package
v0.0.0-...-a46f264 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package influx provides the implementation of the browser.Database interface using InfluxDB as backend. It uses an in-memory cache based on maps guarded by a sync.RWMutex for storing data of queries like "SHOW TAG VALUES" which can be slow on large datasets.

Index

Constants

This section is empty.

Variables

View Source
var (

	// CacheRefreshInterval is the interval in which the cache will be refreshed.
	CacheRefreshInterval = 8 * time.Hour
)

Functions

This section is empty.

Types

type DB

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

DB holds information for communicating with InfluxDB.

func NewDB

func NewDB(client client.Client, database string) (*DB, error)

NewDB returns a new instance of DB and initializes the internal caches and starts a new go routine for refreshing the cache on the defined CacheRefreshInterval.

func (*DB) GroupsByStation

func (db *DB) GroupsByStation(ctx context.Context, id int64) ([]browser.Group, error)

func (*DB) Maintenance

func (db *DB) Maintenance(ctx context.Context) ([]string, error)

func (*DB) Query

func (db *DB) Query(ctx context.Context, filter *browser.SeriesFilter) *browser.Stmt

func (*DB) Series

func (db *DB) Series(ctx context.Context, filter *browser.SeriesFilter) (browser.TimeSeries, error)

type UserService

type UserService struct {
	Client   client.Client
	Database string
	Env      string
}

UserService represents an service for retrieving information of an authenticated user stored in InfluxDB.

func (*UserService) Create

func (s *UserService) Create(ctx context.Context, user *browser.User) error

Create adds a new user to the database.

func (*UserService) Delete

func (s *UserService) Delete(ctx context.Context, user *browser.User) error

Delete will delete the given user from the database.

func (*UserService) Get

func (s *UserService) Get(ctx context.Context, user *browser.User) (*browser.User, error)

Get returns the given user if found.

func (*UserService) Update

func (s *UserService) Update(ctx context.Context, user *browser.User) error

Update will update the user information stored in the database. In Influx we cannot update single entries so we first need to retrieve the current stored user, delete it and re-create it with the given user.

Jump to

Keyboard shortcuts

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