Documentation
¶
Index ¶
- func Routes(h *Handler) chi.Router
- type Cache
- type CreateMonitor
- type CreateMonitorRequest
- type CreateMonitorResponse
- type GetAllMonitorsResponse
- type GetMonitorResponse
- type Handler
- type Monitor
- type MonitorRecord
- type Repository
- func (r *Repository) Create(ctx context.Context, monitor CreateMonitor) (uuid.UUID, error)
- func (r *Repository) Get(ctx context.Context, userID, monitorID uuid.UUID) (Monitor, error)
- func (r *Repository) GetAll(ctx context.Context, userID uuid.UUID, limit int32, offset int32) ([]Monitor, error)
- func (r *Repository) GetByID(ctx context.Context, monitorID uuid.UUID) (Monitor, error)
- func (r *Repository) SetEnabled(ctx context.Context, userID, monitorID uuid.UUID, enabled bool) error
- type Service
- func (s *Service) CreateMonitor(ctx context.Context, data CreateMonitor) (uuid.UUID, error)
- func (s *Service) GetAllMonitors(ctx context.Context, userID uuid.UUID, limit int32, offset int32) ([]Monitor, error)
- func (s *Service) GetMonitor(ctx context.Context, userID uuid.UUID, monitorID uuid.UUID) (Monitor, error)
- func (s *Service) LoadMonitor(ctx context.Context, monitorID uuid.UUID) (Monitor, error)
- func (s *Service) ScheduleMonitor(ctx context.Context, mID uuid.UUID, intervalSec int32, op string)
- func (s *Service) UpdateMonitorStatus(ctx context.Context, userID, monitorID uuid.UUID, enable bool) (bool, error)
- type UpdateMonitorStatusRequest
- type UserService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
GetMonitor(ctx context.Context, id uuid.UUID) (Monitor, bool)
SetMonitor(ctx context.Context, m Monitor) error
Schedule(ctx context.Context, monitorID string, runAt time.Time) error
ClearIncident(ctx context.Context, monitorID uuid.UUID) error
DelMonitor(ctx context.Context, id uuid.UUID) error
DelStatus(ctx context.Context, monitorID uuid.UUID) error
DelSchedule(ctx context.Context, monitorID string) error
}
type CreateMonitor ¶
type CreateMonitorRequest ¶
type CreateMonitorRequest struct {
Url string `json:"url" validate:"required,url"`
AlertEmail string `json:"alert_email" validate:"email"`
IntervalSec int32 `json:"interval_sec" validate:"required,gte=60"`
TimeoutSec int32 `json:"timeout_sec" validate:"required,gte=120"`
LatencyThresholdMs *int32 `json:"latency_threshold_ms"`
ExpectedStatus *int32 `json:"expected_status"`
}
type CreateMonitorResponse ¶
type CreateMonitorResponse struct {
MonitorID string `json:"monitor_id"`
}
type GetAllMonitorsResponse ¶
type GetAllMonitorsResponse struct {
UserID string `json:"user_id"`
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
Monitors []GetMonitorResponse `json:"monitors"`
}
type GetMonitorResponse ¶
type GetMonitorResponse struct {
ID string `json:"id"`
Url string `json:"url"`
AlertEmail string `json:"alert_mail"`
IntervalSec int32 `json:"interval_sec"`
TimeoutSec int32 `json:"timeout_sec"`
LatencyThresholdMs *int32 `json:"latency_threshold_ms"`
ExpectedStatus *int32 `json:"expected_status"`
Enabled bool `json:"enabled"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) CreateMonitor ¶
func (h *Handler) CreateMonitor(w http.ResponseWriter, r *http.Request)
func (*Handler) GetAllMonitors ¶
func (h *Handler) GetAllMonitors(w http.ResponseWriter, r *http.Request)
/monitors?offset=3&limit=10
func (*Handler) GetMonitor ¶
func (h *Handler) GetMonitor(w http.ResponseWriter, r *http.Request)
func (*Handler) UpdateMonitorStatus ¶
func (h *Handler) UpdateMonitorStatus(w http.ResponseWriter, r *http.Request)
Patch : /monitors/{monitorID}
{
enable: false/true
}
type MonitorRecord ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(dbExecutor db.DBTX, logger *zerolog.Logger) *Repository
func (*Repository) Create ¶
func (r *Repository) Create(ctx context.Context, monitor CreateMonitor) (uuid.UUID, error)
func (*Repository) SetEnabled ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(monitorRepo *Repository, cache Cache, userSvc UserService, logger *zerolog.Logger) *Service
func (*Service) CreateMonitor ¶
func (*Service) GetAllMonitors ¶
func (*Service) GetMonitor ¶
func (*Service) LoadMonitor ¶
func (*Service) ScheduleMonitor ¶
type UpdateMonitorStatusRequest ¶
type UpdateMonitorStatusRequest struct {
Enable *bool `json:"enable" validate:"required"`
}
Click to show internal directories.
Click to hide internal directories.