ecs_alert_init

Function ecs_alert_init 

Source
pub unsafe extern "C" fn ecs_alert_init(
    world: *mut ecs_world_t,
    desc: *const ecs_alert_desc_t,
) -> ecs_entity_t
Expand description

Create a new alert. An alert is a query that is evaluated periodically and creates alert instances for each entity that matches the query. Alerts can be used to automate detection of errors in an application.

Alerts are automatically cleared when a query is no longer true for an alert instance. At most one alert instance will be created per matched entity.

Alert instances have three components:

  • AlertInstance: contains the alert message for the instance
  • MetricSource: contains the entity that triggered the alert
  • MetricValue: contains how long the alert has been active

Alerts reuse components from the metrics addon so that alert instances can be tracked and discovered as metrics. Just like metrics, alert instances are created as children of the alert.

When an entity has active alerts, it will have the EcsAlertsActive component which contains a map with active alerts for the entity. This component will be automatically removed once all alerts are cleared for the entity.

@param world The world. @param desc Alert description. @return The alert entity.