monitor

package
v0.26.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEndpointIsDown   = errors.New("endpoint is down")
	ErrMonitorNotFound  = errors.New("monitor not found")
	ErrIncidentNotFound = errors.New("incident not found")
)
View Source
var (
	IncidentActionTypeCreated      = IncidentActionType{"created"}
	IncidentActionTypeResolved     = IncidentActionType{"resolved"}
	IncidentActionTypeAcknowledged = IncidentActionType{"acknowledged"}
)
View Source
var (
	RegionAfrica       = Region{"africa"}
	RegionEurope       = Region{"europe"}
	RegionNorthAmerica = Region{"north-america"}
	RegionSouthAmerica = Region{"south-america"}
	RegionMiddleEast   = Region{"middle-east"}
	RegionAsia         = Region{"asia"}
	RegionAustralia    = Region{"australia"}
	Regions            = []Region{
		RegionAfrica,
		RegionEurope,
		RegionNorthAmerica,
		RegionSouthAmerica,
		RegionMiddleEast,
		RegionAsia,
		RegionAustralia,
	}
)

Functions

This section is empty.

Types

type CheckResult

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

func NewCheckResult

func NewCheckResult(
	id domain.ID,
	statusCode *int16,
	region Region,
	checkedAt time.Time,
	responseTimeInMs int16,
) (*CheckResult, error)

func (*CheckResult) CheckedAt

func (c *CheckResult) CheckedAt() time.Time

func (*CheckResult) ID

func (c *CheckResult) ID() domain.ID

func (*CheckResult) IsEndpointDown

func (c *CheckResult) IsEndpointDown() bool

func (*CheckResult) Region

func (c *CheckResult) Region() Region

func (*CheckResult) ResponseTimeInMs

func (c *CheckResult) ResponseTimeInMs() int16

func (*CheckResult) StatusCode

func (c *CheckResult) StatusCode() *int16

type Incident

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

func NewIncident

func NewIncident(
	id,
	monitorID domain.ID,
	resolvedAt *time.Time,
	createdAt time.Time,
	checkedURL string,
	actions []IncidentAction,
	cause string,
	responseStatusCode *int16,
) (*Incident, error)

func (*Incident) Actions

func (i *Incident) Actions() []IncidentAction

func (*Incident) Cause

func (i *Incident) Cause() string

func (*Incident) CheckedURL

func (i *Incident) CheckedURL() string

func (*Incident) CreatedAt

func (i *Incident) CreatedAt() time.Time

func (*Incident) ID

func (i *Incident) ID() domain.ID

func (*Incident) IsResolved

func (i *Incident) IsResolved() bool

func (*Incident) MonitorID

func (i *Incident) MonitorID() domain.ID

func (*Incident) Resolve

func (i *Incident) Resolve()

func (*Incident) ResolvedAt

func (i *Incident) ResolvedAt() *time.Time

func (*Incident) ResponseStatusCode

func (i *Incident) ResponseStatusCode() *int16

type IncidentAction

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

func NewIncidentAction

func NewIncidentAction(
	id domain.ID,
	takenByUserWithID *domain.ID,
	at time.Time,
	description string,
	actionType IncidentActionType,
) (*IncidentAction, error)

func (*IncidentAction) ActionType

func (i *IncidentAction) ActionType() IncidentActionType

func (*IncidentAction) Description

func (i *IncidentAction) Description() string

func (*IncidentAction) Id

func (i *IncidentAction) Id() domain.ID

func (*IncidentAction) TakenAt

func (i *IncidentAction) TakenAt() time.Time

func (*IncidentAction) TakerUserID

func (i *IncidentAction) TakerUserID() *domain.ID

type IncidentActionType

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

func (IncidentActionType) String

func (t IncidentActionType) String() string

type IncidentRepository

type IncidentRepository interface {
	FindByID(ctx context.Context, id domain.ID) (*Incident, error)
	Create(ctx context.Context, incident *Incident) error
	Update(ctx context.Context, id domain.ID, fn func(incident *Incident) error) error
	AppendIncidentAction(ctx context.Context, incidentID domain.ID, incidentAction *IncidentAction) error
}

type Monitor

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

func NewMonitor

func NewMonitor(
	id domain.ID,
	endpointUrl string,
	accountID domain.ID,
	isEndpointUp,
	isPaused bool,
	incidents []*Incident,
	subscribers []*Subscriber,
	createdAt time.Time,
	checkInterval time.Duration,
	lastCheckedAt *time.Time,
) (*Monitor, error)

func (*Monitor) AccountID

func (m *Monitor) AccountID() domain.ID

func (*Monitor) CheckInterval

func (m *Monitor) CheckInterval() time.Duration

func (*Monitor) CheckResults

func (m *Monitor) CheckResults() []CheckResult

func (*Monitor) CreatedAt

func (m *Monitor) CreatedAt() time.Time

func (*Monitor) DownSince

func (m *Monitor) DownSince() *time.Time

func (*Monitor) Edit

func (m *Monitor) Edit(endpointUrl string, checkIntervalInSeconds time.Duration) error

func (*Monitor) EndpointUrl

func (m *Monitor) EndpointUrl() string

func (*Monitor) HasIncidentUnresolved

func (m *Monitor) HasIncidentUnresolved() bool

func (*Monitor) ID

func (m *Monitor) ID() domain.ID

func (*Monitor) IncidentUnresolved

func (m *Monitor) IncidentUnresolved() *Incident

func (*Monitor) Incidents

func (m *Monitor) Incidents() []*Incident

func (*Monitor) IsEndpointUp

func (m *Monitor) IsEndpointUp() bool

func (*Monitor) IsPaused

func (m *Monitor) IsPaused() bool

func (*Monitor) IsValid

func (m *Monitor) IsValid() bool

func (*Monitor) LastCheckedAt

func (m *Monitor) LastCheckedAt() *time.Time

func (*Monitor) MarkEndpointAsDown

func (m *Monitor) MarkEndpointAsDown()

func (*Monitor) MarkEndpointAsUp

func (m *Monitor) MarkEndpointAsUp()

func (*Monitor) Pause

func (m *Monitor) Pause()

func (*Monitor) SetEndpointCheckResult

func (m *Monitor) SetEndpointCheckResult(isUp bool)

func (*Monitor) Subscribers

func (m *Monitor) Subscribers() []*Subscriber

func (*Monitor) UnPause

func (m *Monitor) UnPause()

func (*Monitor) UpSince

func (m *Monitor) UpSince() *time.Time

type Region

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

func NewRegion

func NewRegion(value string) (Region, error)

func (Region) String

func (r Region) String() string

type Repository

type Repository interface {
	Delete(ctx context.Context, ID domain.ID) error
	Insert(ctx context.Context, monitor *Monitor) error
	FindByID(ctx context.Context, ID domain.ID) (*Monitor, error)
	Update(ctx context.Context, ID domain.ID, fn func(monitor *Monitor) error) error
	UpdateForCheck(ctx context.Context, fn func(foundMonitors []*Monitor) error) error
	SaveCheckResult(ctx context.Context, ID domain.ID, checkResult *CheckResult) error
}

type Subscriber

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

func NewSubscriber

func NewSubscriber(userID domain.ID) (*Subscriber, error)

func (*Subscriber) UserID

func (s *Subscriber) UserID() domain.ID

type URL

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

func NewURL

func NewURL(value string) (URL, error)

func (URL) IsEmpty

func (u URL) IsEmpty() bool

func (URL) String

func (u URL) String() string

Jump to

Keyboard shortcuts

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