database

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

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRecentSensorMessages

func GetRecentSensorMessages(db *DB, ipAddr string) (sensorMessages [][]byte, insertErr error)

GetRecentSensorMessages returns the most recent sensor messages (1 minute) of a client

func InsertSensorMessage

func InsertSensorMessage(db *DB, payload *map[string]interface{}, remoteAddress string) (err error)

InsertSensorMessage inserts a sensor message into the database

func UpsertClient

func UpsertClient(db *DB, remoteAddr string) *entities.ClientEntity

UpsertClient inserts a new client into the database if it doesn't exist, otherwise updates the last seen time

Types

type DB

type DB struct {
	*bun.DB
}

func Connect

func Connect(env *database_models.PostgresEnv) *DB

Connect creates a new database connection using exponential backoff when failing to connect

func (*DB) InsertClient

func (db *DB) InsertClient(ipAddr string) (*entities.ClientEntity, error)

InsertClient inserts a new client into the database

type DBClient

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

DBClient manages the lifecycle of database operations

func NewClient

func NewClient() *DBClient

func (*DBClient) GetDB

func (dbc *DBClient) GetDB() DB

func (*DBClient) Init

func (dbc *DBClient) Init(config *serverConfig.ServerConfig)

Init initializes the database client

func (*DBClient) Start

func (dbc *DBClient) Start() error

Start initializes the database client

func (*DBClient) Stop

func (dbc *DBClient) Stop() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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