ores.cpp.protocol.protocol_header
Request/response message types for the entity's NATS API. protocol profile. NATS messaging contract: request and response message structs used by the service layer for inter-component communication.
Model flags consumed by this template:
read_for_cache(bool, Flags) — emit aread_<entity_plural>_for_cache_request/responsepair: an unpaginated, tenant-scoped bulk read used to warm client-side caches. Requireshas_tenant_id.
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_protocol.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}}_MESSAGING_{{entity_singular_upper}}_PROTOCOL_HPP
#define ORES_{{component_include_upper}}_MESSAGING_{{entity_singular_upper}}_PROTOCOL_HPP
#include <cstdint>
#include <string>
#include <vector>
#include "ores.{{component_include}}/domain/{{entity_singular}}.hpp"
{{#has_parent_id}}
#include "ores.utility/domain/hierarchy.hpp"
{{/has_parent_id}}
<<paste:8A2E4C7F-1D9B-4E6A-9F3C-5B8D2A6E4C1F>>
namespace ores::{{component}}::messaging {
struct get_{{entity_plural}}_request {
using response_type = struct get_{{entity_plural}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.list";
std::uint32_t offset = 0;
std::uint32_t limit = 100;
{{#list_filter_column}}
std::string {{list_filter_column}};
{{/list_filter_column}}
{{#has_as_of_lookup}}
// Empty = current/latest. Note: when as_of is set, results are not
// paginated by offset/limit -- all matching rows are returned.
std::string as_of;
{{/has_as_of_lookup}}
};
struct get_{{entity_plural}}_response {
std::vector<ores::{{component}}::domain::{{entity_singular}}> {{entity_plural_short}};
int total_available_count = 0;
bool success = false;
std::string message;
};
struct save_{{entity_singular}}_request {
using response_type = struct save_{{entity_singular}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.save";
ores::{{component}}::domain::{{entity_singular}} data;
static save_{{entity_singular}}_request from(ores::{{component}}::domain::{{entity_singular}} v) {
return {.data = std::move(v)};
}
};
struct save_{{entity_singular}}_response {
bool success = false;
std::string message;
};
struct delete_{{entity_singular}}_request {
using response_type = struct delete_{{entity_singular}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.delete";
{{#primary_key.is_uuid}}
std::vector<std::string> ids;
{{/primary_key.is_uuid}}
{{^primary_key.is_uuid}}
{{#primary_key.columns}}
std::vector<std::string> {{column}}s;
{{/primary_key.columns}}
{{/primary_key.is_uuid}}
};
struct delete_{{entity_singular}}_response {
bool success = false;
std::string message;
};
struct get_{{entity_singular}}_history_request {
using response_type = struct get_{{entity_singular}}_history_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.history";
{{#primary_key.is_uuid}}
std::string {{primary_key.column}};
{{/primary_key.is_uuid}}
{{^primary_key.is_uuid}}
{{#primary_key.columns}}
std::string {{column}};
{{/primary_key.columns}}
{{/primary_key.is_uuid}}
};
struct get_{{entity_singular}}_history_response {
std::vector<ores::{{component}}::domain::{{entity_singular}}> history;
bool success = false;
std::string message;
};
{{#extra_list_requests}}
struct get_{{entity_plural}}_{{name_suffix}}_request {
using response_type = struct get_{{entity_plural}}_{{name_suffix}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.{{nats_suffix}}";
std::string {{filter_column}};
std::uint32_t offset = 0;
std::uint32_t limit = {{default_limit}};
};
struct get_{{entity_plural}}_{{name_suffix}}_response {
std::vector<ores::{{component}}::domain::{{entity_singular}}> {{entity_plural_short}};
int total_available_count = 0;
bool success = false;
std::string message;
};
{{/extra_list_requests}}
{{#has_parent_id}}
/**
* @brief Reads the {{entity_singular}} hierarchy rooted at, or containing,
* a given {{entity_singular}}.
*/
struct get_{{entity_singular}}_hierarchy_request {
using response_type = struct get_{{entity_singular}}_hierarchy_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.hierarchy";
std::string root_id;
bool from_root = false;
};
struct get_{{entity_singular}}_hierarchy_response {
bool success = false;
std::string message;
std::vector<ores::utility::domain::hierarchy_node> roots;
};
{{/has_parent_id}}
{{#read_for_cache}}
/**
* @brief Reads all active {{entity_plural}} for a tenant — used by
* client-side caches to warm up without multiple round-trips.
*/
struct read_{{entity_plural}}_for_cache_request {
using response_type = struct read_{{entity_plural}}_for_cache_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.read";
std::string tenant_id;
};
struct read_{{entity_plural}}_for_cache_response {
bool success = false;
std::string message;
std::vector<ores::{{component}}::domain::{{entity_singular}}> {{entity_plural_short}};
};
{{/read_for_cache}}
<<paste:2C4E8F1A-6B9D-4A3E-8F2C-7D1E5A9B3C6F>>
}
#endif
{{/domain_entity}}
{{#junction}}
#ifndef ORES_{{component_include_upper}}_MESSAGING_{{name_singular_upper}}_PROTOCOL_HPP
#define ORES_{{component_include_upper}}_MESSAGING_{{name_singular_upper}}_PROTOCOL_HPP
#include <cstdint>
#include <string>
#include <vector>
#include "ores.{{component_include}}/domain/{{name_singular}}.hpp"
namespace ores::{{component}}::messaging {
{{#left.list_by}}
struct get_{{name}}_by_{{left.column_short}}_request {
using response_type = struct get_{{name}}_by_{{left.column_short}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{name}}.list_by_{{left.column}}";
std::string {{left.column}};
std::uint32_t offset = 0;
std::uint32_t limit = 100;
};
struct get_{{name}}_by_{{left.column_short}}_response {
std::vector<ores::{{component}}::domain::{{name_singular}}> {{name}};
int total_available_count = 0;
bool success = false;
std::string message;
};
{{/left.list_by}}
{{#right.list_by}}
struct get_{{name}}_by_{{right.column_short}}_request {
using response_type = struct get_{{name}}_by_{{right.column_short}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{name}}.list_by_{{right.column}}";
std::string {{right.column}};
std::uint32_t offset = 0;
std::uint32_t limit = 100;
};
struct get_{{name}}_by_{{right.column_short}}_response {
std::vector<ores::{{component}}::domain::{{name_singular}}> {{name}};
int total_available_count = 0;
bool success = false;
std::string message;
};
{{/right.list_by}}
<<paste:5C3C5DBB-684A-4947-9A35-25D33ED7A222>>
}
#endif
{{/junction}}
{{#entity}}
#ifndef ORES_{{component_include_upper}}_MESSAGING_{{entity_singular_upper}}_PROTOCOL_HPP
#define ORES_{{component_include_upper}}_MESSAGING_{{entity_singular_upper}}_PROTOCOL_HPP
#include <cstdint>
#include <string>
#include <vector>
#include "ores.{{component_include}}/domain/{{entity_singular}}.hpp"
namespace ores::{{component}}::messaging {
struct get_{{entity_plural}}_request {
using response_type = struct get_{{entity_plural}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.list";
std::uint32_t offset = 0;
std::uint32_t limit = 100;
{{#list_filter_column}}
std::string {{list_filter_column}};
{{/list_filter_column}}
{{#has_as_of_lookup}}
// Empty = current/latest. Note: when as_of is set, results are not
// paginated by offset/limit -- all matching rows are returned.
std::string as_of;
{{/has_as_of_lookup}}
};
struct get_{{entity_plural}}_response {
std::vector<ores::{{component}}::domain::{{entity_singular}}> {{entity_plural_short}};
int total_available_count = 0;
bool success = false;
std::string message;
};
struct save_{{entity_singular}}_request {
using response_type = struct save_{{entity_singular}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.save";
ores::{{component}}::domain::{{entity_singular}} data;
static save_{{entity_singular}}_request from(ores::{{component}}::domain::{{entity_singular}} v) {
return {.data = std::move(v)};
}
};
struct save_{{entity_singular}}_response {
bool success = false;
std::string message;
};
struct delete_{{entity_singular}}_request {
using response_type = struct delete_{{entity_singular}}_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.delete";
{{#primary_key.is_text}}
std::vector<std::string> {{primary_key.column}}s;
{{/primary_key.is_text}}
{{^primary_key.is_text}}
std::vector<std::string> ids;
{{/primary_key.is_text}}
};
struct delete_{{entity_singular}}_response {
bool success = false;
std::string message;
};
struct get_{{entity_singular}}_history_request {
using response_type = struct get_{{entity_singular}}_history_response;
static constexpr std::string_view nats_subject =
"{{component}}.v1.{{entity_plural}}.history";
std::string {{primary_key.column}};
};
struct get_{{entity_singular}}_history_response {
std::vector<ores::{{component}}::domain::{{entity_singular}}> history;
bool success = false;
std::string message;
};
}
#endif
{{/entity}}
See also
- Parent facet: ores.cpp.protocol
- Template variable reference