dataaccess

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicate is the error for a duplicate record.
	ErrDuplicate = errors.New("duplicate record")

	// ErrNotFound is the error for a record not found.
	ErrNotFound = errors.New("record not found")
)
View Source
var DB database
View Source
var DatabaseLatency = promauto.NewHistogramVec(
	prometheus.HistogramOpts{
		Name: "database_latency",
		Help: "Duration of database queries",
	},
	[]string{"query"},
)

DatabaseLatency is the duration of database queries.

View Source
var Files fileHandler
View Source
var StorageLatency = promauto.NewHistogramVec(
	prometheus.HistogramOpts{
		Name: "storage_latency",
		Help: "Duration of fileHandler queries",
	},
	[]string{"query"},
)

StorageLatency is the duration of Files queries.

Functions

func ConnectDatabase

func ConnectDatabase(ctx context.Context, dbType string) error

func ConnectStorage

func ConnectStorage(ctx context.Context, storeType StoreType, bucketName string) error

func Purge

func Purge(from time.Time) error

func PurgeAll

func PurgeAll() error

Types

type DbOpt

type DbOpt string
const (
	// DbSqlite is the sqlite database.
	DbSqlite DbOpt = "SQLITE"

	// DbMySQL is the MySQL database.
	DbMySQL DbOpt = "MYSQL"

	// DbMongo is the MongoDB database.
	DbMongo DbOpt = "MONGO"
)

func (DbOpt) IsIn

func (d DbOpt) IsIn(opts ...DbOpt) bool

func (DbOpt) String

func (d DbOpt) String() string

func (DbOpt) Valid

func (d DbOpt) Valid() bool

type MockDb

type MockDb struct {
	mock.Mock
}

func (*MockDb) Close

func (m *MockDb) Close(ctx context.Context) error

func (*MockDb) GetEnvironments

func (m *MockDb) GetEnvironments(ctx context.Context) ([]entities.Environment, error)

func (*MockDb) GetHistory

func (m *MockDb) GetHistory(ctx context.Context, environment entities.Environment) ([]*entities.PuppetHistory, error)

func (*MockDb) GetReport

func (m *MockDb) GetReport(ctx context.Context, id string) (*entities.PuppetReport, error)

func (*MockDb) GetReports

func (m *MockDb) GetReports(ctx context.Context, fqdn string) ([]*entities.PuppetReportSummary, error)

func (*MockDb) GetRuns

func (m *MockDb) GetRuns(ctx context.Context) ([]*entities.PuppetRun, error)

func (*MockDb) GetRunsByState

func (m *MockDb) GetRunsByState(ctx context.Context, states ...entities.State) ([]*entities.PuppetRun, error)

func (*MockDb) Ping

func (m *MockDb) Ping(ctx context.Context) error

func (*MockDb) Purge

func (m *MockDb) Purge(ctx context.Context, from time.Time) (int, error)

func (*MockDb) SaveRun

func (m *MockDb) SaveRun(ctx context.Context, run *entities.PuppetReport) error

type MockStorage

type MockStorage struct {
	mock.Mock
}

func (*MockStorage) DeleteFile

func (m *MockStorage) DeleteFile(ctx context.Context, filePath string) error

func (*MockStorage) DownloadFile

func (m *MockStorage) DownloadFile(ctx context.Context, filePath string) ([]byte, error)

func (*MockStorage) Purge

func (m *MockStorage) Purge(ctx context.Context, from time.Time) (int, error)

func (*MockStorage) SaveFile

func (m *MockStorage) SaveFile(ctx context.Context, filePath string, file []byte) error

type StoreType

type StoreType string
const (
	// StoreTypeLocal is a local file system store
	StoreTypeLocal StoreType = "LOCAL"

	// StoreTypeS3 is an S3 store
	StoreTypeS3 StoreType = "S3"

	// StoreTypeGCS is a Google Cloud fileHandler store
	StoreTypeGCS StoreType = "GCS"
)

Jump to

Keyboard shortcuts

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