incident

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeCursor

func EncodeCursor(c Cursor) (string, error)

func Routes

func Routes(h *Handler) chi.Router

Types

type AppliedFilters

type AppliedFilters struct {
	Status    string  `json:"status"`
	Query     string  `json:"query,omitempty"`
	MonitorID *string `json:"monitor_id,omitempty"`
	From      *string `json:"from,omitempty"`
	To        *string `json:"to,omitempty"`
}

type Cursor

type Cursor struct {
	StartTime  time.Time
	IncidentID string
}

func DecodeCursor

func DecodeCursor(v string) (*Cursor, error)

type Handler

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

func NewHandler

func NewHandler(service *Service, logger *zerolog.Logger) *Handler

func (*Handler) GetIncident

func (h *Handler) GetIncident(w http.ResponseWriter, r *http.Request)

func (*Handler) ListIncidents

func (h *Handler) ListIncidents(w http.ResponseWriter, r *http.Request)

type Incident

type Incident struct {
	ID          string
	MonitorID   string
	MonitorURL  string
	StartTime   time.Time
	EndTime     *time.Time
	Alerted     bool
	HTTPStatus  int32
	LatencyMs   int32
	CreatedAt   time.Time
	IsActive    bool
	DurationSec int64
	AlertStatus string
	AlertEmail  string
	AlertSentAt *time.Time
}

type IncidentResponse

type IncidentResponse struct {
	ID          string               `json:"id"`
	MonitorID   string               `json:"monitor_id"`
	MonitorURL  string               `json:"monitor_url"`
	StartTime   string               `json:"start_time"`
	EndTime     *string              `json:"end_time,omitempty"`
	Alerted     bool                 `json:"alerted"`
	HTTPStatus  int32                `json:"http_status"`
	LatencyMs   int32                `json:"latency_ms"`
	CreatedAt   string               `json:"created_at"`
	IsActive    bool                 `json:"is_active"`
	DurationSec int64                `json:"duration_sec"`
	LatestAlert *LatestAlertResponse `json:"latest_alert,omitempty"`
}

type LatestAlertResponse

type LatestAlertResponse struct {
	Status string  `json:"status,omitempty"`
	Email  string  `json:"email,omitempty"`
	SentAt *string `json:"sent_at,omitempty"`
}

type ListFilters

type ListFilters struct {
	Status    string
	Query     string
	MonitorID *uuid.UUID
	From      *time.Time
	To        *time.Time
}

type ListIncidentsOptions

type ListIncidentsOptions struct {
	Limit   int32
	Cursor  *Cursor
	Filters ListFilters
}

type ListIncidentsPage

type ListIncidentsPage struct {
	Incidents  []Incident
	HasMore    bool
	NextCursor *string
	Applied    ListFilters
	Limit      int32
}

type ListIncidentsResponse

type ListIncidentsResponse struct {
	Limit          int32              `json:"limit"`
	HasMore        bool               `json:"has_more"`
	NextCursor     *string            `json:"next_cursor,omitempty"`
	AppliedFilters AppliedFilters     `json:"applied_filters"`
	Incidents      []IncidentResponse `json:"incidents"`
}

type Repository

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

func NewRepository

func NewRepository(dbExecutor db.DBTX, logger *zerolog.Logger) *Repository

func (*Repository) GetByIDAndUserID

func (r *Repository) GetByIDAndUserID(ctx context.Context, incidentID uuid.UUID, userID uuid.UUID) (Incident, error)

func (*Repository) ListByUserID

func (r *Repository) ListByUserID(ctx context.Context, userID uuid.UUID, opts ListIncidentsOptions) ([]Incident, bool, error)

type Service

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

func NewService

func NewService(repo *Repository) *Service

func (*Service) GetByIDAndUserID

func (s *Service) GetByIDAndUserID(ctx context.Context, incidentID uuid.UUID, userID uuid.UUID) (Incident, error)

func (*Service) ListByUserID

func (s *Service) ListByUserID(ctx context.Context, userID uuid.UUID, opts ListIncidentsOptions) (ListIncidentsPage, error)

Jump to

Keyboard shortcuts

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