amduat-api/src/amduatd_fed_cursor.h
Carl Niklas Rydberg e54a9009a6 Add GET /v1/space/mounts/resolve with local mount resolution tests
Add mount-aware v2 federation cursors with remote_space_id support
2026-01-24 19:50:13 +01:00

139 lines
4.6 KiB
C

#ifndef AMDUATD_FED_CURSOR_H
#define AMDUATD_FED_CURSOR_H
#include "amduat/asl/asl_pointer_fs.h"
#include "amduat/asl/core.h"
#include "amduat/asl/store.h"
#include "amduatd_fed.h"
#include "amduatd_space.h"
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
AMDUATD_FED_CURSOR_OK = 0,
AMDUATD_FED_CURSOR_ERR_INVALID = 1,
AMDUATD_FED_CURSOR_ERR_NOT_FOUND = 2,
AMDUATD_FED_CURSOR_ERR_POINTER = 3,
AMDUATD_FED_CURSOR_ERR_STORE = 4,
AMDUATD_FED_CURSOR_ERR_CODEC = 5,
AMDUATD_FED_CURSOR_ERR_CONFLICT = 6,
AMDUATD_FED_CURSOR_ERR_DISABLED = 7
} amduatd_fed_cursor_status_t;
typedef struct {
char *peer_key;
char *space_id;
bool has_logseq;
uint64_t last_logseq;
bool has_record_ref;
amduat_reference_t last_record_ref;
} amduatd_fed_cursor_record_t;
void amduatd_fed_cursor_record_init(amduatd_fed_cursor_record_t *record);
void amduatd_fed_cursor_record_free(amduatd_fed_cursor_record_t *record);
bool amduatd_fed_cursor_pointer_name(const amduatd_space_t *space,
const char *peer_key,
amduat_octets_t *out_name);
bool amduatd_fed_push_cursor_pointer_name(const amduatd_space_t *space,
const char *peer_key,
amduat_octets_t *out_name);
bool amduatd_fed_cursor_pointer_name_v2(const amduatd_space_t *space,
const char *peer_key,
const char *remote_space_id,
amduat_octets_t *out_name);
bool amduatd_fed_push_cursor_pointer_name_v2(const amduatd_space_t *space,
const char *peer_key,
const char *remote_space_id,
amduat_octets_t *out_name);
amduatd_fed_cursor_status_t amduatd_fed_cursor_check_enabled(
const amduatd_fed_cfg_t *cfg);
amduatd_fed_cursor_status_t amduatd_fed_cursor_get(
amduat_asl_store_t *store,
amduat_asl_pointer_store_t *pointer_store,
const amduatd_space_t *effective_space,
const char *peer_key,
amduatd_fed_cursor_record_t *out_cursor,
amduat_reference_t *out_ref);
amduatd_fed_cursor_status_t amduatd_fed_cursor_get_remote(
amduat_asl_store_t *store,
amduat_asl_pointer_store_t *pointer_store,
const amduatd_space_t *effective_space,
const char *peer_key,
const char *remote_space_id,
amduatd_fed_cursor_record_t *out_cursor,
amduat_reference_t *out_ref);
amduatd_fed_cursor_status_t amduatd_fed_push_cursor_get(
amduat_asl_store_t *store,
amduat_asl_pointer_store_t *pointer_store,
const amduatd_space_t *effective_space,
const char *peer_key,
amduatd_fed_cursor_record_t *out_cursor,
amduat_reference_t *out_ref);
amduatd_fed_cursor_status_t amduatd_fed_push_cursor_get_remote(
amduat_asl_store_t *store,
amduat_asl_pointer_store_t *pointer_store,
const amduatd_space_t *effective_space,
const char *peer_key,
const char *remote_space_id,
amduatd_fed_cursor_record_t *out_cursor,
amduat_reference_t *out_ref);
amduatd_fed_cursor_status_t amduatd_fed_cursor_cas_set(
amduat_asl_store_t *store,
amduat_asl_pointer_store_t *pointer_store,
const amduatd_space_t *effective_space,
const char *peer_key,
const amduat_reference_t *expected_ref,
const amduatd_fed_cursor_record_t *new_cursor,
amduat_reference_t *out_new_ref);
amduatd_fed_cursor_status_t amduatd_fed_cursor_cas_set_remote(
amduat_asl_store_t *store,
amduat_asl_pointer_store_t *pointer_store,
const amduatd_space_t *effective_space,
const char *peer_key,
const char *remote_space_id,
const amduat_reference_t *expected_ref,
const amduatd_fed_cursor_record_t *new_cursor,
amduat_reference_t *out_new_ref);
amduatd_fed_cursor_status_t amduatd_fed_push_cursor_cas_set(
amduat_asl_store_t *store,
amduat_asl_pointer_store_t *pointer_store,
const amduatd_space_t *effective_space,
const char *peer_key,
const amduat_reference_t *expected_ref,
const amduatd_fed_cursor_record_t *new_cursor,
amduat_reference_t *out_new_ref);
amduatd_fed_cursor_status_t amduatd_fed_push_cursor_cas_set_remote(
amduat_asl_store_t *store,
amduat_asl_pointer_store_t *pointer_store,
const amduatd_space_t *effective_space,
const char *peer_key,
const char *remote_space_id,
const amduat_reference_t *expected_ref,
const amduatd_fed_cursor_record_t *new_cursor,
amduat_reference_t *out_new_ref);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* AMDUATD_FED_CURSOR_H */