55 lines
1.7 KiB
C
55 lines
1.7 KiB
C
// 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
|