mongo

package
v0.0.0-...-08a0563 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

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) Count

func (r *AlertRepo) Count() (int, error)

func (*AlertRepo) Create

func (r *AlertRepo) Create(alert *model.Alert) error

Create a new Alert in the repo.

func (*AlertRepo) Delete

func (r *AlertRepo) Delete(alertID uuid.UUID) error

Delete an Alert from the repo.

func (*AlertRepo) Find

func (r *AlertRepo) Find(id uuid.UUID) (model.Alert, error)

Find an Alert by its ID.

func (*AlertRepo) FindByFilter

func (r *AlertRepo) FindByFilter(roles, tags []string) ([]model.Alert, error)

FindByFilter returns alerts that match the given roles and tags.

func (*AlertRepo) Search

func (r *AlertRepo) Search(name, role, tag string) ([]model.Alert, error)

Search the Alerts in the repo by name regular expression and role/tag (combined with AND). Any parameter left blank will be ignored.

func (*AlertRepo) Update

func (r *AlertRepo) Update(alert model.Alert) error

Update an Alert in the repo.

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

type CheckRepo

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

CheckRepo acts as a repository of Checks in the database.

func (*CheckRepo) AllTags

func (r *CheckRepo) AllTags() ([]string, error)

AllTags returns all distinct tags used across all Checks.

func (*CheckRepo) Count

func (r *CheckRepo) Count() (int, error)

func (*CheckRepo) CountTags

func (r *CheckRepo) CountTags() (int, error)

func (*CheckRepo) Create

func (r *CheckRepo) Create(check *model.Check) error

Create a new Check in the repo.

func (*CheckRepo) Delete

func (r *CheckRepo) Delete(checkID uuid.UUID) error

Delete a Check from the repo.

func (*CheckRepo) Find

func (r *CheckRepo) Find(id uuid.UUID) (model.Check, error)

Find a Check by its ID.

func (*CheckRepo) ForRoles

func (r *CheckRepo) ForRoles(roles []string) ([]model.Check, error)

ForRoles returns all Checks for the given Roles.

func (*CheckRepo) OfTypes

func (r *CheckRepo) OfTypes(types []model.CheckType) ([]model.Check, error)

OfTypes returns all Checks for the given Types.

func (*CheckRepo) OfTypesForRoles

func (r *CheckRepo) OfTypesForRoles(types []model.CheckType, roles []string) ([]model.Check, error)

OfTypesForRoles returns all checks for the given Roles of the given Types.

func (*CheckRepo) Search

func (r *CheckRepo) Search(name, role, tag string) ([]model.Check, error)

Search the Checks in the repo by name regular expression and role/tag (combined with AND). Any parameter left blank will be ignored.

func (*CheckRepo) Update

func (r *CheckRepo) Update(check model.Check) error

Update a Check in the repo.

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

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).

func (*PeriodRepo) Search

func (r *PeriodRepo) Search(name, role, tag string) ([]model.Period, error)

Search the Periods in the repo by name regular expression and role/tag (combined with AND). Any parameter left blank will be ignored.

func (*PeriodRepo) Update

func (r *PeriodRepo) Update(period model.Period) error

Update an Period in the repo.

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.

func (*SubjectRepo) Update

func (r *SubjectRepo) Update(subject model.Subject) error

Update a Subject in the repo.

Jump to

Keyboard shortcuts

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