postgres

package
v0.0.0-...-90d47c1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	squirrel.StatementBuilderType
	// contains filtered or unexported fields
}

DB is a postgres db, for dev and production

func New

func New(uri, migrationsDir string) (DB, error)

New creates a new postgres DB

func (DB) Close

func (d DB) Close() error

Close finishes using the db

func (DB) DeactivateConfig

func (d DB) DeactivateConfig(userID string) error

DeactivateConfig deactivates a configuration.

func (DB) GetAllConfigs

func (d DB) GetAllConfigs() (map[string]configs.View, error)

GetAllConfigs gets all of the configs.

func (DB) GetAllRulesConfigs

func (d DB) GetAllRulesConfigs() (map[string]configs.VersionedRulesConfig, error)

GetAllRulesConfigs gets all alertmanager configs for all users.

func (DB) GetConfig

func (d DB) GetConfig(userID string) (configs.View, error)

GetConfig gets a configuration.

func (DB) GetConfigs

func (d DB) GetConfigs(since configs.ID) (map[string]configs.View, error)

GetConfigs gets all of the configs that have changed recently.

func (DB) GetRulesConfig

func (d DB) GetRulesConfig(userID string) (configs.VersionedRulesConfig, error)

GetRulesConfig gets the latest alertmanager config for a user.

func (DB) GetRulesConfigs

func (d DB) GetRulesConfigs(since configs.ID) (map[string]configs.VersionedRulesConfig, error)

GetRulesConfigs gets all the alertmanager configs that have changed since a given config.

func (DB) RestoreConfig

func (d DB) RestoreConfig(userID string) error

RestoreConfig restores configuration.

func (DB) SetConfig

func (d DB) SetConfig(userID string, cfg configs.Config) error

SetConfig sets a configuration.

func (DB) SetDeletedAtConfig

func (d DB) SetDeletedAtConfig(userID string, deletedAt pq.NullTime, cfg configs.Config) error

SetDeletedAtConfig sets a deletedAt for configuration by adding a single new row with deleted_at set the same as SetConfig is actually insert

func (DB) SetRulesConfig

func (d DB) SetRulesConfig(userID string, oldConfig, newConfig configs.RulesConfig) (bool, error)

SetRulesConfig sets the current alertmanager config for a user.

func (DB) Transaction

func (d DB) Transaction(f func(DB) error) error

Transaction runs the given function in a postgres transaction. If fn returns an error the txn will be rolled back.

Jump to

Keyboard shortcuts

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