Archetype: cpp_nats_changed_event.hpp.mustache
Entity-changed event type published by the notify pipeline. nats-eventing profile.
See the Template variable reference for the complete list of available variables and their semantics.
Template
The full template source. Edit here and re-tangle with
compass build --direct tangle_codegen_templates to regenerate
library/templates/cpp_nats_changed_event.hpp.mustache.
{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/cpp_messaging.org. Edit the org source. }}
{{{cpp_license}}}
{{#domain_entity}}
#ifndef ORES_{{component_include_upper}}_EVENTING_{{entity_singular_upper}}_CHANGED_EVENT_HPP
#define ORES_{{component_include_upper}}_EVENTING_{{entity_singular_upper}}_CHANGED_EVENT_HPP
#include <chrono>
#include <vector>
#include <string>
#include "ores.eventing.api/domain/event_traits.hpp"
namespace ores::{{component}}::eventing {
/**
* @brief Domain event indicating that {{entity_title_lower}} data has changed.
*
* Published when any {{entity_title_lower}} entity is created, updated, or
* deleted. Subscribers use the timestamp to query for changes since that point.
*/
struct {{entity_singular}}_changed_event final {
/**
* @brief The timestamp of when the change occurred (in UTC).
*/
std::chrono::system_clock::time_point timestamp;
{{#primary_key.is_text}}
/**
* @brief Changed {{entity_title_lower}} codes.
*/
std::vector<std::string> {{primary_key.column}}s;
{{/primary_key.is_text}}
{{#primary_key.is_uuid}}
/**
* @brief Changed {{entity_title_lower}} UUIDs (as strings).
*/
std::vector<std::string> {{entity_singular_short}}_ids;
{{/primary_key.is_uuid}}
/**
* @brief The tenant that owns the changed entity.
*/
std::string tenant_id;
};
}
namespace ores::eventing::domain {
/**
* @brief Event traits specialization for {{entity_singular}}_changed_event.
*/
template<>
struct event_traits<ores::{{component}}::eventing::{{entity_singular}}_changed_event> {
static constexpr std::string_view name =
"ores.{{component}}.{{entity_singular}}_changed";
};
}
#endif
{{/domain_entity}}
{{#entity}}
#ifndef ORES_{{component_include_upper}}_EVENTING_{{entity_singular_upper}}_CHANGED_EVENT_HPP
#define ORES_{{component_include_upper}}_EVENTING_{{entity_singular_upper}}_CHANGED_EVENT_HPP
#include <chrono>
#include <vector>
#include <string>
#include "ores.eventing.api/domain/event_traits.hpp"
namespace ores::{{component}}::eventing {
/**
* @brief Domain event indicating that {{entity_title_lower}} data has changed.
*
* Published when any {{entity_title_lower}} entity is created, updated, or
* deleted. Subscribers use the timestamp to query for changes since that point.
*/
struct {{entity_singular}}_changed_event final {
/**
* @brief The timestamp of when the change occurred (in UTC).
*/
std::chrono::system_clock::time_point timestamp;
{{#primary_key.is_text}}
/**
* @brief Changed {{entity_title_lower}} codes.
*/
std::vector<std::string> {{primary_key.column}}s;
{{/primary_key.is_text}}
{{^primary_key.is_text}}
/**
* @brief Changed {{entity_title_lower}} UUIDs (as strings).
*/
std::vector<std::string> {{entity_singular_short}}_ids;
{{/primary_key.is_text}}
/**
* @brief The tenant that owns the changed entity.
*/
std::string tenant_id;
};
}
namespace ores::eventing::domain {
/**
* @brief Event traits specialization for {{entity_singular}}_changed_event.
*/
template<>
struct event_traits<ores::{{component}}::eventing::{{entity_singular}}_changed_event> {
static constexpr std::string_view name =
"ores.{{component}}.{{entity_singular}}_changed";
};
}
#endif
{{/entity}}
See also
- Parent facet: C++ messaging templates
- Template variable reference