mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
format
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
#include "data_model/generated_models.h"
|
||||
#include "services/database/export_service.h"
|
||||
#include "services/enrichment/enrichment_service.h"
|
||||
|
||||
#include "services/logging/logger.h"
|
||||
|
||||
/**
|
||||
@@ -28,14 +27,15 @@
|
||||
*/
|
||||
class BiergartenPipelineOrchestrator {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs the orchestrator with injected pipeline dependencies.
|
||||
*
|
||||
* @param context_service Provides regional context for locations.
|
||||
* @param generator Implementation (Llama or Mock) for brewery/user generation.
|
||||
* @param exporter Database backend for persisting generated records.
|
||||
* @param application_options CLI configuration and paths.
|
||||
*/
|
||||
/**
|
||||
* @brief Constructs the orchestrator with injected pipeline dependencies.
|
||||
*
|
||||
* @param context_service Provides regional context for locations.
|
||||
* @param generator Implementation (Llama or Mock) for brewery/user
|
||||
* generation.
|
||||
* @param exporter Database backend for persisting generated records.
|
||||
* @param application_options CLI configuration and paths.
|
||||
*/
|
||||
BiergartenPipelineOrchestrator(
|
||||
std::shared_ptr<ILogger> logger,
|
||||
std::unique_ptr<IEnrichmentService> context_service,
|
||||
@@ -52,10 +52,11 @@ class BiergartenPipelineOrchestrator {
|
||||
* 3. Generate brewery data for sampled cities
|
||||
*
|
||||
* @note STRUCTURAL CONCURRENCY REQUIREMENT:
|
||||
* When transitioned to a multithreaded design, this method MUST structurally
|
||||
* enforce that all deployed worker threads are joined before returning (e.g.
|
||||
* by using std::jthread or a structured concurrency primitive). This ensures
|
||||
* workers do not attempt to log to a closed channel during application teardown.
|
||||
* When transitioned to a multithreaded design, this method MUST
|
||||
* structurally enforce that all deployed worker threads are joined before
|
||||
* returning (e.g. by using std::jthread or a structured concurrency
|
||||
* primitive). This ensures workers do not attempt to log to a closed
|
||||
* channel during application teardown.
|
||||
*
|
||||
* @return true if successful, false if not
|
||||
*/
|
||||
@@ -71,11 +72,11 @@ class BiergartenPipelineOrchestrator {
|
||||
/// @brief Generator dependency selected in the composition root.
|
||||
std::unique_ptr<DataGenerator> generator_;
|
||||
|
||||
/// @brief Storage backend for generated brewery records.
|
||||
std::unique_ptr<IExportService> exporter_;
|
||||
/// @brief Storage backend for generated brewery records.
|
||||
std::unique_ptr<IExportService> exporter_;
|
||||
|
||||
/// @brief CLI configuration: paths, model settings, generation parameters.
|
||||
ApplicationOptions application_options_;
|
||||
/// @brief CLI configuration: paths, model settings, generation parameters.
|
||||
ApplicationOptions application_options_;
|
||||
|
||||
/**
|
||||
* @brief Load locations from JSON and sample cities.
|
||||
@@ -95,9 +96,9 @@ class BiergartenPipelineOrchestrator {
|
||||
* @brief Generate users grounded in sampled names and personas for
|
||||
* enriched cities.
|
||||
*
|
||||
* Loads personas.json / forenames-by-country.json / surnames-by-country.json
|
||||
* itself, mirroring how QueryCitiesWithCountries() owns its own
|
||||
* locations.json load.
|
||||
* Loads personas.json / forenames-by-country.json /
|
||||
* surnames-by-country.json itself, mirroring how QueryCitiesWithCountries()
|
||||
* owns its own locations.json load.
|
||||
*
|
||||
* @param cities Span of enriched city data.
|
||||
*/
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
|
||||
/**
|
||||
* @file bounded_channel.h
|
||||
* @brief Thread-safe, bounded multi-producer/multi-consumer synchronous channel.
|
||||
* @brief Thread-safe, bounded multi-producer/multi-consumer synchronous
|
||||
* channel.
|
||||
*
|
||||
* Intent: Enables asynchronous inter-thread communication with backpressure.
|
||||
* Models a synchronous channel where producers/consumers block on capacity limits.
|
||||
* Models a synchronous channel where producers/consumers block on capacity
|
||||
* limits.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,8 +57,7 @@ class MockGenerator final : public DataGenerator {
|
||||
* @return Deterministic hash value.
|
||||
*/
|
||||
static size_t DeterministicHash(const Location& location,
|
||||
const UserPersona& persona,
|
||||
const Name& name);
|
||||
const UserPersona& persona, const Name& name);
|
||||
|
||||
// Hash stride constants for deterministic distribution across fixed-size
|
||||
// arrays. These coprime strides spread hash values uniformly without
|
||||
@@ -142,7 +141,8 @@ class MockGenerator final : public DataGenerator {
|
||||
"Visits breweries for the stories, stays for the flagship pours.",
|
||||
"Craft beer fan mapping tasting notes and favorite brew routes.",
|
||||
"Always ready to trade recommendations for underrated local breweries.",
|
||||
"Keeping a running list of must-try collab releases and tap takeovers."};
|
||||
"Keeping a running list of must-try collab releases and tap "
|
||||
"takeovers."};
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_MOCK_GENERATOR_H_
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
/**
|
||||
* @file data_model/generated_models.h
|
||||
* @brief Generated output models from the pipeline: brewery/user results, enriched data,
|
||||
* and complete generation results.
|
||||
* @brief Generated output models from the pipeline: brewery/user results,
|
||||
* enriched data, and complete generation results.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -148,8 +148,6 @@ struct GeneratorOptions {
|
||||
/// @brief Use mocked generator instead of actual LLM inference.
|
||||
bool use_mocked = false;
|
||||
|
||||
|
||||
|
||||
/// @brief Specific sampling parameters for this generator.
|
||||
/// If nullopt, the application should use global defaults.
|
||||
std::optional<SamplingOptions> sampling;
|
||||
@@ -186,7 +184,7 @@ struct ApplicationOptions {
|
||||
// Function Declarations
|
||||
// ============================================================================
|
||||
|
||||
std::optional<ApplicationOptions> ParseArguments(const int argc, char** argv,
|
||||
std::shared_ptr<ILogger> logger = nullptr);
|
||||
std::optional<ApplicationOptions> ParseArguments(
|
||||
const int argc, char** argv, std::shared_ptr<ILogger> logger = nullptr);
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_MODEL_MODELS_H_
|
||||
|
||||
@@ -25,11 +25,10 @@
|
||||
*/
|
||||
class NamesByCountry {
|
||||
public:
|
||||
NamesByCountry(
|
||||
std::unordered_map<std::string, std::vector<ForenameEntry>>
|
||||
forenames_by_country,
|
||||
std::unordered_map<std::string, std::vector<std::string>>
|
||||
surnames_by_country);
|
||||
NamesByCountry(std::unordered_map<std::string, std::vector<ForenameEntry>>
|
||||
forenames_by_country,
|
||||
std::unordered_map<std::string, std::vector<std::string>>
|
||||
surnames_by_country);
|
||||
|
||||
/**
|
||||
* @brief Samples a first/last name pair for the given country.
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "data_model/models.h"
|
||||
#include "../datetime/date_time_provider.h"
|
||||
#include "data_model/models.h"
|
||||
#include "export_service.h"
|
||||
#include "sqlite_export_service_helpers.h"
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ enum class LogLevel {
|
||||
* pipeline that emitted it.
|
||||
*/
|
||||
enum class PipelinePhase {
|
||||
Startup, ///< Initialization and validation.
|
||||
Enrichment, ///< Location/context enrichment (e.g. Wikipedia lookups).
|
||||
UserGeneration, ///< User profile generation.
|
||||
Startup, ///< Initialization and validation.
|
||||
Enrichment, ///< Location/context enrichment (e.g. Wikipedia lookups).
|
||||
UserGeneration, ///< User profile generation.
|
||||
BreweryAndBeerGeneration, ///< Brewery and beer data generation.
|
||||
CheckinGeneration, ///< Checkin (visit) record generation.
|
||||
RatingGeneration, ///< Rating and review generation.
|
||||
@@ -46,7 +46,8 @@ enum class PipelinePhase {
|
||||
|
||||
/**
|
||||
* @struct LogDTO
|
||||
* @brief User-provided subset of log fields. Used to capture call-site info transparently.
|
||||
* @brief User-provided subset of log fields. Used to capture call-site info
|
||||
* transparently.
|
||||
*/
|
||||
struct LogDTO {
|
||||
LogLevel level;
|
||||
@@ -74,7 +75,6 @@ struct LogEntry {
|
||||
/// @brief Thread responsible for emitting the log.
|
||||
std::thread::id thread_id{};
|
||||
|
||||
|
||||
/// @brief Severity level of this entry.
|
||||
LogLevel level;
|
||||
|
||||
@@ -83,7 +83,6 @@ struct LogEntry {
|
||||
|
||||
/// @brief Log message text.
|
||||
std::string message;
|
||||
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_ENTRY_H_
|
||||
|
||||
@@ -39,7 +39,8 @@ class ILogger {
|
||||
*/
|
||||
void Log(LogDTO payload,
|
||||
std::source_location origin = std::source_location::current(),
|
||||
std::chrono::system_clock::time_point timestamp = std::chrono::system_clock::now(),
|
||||
std::chrono::system_clock::time_point timestamp =
|
||||
std::chrono::system_clock::now(),
|
||||
std::thread::id thread_id = std::this_thread::get_id()) {
|
||||
LogEntry entry;
|
||||
entry.timestamp = timestamp;
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
/**
|
||||
* @file web_client/http_web_client.h
|
||||
* @brief cpp-httplib implementation of the WebClient interface.
|
||||
*/
|
||||
* @file web_client/http_web_client.h
|
||||
* @brief cpp-httplib implementation of the WebClient interface.
|
||||
*/
|
||||
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_WEB_CLIENT_HTTP_WEB_CLIENT_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_WEB_CLIENT_HTTP_WEB_CLIENT_H_
|
||||
|
||||
|
||||
#include "web_client/web_client.h"
|
||||
#include "services/logging/logger.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "services/logging/logger.h"
|
||||
#include "web_client/web_client.h"
|
||||
|
||||
/**
|
||||
* @brief WebClient implementation backed by cpp-httplib.
|
||||
*
|
||||
@@ -26,7 +25,7 @@
|
||||
* bound to a single origin at construction time.
|
||||
*/
|
||||
class HttpWebClient final : public WebClient {
|
||||
public:
|
||||
public:
|
||||
explicit HttpWebClient(std::shared_ptr<ILogger> logger)
|
||||
: logger_(std::move(logger)) {}
|
||||
~HttpWebClient() override = default;
|
||||
@@ -34,7 +33,8 @@ public:
|
||||
/**
|
||||
* @brief Executes a blocking HTTP/HTTPS GET request against a full URL.
|
||||
*
|
||||
* @param url Fully-qualified URL, e.g. "https://en.wikipedia.org/api/rest_v1/page/summary/Berlin"
|
||||
* @param url Fully-qualified URL, e.g.
|
||||
* "https://en.wikipedia.org/api/rest_v1/page/summary/Berlin"
|
||||
* @return Response body on HTTP 2xx; throws std::runtime_error otherwise.
|
||||
*/
|
||||
std::string Get(const std::string& url) override;
|
||||
@@ -52,5 +52,4 @@ public:
|
||||
std::shared_ptr<ILogger> logger_;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user