forked from lei.chen/myxce
feat: persistence hook functions wired to WAL write on AFTER_EVENT (P0-6)
Implements persist_job_hook_fun, persist_queue_hook_fun, and persist_worker_hook_fun — AFTER_EVENT hooks that write WAL entries whenever state mutations occur in the controller. - detail_to_wal_type() maps all 15 HOOK_DETAIL_* values to WAL types; unknown details return 0 and are silently skipped - HOOK_DETAIL_JOB_NEW uses the sync replication path (WAL_JOB_SUBMIT); all others use persist_wal_async - P0 payload: 4-byte detail value; full Cap'n Proto serialization in Task 15 - Hook signature matches hook_fn_t exactly: int fn(int type, int situation, int detail, void* cls, va_list ap) - Added <stdarg.h> to persist.h for va_list; added hook.h and xce/cluster_def.h includes to persist.c - 18 new unit tests in test_persist_hooks.c covering all 15 detail→WAL mappings, skip-on-unknown, and sequential LSN advancement
This commit is contained in:
parent
045d9e3287
commit
6f3b98c6b5
5 changed files with 500 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -145,3 +146,20 @@ int persist_checkpoint(persist_t* p);
|
|||
|
||||
/* Logging helper — never logs payload content (security invariant) */
|
||||
void persist_log_entry_metadata(const wal_entry_hdr_t* hdr);
|
||||
|
||||
/* ============================================================
|
||||
* AFTER_EVENT hook functions — registered by persist_start()
|
||||
*
|
||||
* Signature matches hook_fn_t: int fn(int type, int situation,
|
||||
* int detail, void* data, va_list ap)
|
||||
* cls/data points to the persist_t instance.
|
||||
*
|
||||
* P0: writes a minimal 4-byte payload (detail value) to the WAL.
|
||||
* Full Cap'n Proto serialization is wired in Task 15.
|
||||
* ============================================================ */
|
||||
int persist_job_hook_fun(int type, int situation, int detail,
|
||||
void* cls, va_list ap);
|
||||
int persist_queue_hook_fun(int type, int situation, int detail,
|
||||
void* cls, va_list ap);
|
||||
int persist_worker_hook_fun(int type, int situation, int detail,
|
||||
void* cls, va_list ap);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue