feat(architecture): enforce lifecycle orchestration and layered component boundaries
This commit is contained in:
@@ -47,13 +47,17 @@ typedef struct {
|
||||
int64_t last_status_ms;
|
||||
} printer_runtime_status_t;
|
||||
|
||||
typedef uint32_t printer_status_poll_pause_token_t;
|
||||
|
||||
esp_err_t printer_protocol_init(void);
|
||||
esp_err_t printer_protocol_stop(uint32_t timeout_ms);
|
||||
|
||||
esp_err_t printer_protocol_connect(const char *target_name, uint32_t timeout_ms);
|
||||
void printer_protocol_disconnect(void);
|
||||
|
||||
void printer_protocol_get_runtime_status(printer_runtime_status_t *out_status);
|
||||
void printer_protocol_set_status_poll_paused(bool paused);
|
||||
printer_status_poll_pause_token_t printer_protocol_status_poll_pause_acquire(void);
|
||||
void printer_protocol_status_poll_pause_release(printer_status_poll_pause_token_t *token);
|
||||
|
||||
esp_err_t printer_protocol_submit_raster_job(const uint8_t *raster,
|
||||
size_t raster_len,
|
||||
|
||||
61
main/domain/include/runtime_diagnostics.h
Normal file
61
main/domain/include/runtime_diagnostics.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
RUNTIME_DIAG_COUNTER_LIFECYCLE_START_ATTEMPT = 0,
|
||||
RUNTIME_DIAG_COUNTER_LIFECYCLE_START_SUCCESS,
|
||||
RUNTIME_DIAG_COUNTER_LIFECYCLE_START_FAILED,
|
||||
RUNTIME_DIAG_COUNTER_LIFECYCLE_START_RETRY,
|
||||
RUNTIME_DIAG_COUNTER_LIFECYCLE_STOP_ATTEMPT,
|
||||
RUNTIME_DIAG_COUNTER_LIFECYCLE_STOP_SUCCESS,
|
||||
RUNTIME_DIAG_COUNTER_LIFECYCLE_STOP_FAILED,
|
||||
RUNTIME_DIAG_COUNTER_WIFI_CONNECT_SUCCESS,
|
||||
RUNTIME_DIAG_COUNTER_WIFI_CONNECT_FAILED,
|
||||
RUNTIME_DIAG_COUNTER_WIFI_CONNECT_TIMEOUT,
|
||||
RUNTIME_DIAG_COUNTER_PRINTER_JOB_SUBMITTED,
|
||||
RUNTIME_DIAG_COUNTER_PRINTER_JOB_SUCCESS,
|
||||
RUNTIME_DIAG_COUNTER_PRINTER_JOB_FAILED,
|
||||
RUNTIME_DIAG_COUNTER_PRINTER_JOB_CANCELED,
|
||||
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_ATTEMPT,
|
||||
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_SUCCESS,
|
||||
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_FAILED,
|
||||
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_TIMEOUT,
|
||||
RUNTIME_DIAG_COUNTER_REST_RESPONSES_TOTAL,
|
||||
RUNTIME_DIAG_COUNTER_REST_ERRORS_TOTAL,
|
||||
RUNTIME_DIAG_COUNTER_MAX,
|
||||
} runtime_diag_counter_t;
|
||||
|
||||
typedef enum {
|
||||
RUNTIME_DIAG_GAUGE_LIFECYCLE_STATE = 0,
|
||||
RUNTIME_DIAG_GAUGE_STATUS_POLL_PAUSE_DEPTH,
|
||||
RUNTIME_DIAG_GAUGE_PRINTER_QUEUE_DEPTH,
|
||||
RUNTIME_DIAG_GAUGE_MAX,
|
||||
} runtime_diag_gauge_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t counters[RUNTIME_DIAG_COUNTER_MAX];
|
||||
int32_t gauges[RUNTIME_DIAG_GAUGE_MAX];
|
||||
int64_t last_error_ms;
|
||||
esp_err_t last_error_code;
|
||||
char last_error_source[32];
|
||||
char last_error_message[96];
|
||||
} runtime_diag_snapshot_t;
|
||||
|
||||
void runtime_diag_counter_add(runtime_diag_counter_t counter, uint32_t delta);
|
||||
void runtime_diag_set_gauge(runtime_diag_gauge_t gauge, int32_t value);
|
||||
void runtime_diag_record_error(const char *source, esp_err_t code, const char *message);
|
||||
void runtime_diag_get_snapshot(runtime_diag_snapshot_t *out_snapshot);
|
||||
|
||||
const char *runtime_diag_counter_name(runtime_diag_counter_t counter);
|
||||
const char *runtime_diag_gauge_name(runtime_diag_gauge_t gauge);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
30
main/domain/include/runtime_policy.h
Normal file
30
main/domain/include/runtime_policy.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
uint32_t runtime_policy_wifi_connect_timeout_ms(void);
|
||||
|
||||
uint32_t runtime_policy_lifecycle_start_retry_count(void);
|
||||
uint32_t runtime_policy_lifecycle_retry_backoff_ms(uint32_t attempt);
|
||||
bool runtime_policy_is_retryable_error(esp_err_t err);
|
||||
|
||||
uint32_t runtime_policy_printer_control_lock_timeout_ms(void);
|
||||
uint32_t runtime_policy_printer_worker_queue_wait_ms(void);
|
||||
uint32_t runtime_policy_printer_queue_retry_delay_ms(void);
|
||||
uint32_t runtime_policy_printer_status_poll_interval_ms(void);
|
||||
uint32_t runtime_policy_printer_stop_timeout_ms(void);
|
||||
|
||||
uint32_t runtime_policy_rest_printer_connect_timeout_ms(void);
|
||||
uint32_t runtime_policy_rest_label_timeout_ms(void);
|
||||
uint32_t runtime_policy_rest_ota_timeout_ms(void);
|
||||
|
||||
uint32_t runtime_policy_image_generation_timeout_default_ms(void);
|
||||
uint32_t runtime_policy_image_generation_timeout_min_ms(void);
|
||||
uint32_t runtime_policy_image_generation_timeout_max_ms(void);
|
||||
|
||||
uint32_t runtime_policy_image_download_timeout_default_ms(void);
|
||||
uint32_t runtime_policy_image_download_timeout_min_ms(void);
|
||||
uint32_t runtime_policy_image_download_timeout_max_ms(void);
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
esp_err_t system_runtime_start(void);
|
||||
esp_err_t system_runtime_shutdown(void);
|
||||
esp_err_t system_runtime_bootstrap(void);
|
||||
|
||||
bool system_runtime_wifi_ready(void);
|
||||
|
||||
Reference in New Issue
Block a user