db

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 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 CreateInvitationParams added in v0.1.2

type CreateInvitationParams struct {
	Email     string
	Role      string
	Token     string
	ExpiresAt pgtype.Timestamptz
	InvitedBy pgtype.UUID
}

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
	Role         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 DeleteMonitorParams added in v0.1.2

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

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 GetTeamRow added in v0.1.2

type GetTeamRow struct {
	ID   int32
	Name string
}

type GetUserByEmailRow

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

type GetUserByIDRow

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

type InstanceSetting added in v0.1.2

type InstanceSetting struct {
	ID                   int32
	RegistrationsEnabled bool
}

type Invitation added in v0.1.2

type Invitation struct {
	ID         pgtype.UUID
	Email      string
	Role       string
	Token      string
	ExpiresAt  pgtype.Timestamptz
	AcceptedAt pgtype.Timestamptz
	InvitedBy  pgtype.UUID
	CreatedAt  pgtype.Timestamptz
}

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 ListUsersRow added in v0.1.2

type ListUsersRow struct {
	ID        pgtype.UUID
	Name      string
	Email     string
	Role      string
	IsActive  bool
	CreatedAt 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) AcceptInvitation added in v0.1.2

func (q *Queries) AcceptInvitation(ctx context.Context, token string) error

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) CreateInvitation added in v0.1.2

func (q *Queries) CreateInvitation(ctx context.Context, arg CreateInvitationParams) (Invitation, 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) DecrementMonitorCount added in v0.1.2

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

func (*Queries) DeleteInvitation added in v0.1.2

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

func (*Queries) DeleteMonitor added in v0.1.2

func (q *Queries) DeleteMonitor(ctx context.Context, arg DeleteMonitorParams) (int64, error)

func (*Queries) GetAllMonitorByUserID

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

func (*Queries) GetIncidentByIDAndUserID

func (*Queries) GetInvitationByToken added in v0.1.2

func (q *Queries) GetInvitationByToken(ctx context.Context, token string) (Invitation, error)

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) GetRegistrationsEnabled added in v0.1.2

func (q *Queries) GetRegistrationsEnabled(ctx context.Context) (bool, error)

func (*Queries) GetTeam added in v0.1.2

func (q *Queries) GetTeam(ctx context.Context) (GetTeamRow, error)

func (*Queries) GetUserActiveStatus added in v0.1.2

func (q *Queries) GetUserActiveStatus(ctx context.Context, id pgtype.UUID) (bool, 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) GetUserPasswordHash added in v0.1.2

func (q *Queries) GetUserPasswordHash(ctx context.Context, id pgtype.UUID) (string, error)

func (*Queries) HasUsers added in v0.1.2

func (q *Queries) HasUsers(ctx context.Context) (bool, 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) ListInvitations added in v0.1.2

func (q *Queries) ListInvitations(ctx context.Context) ([]Invitation, error)

func (*Queries) ListUsers added in v0.1.2

func (q *Queries) ListUsers(ctx context.Context) ([]ListUsersRow, error)

func (*Queries) SetRegistrationsEnabled added in v0.1.2

func (q *Queries) SetRegistrationsEnabled(ctx context.Context, registrationsEnabled bool) error

func (*Queries) SetUserActive added in v0.1.2

func (q *Queries) SetUserActive(ctx context.Context, arg SetUserActiveParams) 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) UpdateTeamName added in v0.1.2

func (q *Queries) UpdateTeamName(ctx context.Context, name string) error

func (*Queries) UpdateUserName added in v0.1.2

func (q *Queries) UpdateUserName(ctx context.Context, arg UpdateUserNameParams) error

func (*Queries) UpdateUserPassword added in v0.1.2

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

func (*Queries) WithTx

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

type SetUserActiveParams added in v0.1.2

type SetUserActiveParams struct {
	IsActive bool
	ID       pgtype.UUID
}

type Team added in v0.1.2

type Team struct {
	ID        int32
	Name      string
	CreatedAt pgtype.Timestamptz
}

type UpdateAlertStatusParams

type UpdateAlertStatusParams struct {
	ID     pgtype.UUID
	Status string
}

type UpdateMonitorStatusParams

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

type UpdateUserNameParams added in v0.1.2

type UpdateUserNameParams struct {
	Name string
	ID   pgtype.UUID
}

type UpdateUserPasswordParams added in v0.1.2

type UpdateUserPasswordParams struct {
	PasswordHash string
	ID           pgtype.UUID
}

type User

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

Jump to

Keyboard shortcuts

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