db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToDB

func ConnectToDB(ctx context.Context, DBCfg *config.DBConfig, log *zerolog.Logger) (*pgxpool.Pool, error)

Types

type Alert

type Alert struct {
	ID         pgtype.UUID
	IncidentID pgtype.UUID
	SentAt     pgtype.Timestamptz
	AlertEmail string
	Status     string
	CreatedAt  pgtype.Timestamptz
}

type CloseMonitorIncidentParams

type CloseMonitorIncidentParams struct {
	MonitorID pgtype.UUID
	EndTime   pgtype.Timestamptz
}

type CreateAlertParams

type CreateAlertParams struct {
	IncidentID pgtype.UUID
	AlertEmail string
}

type CreateMonitorIncidentParams

type CreateMonitorIncidentParams struct {
	MonitorID  pgtype.UUID
	StartTime  pgtype.Timestamptz
	Alerted    bool
	HttpStatus int32
	LatencyMs  int32
}

type CreateMonitorParams

type CreateMonitorParams struct {
	UserID             pgtype.UUID
	Url                string
	IntervalSec        int32
	TimeoutSec         int32
	LatencyThresholdMs pgtype.Int4
	ExpectedStatus     pgtype.Int4
	AlertEmail         pgtype.Text
}

type CreateUserParams

type CreateUserParams struct {
	Name         string
	Email        string
	PasswordHash string
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetAllMonitorByUserIDParams

type GetAllMonitorByUserIDParams struct {
	UserID pgtype.UUID
	Limit  int32
	Offset int32
}

type GetIncidentByIDAndUserIDParams

type GetIncidentByIDAndUserIDParams struct {
	ID     pgtype.UUID
	UserID pgtype.UUID
}

type GetIncidentByIDAndUserIDRow

type GetIncidentByIDAndUserIDRow struct {
	ID          pgtype.UUID
	MonitorID   pgtype.UUID
	MonitorUrl  string
	StartTime   pgtype.Timestamptz
	EndTime     pgtype.Timestamptz
	Alerted     bool
	HttpStatus  int32
	LatencyMs   int32
	CreatedAt   pgtype.Timestamptz
	IsActive    bool
	DurationSec int64
	AlertStatus string
	AlertEmail  string
	AlertSentAt pgtype.Timestamptz
}

type GetMonitorByIDRow

type GetMonitorByIDRow struct {
	ID                 pgtype.UUID
	UserID             pgtype.UUID
	Url                string
	AlertEmail         pgtype.Text
	IntervalSec        int32
	TimeoutSec         int32
	LatencyThresholdMs pgtype.Int4
	ExpectedStatus     pgtype.Int4
	Enabled            bool
}

type GetMonitorParams

type GetMonitorParams struct {
	ID     pgtype.UUID
	UserID pgtype.UUID
}

type GetMonitorRow

type GetMonitorRow struct {
	ID                 pgtype.UUID
	UserID             pgtype.UUID
	Url                string
	AlertEmail         pgtype.Text
	IntervalSec        int32
	TimeoutSec         int32
	LatencyThresholdMs pgtype.Int4
	ExpectedStatus     pgtype.Int4
	Enabled            bool
}

type GetUserByEmailRow

type GetUserByEmailRow struct {
	ID           pgtype.UUID
	Name         string
	Email        string
	PasswordHash string
}

type GetUserByIDRow

type GetUserByIDRow struct {
	ID            pgtype.UUID
	Name          string
	Email         string
	PasswordHash  string
	MonitorsCount pgtype.Int4
}

type ListIncidentsByUserCursorParams

type ListIncidentsByUserCursorParams struct {
	UserID  pgtype.UUID
	Column2 string
	Column3 pgtype.Timestamptz
	Column4 pgtype.Timestamptz
	Column5 string
	Column6 pgtype.UUID
	Column7 pgtype.Timestamptz
	Column8 pgtype.UUID
	Limit   int32
}

type ListIncidentsByUserCursorRow

type ListIncidentsByUserCursorRow struct {
	ID          pgtype.UUID
	MonitorID   pgtype.UUID
	MonitorUrl  string
	StartTime   pgtype.Timestamptz
	EndTime     pgtype.Timestamptz
	Alerted     bool
	HttpStatus  int32
	LatencyMs   int32
	CreatedAt   pgtype.Timestamptz
	IsActive    bool
	DurationSec int64
	AlertStatus string
	AlertEmail  string
	AlertSentAt pgtype.Timestamptz
}

type ListIncidentsByUserIDParams

type ListIncidentsByUserIDParams struct {
	UserID pgtype.UUID
	Limit  int32
	Offset int32
}

type ListIncidentsByUserIDRow

type ListIncidentsByUserIDRow struct {
	ID          pgtype.UUID
	MonitorID   pgtype.UUID
	MonitorUrl  string
	StartTime   pgtype.Timestamptz
	EndTime     pgtype.Timestamptz
	Alerted     bool
	HttpStatus  int32
	LatencyMs   int32
	CreatedAt   pgtype.Timestamptz
	IsActive    bool
	DurationSec int64
	AlertStatus string
	AlertEmail  string
	AlertSentAt pgtype.Timestamptz
}

type Monitor

type Monitor struct {
	ID                 pgtype.UUID
	UserID             pgtype.UUID
	Url                string
	AlertEmail         pgtype.Text
	IntervalSec        int32
	TimeoutSec         int32
	LatencyThresholdMs pgtype.Int4
	ExpectedStatus     pgtype.Int4
	Enabled            bool
	UpdatedAt          pgtype.Timestamptz
	CreatedAt          pgtype.Timestamptz
}

type MonitorIncident

type MonitorIncident struct {
	ID         pgtype.UUID
	MonitorID  pgtype.UUID
	StartTime  pgtype.Timestamptz
	EndTime    pgtype.Timestamptz
	Alerted    bool
	HttpStatus int32
	LatencyMs  int32
	CreatedAt  pgtype.Timestamptz
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CloseMonitorIncident

func (q *Queries) CloseMonitorIncident(ctx context.Context, arg CloseMonitorIncidentParams) (pgtype.UUID, error)

func (*Queries) CountIncidentsByUserID

func (q *Queries) CountIncidentsByUserID(ctx context.Context, userID pgtype.UUID) (int64, error)

func (*Queries) CreateAlert

func (q *Queries) CreateAlert(ctx context.Context, arg CreateAlertParams) error

func (*Queries) CreateMonitor

func (q *Queries) CreateMonitor(ctx context.Context, arg CreateMonitorParams) (pgtype.UUID, error)

func (*Queries) CreateMonitorIncident

func (q *Queries) CreateMonitorIncident(ctx context.Context, arg CreateMonitorIncidentParams) (pgtype.UUID, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (pgtype.UUID, error)

func (*Queries) GetAllMonitorByUserID

func (q *Queries) GetAllMonitorByUserID(ctx context.Context, arg GetAllMonitorByUserIDParams) ([]Monitor, error)

func (*Queries) GetIncidentByIDAndUserID

func (*Queries) GetMonitor

func (q *Queries) GetMonitor(ctx context.Context, arg GetMonitorParams) (GetMonitorRow, error)

func (*Queries) GetMonitorByID

func (q *Queries) GetMonitorByID(ctx context.Context, id pgtype.UUID) (GetMonitorByIDRow, error)

func (*Queries) GetMonitorIncidentByID

func (q *Queries) GetMonitorIncidentByID(ctx context.Context, id pgtype.UUID) (MonitorIncident, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (GetUserByEmailRow, error)

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (GetUserByIDRow, error)

func (*Queries) IncrementMonitorCount

func (q *Queries) IncrementMonitorCount(ctx context.Context, id pgtype.UUID) (int64, error)

func (*Queries) ListIncidentsByUserCursor

func (q *Queries) ListIncidentsByUserCursor(ctx context.Context, arg ListIncidentsByUserCursorParams) ([]ListIncidentsByUserCursorRow, error)

func (*Queries) ListIncidentsByUserID

func (q *Queries) ListIncidentsByUserID(ctx context.Context, arg ListIncidentsByUserIDParams) ([]ListIncidentsByUserIDRow, error)

func (*Queries) UpdateAlertStatus

func (q *Queries) UpdateAlertStatus(ctx context.Context, arg UpdateAlertStatusParams) (int64, error)

func (*Queries) UpdateMonitorStatus

func (q *Queries) UpdateMonitorStatus(ctx context.Context, arg UpdateMonitorStatusParams) (int64, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type UpdateAlertStatusParams

type UpdateAlertStatusParams struct {
	ID     pgtype.UUID
	Status string
}

type UpdateMonitorStatusParams

type UpdateMonitorStatusParams struct {
	ID      pgtype.UUID
	Enabled bool
	UserID  pgtype.UUID
}

type User

type User struct {
	ID            pgtype.UUID
	Name          string
	Email         string
	PasswordHash  string
	Role          string
	MonitorsCount pgtype.Int4
	CreatedAt     pgtype.Timestamptz
}

Jump to

Keyboard shortcuts

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