Documentation ¶
Index ¶
- func InitConnection(host, db, user, pass string) (model.AppContextFactory, error)
- type AlertRepo
- func (r *AlertRepo) Count() (int, error)
- func (r *AlertRepo) Create(alert *model.Alert) error
- func (r *AlertRepo) Delete(alertID uuid.UUID) error
- func (r *AlertRepo) Find(id uuid.UUID) (model.Alert, error)
- func (r *AlertRepo) FindByFilter(roles, tags []string) ([]model.Alert, error)
- func (r *AlertRepo) Search(name, role, tag string) ([]model.Alert, error)
- func (r *AlertRepo) Update(alert model.Alert) error
- type AppContext
- func (c *AppContext) AlertRepo() model.AlertRepo
- func (c *AppContext) CheckConnection() error
- func (c *AppContext) CheckRepo() model.CheckRepo
- func (c *AppContext) CheckResultRepo() model.CheckResultRepo
- func (c *AppContext) CheckStateRepo() model.CheckStateRepo
- func (c *AppContext) Close() error
- func (c *AppContext) DropDatabase() error
- func (c *AppContext) PeriodRepo() model.PeriodRepo
- func (c *AppContext) RoleRepo() model.RoleRepo
- func (c *AppContext) SubjectRepo() model.SubjectRepo
- func (c *AppContext) TagRepo() model.TagRepo
- type AppContextFactory
- type CheckRepo
- func (r *CheckRepo) AllTags() ([]string, error)
- func (r *CheckRepo) Count() (int, error)
- func (r *CheckRepo) CountTags() (int, error)
- func (r *CheckRepo) Create(check *model.Check) error
- func (r *CheckRepo) Delete(checkID uuid.UUID) error
- func (r *CheckRepo) Find(id uuid.UUID) (model.Check, error)
- func (r *CheckRepo) ForRoles(roles []string) ([]model.Check, error)
- func (r *CheckRepo) OfTypes(types []model.CheckType) ([]model.Check, error)
- func (r *CheckRepo) OfTypesForRoles(types []model.CheckType, roles []string) ([]model.Check, error)
- func (r *CheckRepo) Search(name, role, tag string) ([]model.Check, error)
- func (r *CheckRepo) Update(check model.Check) error
- type CheckResultRepo
- func (r *CheckResultRepo) Count() (int, error)
- func (r *CheckResultRepo) Create(check *model.CheckResult) error
- func (r *CheckResultRepo) DeleteByCheck(checkID uuid.UUID) error
- func (r *CheckResultRepo) DeleteBySubject(subjectID uuid.UUID) error
- func (r *CheckResultRepo) DeleteBySubjectCheck(id model.SubjectCheckID) error
- type CheckStateRepo
- func (r *CheckStateRepo) CoordinatorWorkload() (model.CoordinatorLoad, error)
- func (r *CheckStateRepo) Count() (int, error)
- func (r *CheckStateRepo) CountInRolesByStatus(roles []string) (model.StatusSummary, error)
- func (r *CheckStateRepo) DeleteByCheck(checkID uuid.UUID) error
- func (r *CheckStateRepo) DeleteBySubject(subjectID uuid.UUID) error
- func (r *CheckStateRepo) DeleteBySubjectCheck(id model.SubjectCheckID) error
- func (r *CheckStateRepo) Find(id model.SubjectCheckID) (model.CheckState, error)
- func (r *CheckStateRepo) ForOwner(owner uuid.UUID) ([]model.CheckState, error)
- func (r *CheckStateRepo) ForTypes(types []model.CheckType) ([]model.CheckState, error)
- func (r *CheckStateRepo) InStatusRoles(statuses []model.CheckStatus, roles []string) ([]model.CheckState, error)
- func (r *CheckStateRepo) Upsert(check model.CheckState) error
- type PeriodRepo
- func (r *PeriodRepo) Count() (int, error)
- func (r *PeriodRepo) Create(period *model.Period) error
- func (r *PeriodRepo) Delete(periodID uuid.UUID) error
- func (r *PeriodRepo) Find(id uuid.UUID) (model.Period, error)
- func (r *PeriodRepo) FindByType(types []model.PeriodType) ([]model.Period, error)
- func (r *PeriodRepo) FindForSubject(subject model.Subject, types []model.PeriodType) ([]model.Period, error)
- func (r *PeriodRepo) FindForSubjectChecks(subject model.Subject, tags []string, types []model.PeriodType) ([]model.Period, error)
- func (r *PeriodRepo) Search(name, role, tag string) ([]model.Period, error)
- func (r *PeriodRepo) Update(period model.Period) error
- type SubjectRepo
- func (r *SubjectRepo) AllRoles() ([]string, error)
- func (r *SubjectRepo) ByRoles(roles []string) ([]model.Subject, error)
- func (r *SubjectRepo) Count() (int, error)
- func (r *SubjectRepo) CountRoles() (int, error)
- func (r *SubjectRepo) Create(subject *model.Subject) error
- func (r *SubjectRepo) Delete(subjectID uuid.UUID) error
- func (r *SubjectRepo) Find(id uuid.UUID) (model.Subject, error)
- func (r *SubjectRepo) Named(name string) (model.Subject, error)
- func (r *SubjectRepo) Search(name, role string) ([]model.Subject, error)
- func (r *SubjectRepo) SharedRoles(role string) ([]string, error)
- func (r *SubjectRepo) Update(subject model.Subject) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitConnection ¶
func InitConnection(host, db, user, pass string) (model.AppContextFactory, error)
InitConnection sets up the MongoDB database context factory.
Types ¶
type AlertRepo ¶
type AlertRepo struct {
// contains filtered or unexported fields
}
AlertRepo acts as a repository of Alerts in the database.
func (*AlertRepo) FindByFilter ¶
FindByFilter returns alerts that match the given roles and tags.
type AppContext ¶
type AppContext struct { DB *mgo.Database // contains filtered or unexported fields }
AppContext serves as a repository factory for the current session.
func (*AppContext) AlertRepo ¶
func (c *AppContext) AlertRepo() model.AlertRepo
AlertRepo returns a pointer to an AlertRepo in the current context.
func (*AppContext) CheckConnection ¶
func (c *AppContext) CheckConnection() error
CheckConnection with the database server.
func (*AppContext) CheckRepo ¶
func (c *AppContext) CheckRepo() model.CheckRepo
CheckRepo returns a pointer to a CheckRepo in the current context.
func (*AppContext) CheckResultRepo ¶
func (c *AppContext) CheckResultRepo() model.CheckResultRepo
CheckResultRepo returns a pointer to a CheckResultRepo in the current context.
func (*AppContext) CheckStateRepo ¶
func (c *AppContext) CheckStateRepo() model.CheckStateRepo
CheckStateRepo returns a pointer to a CheckStateRepo in the current context.
func (*AppContext) Close ¶
func (c *AppContext) Close() error
Close the DB session associated with this context.
func (*AppContext) DropDatabase ¶
func (c *AppContext) DropDatabase() error
DropDatabase drops the current Mongo database.
func (*AppContext) PeriodRepo ¶
func (c *AppContext) PeriodRepo() model.PeriodRepo
PeriodRepo returns a pointer to a PeriodRepo in the current context.
func (*AppContext) RoleRepo ¶
func (c *AppContext) RoleRepo() model.RoleRepo
RoleRepo returns a pointer to a RoleRepo in the current context.
func (*AppContext) SubjectRepo ¶
func (c *AppContext) SubjectRepo() model.SubjectRepo
SubjectRepo returns a pointer to a SubjectRepo in the current context.
func (*AppContext) TagRepo ¶
func (c *AppContext) TagRepo() model.TagRepo
TagRepo returns a pointer to a TagRepo in the current context.
type AppContextFactory ¶
type AppContextFactory struct {
// contains filtered or unexported fields
}
func (AppContextFactory) Close ¶
func (f AppContextFactory) Close() error
func (AppContextFactory) Get ¶
func (f AppContextFactory) Get() (model.AppContext, error)
type CheckRepo ¶
type CheckRepo struct {
// contains filtered or unexported fields
}
CheckRepo acts as a repository of Checks in the database.
func (*CheckRepo) OfTypesForRoles ¶
OfTypesForRoles returns all checks for the given Roles of the given Types.
type CheckResultRepo ¶
type CheckResultRepo struct {
// contains filtered or unexported fields
}
CheckResultRepo acts as a repository of CheckResults in the database.
func (*CheckResultRepo) Count ¶
func (r *CheckResultRepo) Count() (int, error)
func (*CheckResultRepo) Create ¶
func (r *CheckResultRepo) Create(check *model.CheckResult) error
Create a new CheckResult in the repo.
func (*CheckResultRepo) DeleteByCheck ¶
func (r *CheckResultRepo) DeleteByCheck(checkID uuid.UUID) error
DeleteByCheck deletes all check results for a Check. Used for cleanup after deleting a Check.
func (*CheckResultRepo) DeleteBySubject ¶
func (r *CheckResultRepo) DeleteBySubject(subjectID uuid.UUID) error
DeleteBySubject deletes all check results for a Subject. Used for cleanup after deleting a Subject.
func (*CheckResultRepo) DeleteBySubjectCheck ¶
func (r *CheckResultRepo) DeleteBySubjectCheck(id model.SubjectCheckID) error
DeleteBySubjectCheck deletes all check results for a given subject and check. Used for cleanup after removing a role from a subject.
type CheckStateRepo ¶
type CheckStateRepo struct {
// contains filtered or unexported fields
}
CheckStateRepo acts as a repository of CheckStates in the database.
func (*CheckStateRepo) CoordinatorWorkload ¶
func (r *CheckStateRepo) CoordinatorWorkload() (model.CoordinatorLoad, error)
CoordinatorWorkload gets the number of checks owned by each coordinator.
func (*CheckStateRepo) Count ¶
func (r *CheckStateRepo) Count() (int, error)
func (*CheckStateRepo) CountInRolesByStatus ¶
func (r *CheckStateRepo) CountInRolesByStatus(roles []string) (model.StatusSummary, error)
CountInRolesByStatus returns the count of distinct Subjects for the given role, by status.
func (*CheckStateRepo) DeleteByCheck ¶
func (r *CheckStateRepo) DeleteByCheck(checkID uuid.UUID) error
DeleteByCheck deletes all check states for a Check. Used for cleanup after deleting a Check.
func (*CheckStateRepo) DeleteBySubject ¶
func (r *CheckStateRepo) DeleteBySubject(subjectID uuid.UUID) error
DeleteBySubject deletes all check states for a Subject. Used for cleanup after deleting a Subject.
func (*CheckStateRepo) DeleteBySubjectCheck ¶
func (r *CheckStateRepo) DeleteBySubjectCheck(id model.SubjectCheckID) error
DeleteBySubjectCheck deletes the check state for a given subject and check. Used for cleanup after removing a role from a subject.
func (*CheckStateRepo) Find ¶
func (r *CheckStateRepo) Find(id model.SubjectCheckID) (model.CheckState, error)
Find a CheckState by its ID.
func (*CheckStateRepo) ForOwner ¶
func (r *CheckStateRepo) ForOwner(owner uuid.UUID) ([]model.CheckState, error)
ForOwner returns all CheckStates owned by a given coordinator.
func (*CheckStateRepo) ForTypes ¶
func (r *CheckStateRepo) ForTypes(types []model.CheckType) ([]model.CheckState, error)
ForTypes returns all CheckStates of a given .
func (*CheckStateRepo) InStatusRoles ¶
func (r *CheckStateRepo) InStatusRoles(statuses []model.CheckStatus, roles []string) ([]model.CheckState, error)
InStatus returns all CheckStates for the given statuses and roles.
func (*CheckStateRepo) Upsert ¶
func (r *CheckStateRepo) Upsert(check model.CheckState) error
Upsert a CheckState in the repo.
type PeriodRepo ¶
type PeriodRepo struct {
// contains filtered or unexported fields
}
PeriodRepo acts as a repository of Periods in the database.
func (*PeriodRepo) Count ¶
func (r *PeriodRepo) Count() (int, error)
func (*PeriodRepo) Create ¶
func (r *PeriodRepo) Create(period *model.Period) error
Create a new Period in the repo.
func (*PeriodRepo) Delete ¶
func (r *PeriodRepo) Delete(periodID uuid.UUID) error
Delete an Period from the repo.
func (*PeriodRepo) Find ¶
func (r *PeriodRepo) Find(id uuid.UUID) (model.Period, error)
Find an Period by its ID.
func (*PeriodRepo) FindByType ¶
func (r *PeriodRepo) FindByType(types []model.PeriodType) ([]model.Period, error)
FindByType returns all active periods for the given types (or all types if no types given).
func (*PeriodRepo) FindForSubject ¶
func (r *PeriodRepo) FindForSubject(subject model.Subject, types []model.PeriodType) ([]model.Period, error)
FindForSubject returns all active Periods that affect a subject by roles or ID for the given types (or all types if no types given).
func (*PeriodRepo) FindForSubjectChecks ¶
func (r *PeriodRepo) FindForSubjectChecks(subject model.Subject, tags []string, types []model.PeriodType) ([]model.Period, error)
FindForSubjectChecks returns all active Periods that affect a subject by roles or ID for the given tags and types (or all types if no types given).
type SubjectRepo ¶
type SubjectRepo struct {
// contains filtered or unexported fields
}
SubjectRepo acts as a repository of Subjects in the database.
func (*SubjectRepo) AllRoles ¶
func (r *SubjectRepo) AllRoles() ([]string, error)
AllRoles returns all distinct roles used across all Subjects.
func (*SubjectRepo) ByRoles ¶
func (r *SubjectRepo) ByRoles(roles []string) ([]model.Subject, error)
ByRoles looks up all subjects with any of the given roles.
func (*SubjectRepo) Count ¶
func (r *SubjectRepo) Count() (int, error)
func (*SubjectRepo) CountRoles ¶
func (r *SubjectRepo) CountRoles() (int, error)
func (*SubjectRepo) Create ¶
func (r *SubjectRepo) Create(subject *model.Subject) error
Create a new Subject in the repo.
func (*SubjectRepo) Delete ¶
func (r *SubjectRepo) Delete(subjectID uuid.UUID) error
Delete a Subject from the repo.
func (*SubjectRepo) Find ¶
func (r *SubjectRepo) Find(id uuid.UUID) (model.Subject, error)
Find a Subject by its ID.
func (*SubjectRepo) Named ¶
func (r *SubjectRepo) Named(name string) (model.Subject, error)
ByName a Subject retrieve.
func (*SubjectRepo) Search ¶
func (r *SubjectRepo) Search(name, role string) ([]model.Subject, error)
Search the Subjects in the repo by name regular expression and role (combined with AND).
func (*SubjectRepo) SharedRoles ¶
func (r *SubjectRepo) SharedRoles(role string) ([]string, error)
SharedRoles returns all distinct roles used across all Subjects which also have the given role.