storage

package
v0.0.0-...-b3995a3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDoesNotExist = errors.New("object does not exist")
)

Functions

func CreateDeployment

func CreateDeployment(ctx context.Context, db sqlx.Execer, d *Deployment) error

CreateDeployment creates the given Deployment.

func CreateDeploymentDevice

func CreateDeploymentDevice(ctx context.Context, db sqlx.Execer, dd *DeploymentDevice) error

CreateDeploymentDevice creates the given DeploymentDevice.

func CreateDeploymentLog

func CreateDeploymentLog(ctx context.Context, db sqlx.Queryer, dl *DeploymentLog) error

CreateDeploymentLog creates the given DeploymentLog.

func DB

func DB() *sqlx.DB

DB returns the DB instance.

func MigrateDown

func MigrateDown(db *sqlx.DB) error

func MigrateUp

func MigrateUp(db *sqlx.DB) error

func Setup

func Setup(conf *config.Config) error

Setup configures the storage package.

func Transaction

func Transaction(f func(tx sqlx.Ext) error) error

Transaction wraps the given function in a transaction. In case the given functions returns an error, the transaction will be rolled back.

func UpdateDeployment

func UpdateDeployment(ctx context.Context, db sqlx.Execer, d *Deployment) error

UpdateDeployment updates the given Deployment.

func UpdateDeploymentDevice

func UpdateDeploymentDevice(ctx context.Context, db sqlx.Execer, dd *DeploymentDevice) error

UpdateDeploymentDevice updates the given DeploymentDevice.

Types

type Deployment

type Deployment struct {
	ID                          uuid.UUID  `db:"id"`
	CreatedAt                   time.Time  `db:"created_at"`
	UpdatedAt                   time.Time  `db:"updated_at"`
	MCGroupSetupCompletedAt     *time.Time `db:"mc_group_setup_completed_at"`
	MCSessionCompletedAt        *time.Time `db:"mc_session_completed_at"`
	FragSessionSetupCompletedAt *time.Time `db:"frag_session_setup_completed_at"`
	EnqueueCompletedAt          *time.Time `db:"enqueue_completed_at"`
	FragStatusCompletedAt       *time.Time `db:"frag_status_completed_at"`
}

Deployment represents a FUOTA deployment.

func GetDeployment

func GetDeployment(ctx context.Context, db sqlx.Queryer, id uuid.UUID) (Deployment, error)

GetDeployment returns the Deployment given an ID.

type DeploymentDevice

type DeploymentDevice struct {
	DeploymentID                uuid.UUID     `db:"deployment_id"`
	DevEUI                      lorawan.EUI64 `db:"dev_eui"`
	CreatedAt                   time.Time     `db:"created_at"`
	UpdatedAt                   time.Time     `db:"updated_at"`
	MCGroupSetupCompletedAt     *time.Time    `db:"mc_group_setup_completed_at"`
	MCSessionCompletedAt        *time.Time    `db:"mc_session_completed_at"`
	FragSessionSetupCompletedAt *time.Time    `db:"frag_session_setup_completed_at"`
	FragStatusCompletedAt       *time.Time    `db:"frag_status_completed_at"`
}

DeploymentDevice represents a device within a FUOTA deployment.

func GetDeploymentDevice

func GetDeploymentDevice(ctx context.Context, db sqlx.Queryer, deploymentID uuid.UUID, devEUI lorawan.EUI64) (DeploymentDevice, error)

GetDeploymentDevice returns the DeploymentDevice for the given Deployment ID and DevEUI.

func GetDeploymentDevices

func GetDeploymentDevices(ctx context.Context, db sqlx.Queryer, deploymentID uuid.UUID) ([]DeploymentDevice, error)

GetDeploymentDevices returns the DeploymentDevices for the given Deployment ID.

type DeploymentLog

type DeploymentLog struct {
	ID           int64         `db:"id"`
	CreatedAt    time.Time     `db:"created_at"`
	DeploymentID uuid.UUID     `db:"deployment_id"`
	DevEUI       lorawan.EUI64 `db:"dev_eui"`
	FPort        uint8         `db:"f_port"`
	Command      string        `db:"command"`
	Fields       hstore.Hstore `db:"fields"`
}

DeploymentLog contains a deployment log item.

func GetDeploymentLogsForDevice

func GetDeploymentLogsForDevice(ctx context.Context, db sqlx.Queryer, deploymentID uuid.UUID, devEUI lorawan.EUI64) ([]DeploymentLog, error)

GetDeploymentLogsForDevice returns the deployment logs given a deployment ID and DevEUI.

Jump to

Keyboard shortcuts

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