fix odin syntax

This commit is contained in:
2026-02-15 11:17:12 -05:00
parent 677bbb4028
commit d8fdef2ca4
16 changed files with 1140 additions and 368 deletions

View File

@@ -0,0 +1,22 @@
// TODO: In order to use RocksDB's WAL replication helpers, we need to import the C++ library so we use this shim
/**
C++ shim implementation notes (the important bits)
In this rocksdb_shim.cc we'll need to use:
rocksdb::DB::Open(...)
db->GetLatestSequenceNumber()
db->GetUpdatesSince(seq, &iter)
from each TransactionLogIterator entry:
get WriteBatch and serialize via WriteBatch::Data()
apply via rocksdb::WriteBatch wb(data); db->Write(write_options, &wb);
Also we must configure WAL retention so the followers dont fall off the end. RocksDB warns the iterator can become invalid if WAL is cleared aggressively; typical controls are WAL TTL / size limit.
https://github.com/facebook/rocksdb/issues/1565
*/

View File

@@ -0,0 +1,54 @@
// In order to use RocksDB's WAL replication helpers, we need to import the C++ library so we use this shim
#pragma once
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct jormun_db jormun_db;
typedef struct jormun_wal_iter jormun_wal_iter;
// Open/close (so Odin never touches rocksdb_t directly)
jormun_db *jormun_db_open(const char *path, int create_if_missing, char **err);
void jormun_db_close(jormun_db *db);
// Basic ops (you can mirror what you already have)
void jormun_db_put(jormun_db *db,
const void *key, size_t keylen,
const void *val, size_t vallen,
char **err);
unsigned char *jormun_db_get(jormun_db *db,
const void *key, size_t keylen,
size_t *vallen,
char **err);
// caller frees with this:
void jormun_free(void *p);
// Replication primitives
uint64_t jormun_latest_sequence(jormun_db *db);
// Iterator: start at seq (inclusive-ish; RocksDB positions to batch containing seq or first after)
jormun_wal_iter *jormun_wal_iter_create(jormun_db *db, uint64_t seq, char **err);
void jormun_wal_iter_destroy(jormun_wal_iter *it);
// Next batch -> returns 1 if produced a batch, 0 if no more / not available
// You get a serialized “write batch” blob (rocksdb::WriteBatch::Data()) plus the batch start seq.
int jormun_wal_iter_next(jormun_wal_iter *it,
uint64_t *batch_start_seq,
unsigned char **out_data,
size_t *out_len,
char **err);
// Apply serialized writebatch blob on follower
void jormun_apply_writebatch(jormun_db *db,
const unsigned char *data, size_t len,
char **err);
#ifdef __cplusplus
}
#endif