Documentation ¶
Index ¶
Constants ¶
const (
MethodWorst = "worst"
)
const (
WatcherCollectionName = "default_entities"
)
WatcherCollectionName is where we store watchers
Variables ¶
This section is empty.
Functions ¶
func DefaultCollection ¶
func DefaultCollection(session *mgo.Session) mongo.Collection
Types ¶
type Adapter ¶
type Adapter interface { // Insert a watcher Insert(watcher Watcher) error // GetAll gets all watchers from database GetAll(watchers *[]Watcher) error // GetAllValidWatchers gets all valid and enabled watchers from database GetAllValidWatchers(watchers *[]Watcher) error // GetAllValidWatchersID gets all valid and enabled watchers ids from database GetAllValidWatchersID() ([]string, error) // GetByID finds the watcher by its entity id GetByID(id string, watchers *Watcher) error // GetEntities gets the entities watched by the watcher GetEntities(watcher Watcher, entities *[]types.Entity) error // Get gets the watchers accordingly to the filter Get(filter map[string]interface{}, watchers *[]Watcher) error // GetWatchersWithDependencies gets all the watchers and their respective active dependencies entities GetWatchersWithDependencies(idList []string) ([]WatcherWithDependencies, error) }
func NewAdapter ¶
func NewAdapter(collection mongo.Collection, safeBulk bulk.Bulk, entitiesCollectionName string) Adapter
NewAdapter gives the correct mongo watcher adapter.
type AmqpChannelPublisher ¶
type AmqpChannelPublisher interface { // Publish sends an amqp.Publishing from the client to an exchange on the server. Publish(exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error }
AmqpChannelPublisher is an interface that represents a non-consumable AMQP channel. This interface is implemented by amqp.Channel. It should be used in services that only publish to amqp, in order to be able to test them easily by mocking this interface.
type Service ¶
type Service interface { // Insert a watcher Insert(watcher Watcher) error // GetAll gets all watchers from database GetAll(watchers *[]Watcher) error // GetAllValidWatchers gets all valid and enabled watchers from database GetAllValidWatchers(watchers *[]Watcher) error // GetWatcherByID finds the watcher by its entity id. GetByID(id string, watcher *Watcher) error // GetWatcherEntities gets the entities watched by the watcher GetEntities(watcher Watcher, entities *[]types.Entity) error // Process updates the watchers impacted by provided event and alarmChange Process(ctx context.Context, event *types.Event, alarmChange types.AlarmChange) error // ProcessResolvedAlarms updates the watchers impacted by the resolution of provided alarms ProcessResolvedAlarms(ctx context.Context, alarms []types.AlarmWithEntity) // ProcessUpdateWatcherEvent updates the watchers impacted by provided updatewatcher event ProcessUpdateWatcherEvent(ctx context.Context, event *types.Event) error // ComputeAllWatchers recompute all valid watchers ComputeAllWatchers(ctx context.Context) error }
Service allows you to manipulate watchers in database.
type StateCounts ¶
StateCounts is a struct containing the number of alarms in each state that impact a watcher.
type TemplateData ¶
type TemplateData struct { Alarms int State StateCounts Acknowledged int NotAcknowledged int }
TemplateData is a struct containing various values that can be used in the watchers output templates.
type Watcher ¶
type Watcher struct { types.Entity `bson:",inline"` // inherits from entity Entities pattern.EntityPatternList `bson:"entities"` State map[string]interface{} `bson:"state"` OutputTemplate string `bson:"output_template"` }
Watcher is a structure representing a watcher type entity document.