#ifndef NET_SDK_H
#define NET_SDK_H
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void* net_handle_t;
typedef enum {
NET_SUCCESS = 0,
NET_ERR_NULL_POINTER = -1,
NET_ERR_INVALID_UTF8 = -2,
NET_ERR_INVALID_JSON = -3,
NET_ERR_INIT_FAILED = -4,
NET_ERR_INGESTION_FAILED = -5,
NET_ERR_POLL_FAILED = -6,
NET_ERR_BUFFER_TOO_SMALL = -7,
NET_ERR_SHUTTING_DOWN = -8,
NET_ERR_INT_OVERFLOW = -9,
NET_ERR_MISMATCHED_HANDLES = -10,
NET_ERR_INTERIOR_NUL = -11,
NET_ERR_UNKNOWN = -99
} net_error_t;
typedef struct {
uint16_t shard_id;
uint64_t timestamp;
} net_receipt_t;
typedef struct {
const char* id;
size_t id_len;
const char* raw;
size_t raw_len;
uint64_t insertion_ts;
uint16_t shard_id;
} net_event_t;
typedef struct {
net_event_t* events;
size_t count;
char* next_id;
int has_more;
} net_poll_result_t;
typedef struct {
uint64_t events_ingested;
uint64_t events_dropped;
uint64_t batches_dispatched;
} net_stats_t;
net_handle_t net_init(const char* config_json);
int net_shutdown(net_handle_t handle);
const char* net_version(void);
uint16_t net_num_shards(net_handle_t handle);
int net_ingest_raw(net_handle_t handle, const char* json, size_t len);
int net_ingest_raw_ex(net_handle_t handle, const char* json, size_t len, net_receipt_t* out);
int net_ingest(net_handle_t handle, const char* event_json, size_t len);
int net_ingest_raw_batch(
net_handle_t handle,
const char** jsons,
const size_t* lens,
size_t count
);
int net_ingest_batch(net_handle_t handle, const char* events_json);
int net_poll(
net_handle_t handle,
const char* request_json,
char* out_buffer,
size_t buffer_len
);
int net_poll_ex(
net_handle_t handle,
size_t limit,
const char* cursor,
net_poll_result_t* out
);
void net_free_poll_result(net_poll_result_t* result);
int net_stats(net_handle_t handle, char* out_buffer, size_t buffer_len);
int net_stats_ex(net_handle_t handle, net_stats_t* out);
int net_flush(net_handle_t handle);
char* net_generate_keypair(void);
void net_free_string(char* s);
typedef struct net_redis_dedup_s net_redis_dedup_t;
net_redis_dedup_t* net_redis_dedup_new(size_t capacity);
void net_redis_dedup_free(net_redis_dedup_t* handle);
int net_redis_dedup_is_duplicate(net_redis_dedup_t* handle, const char* dedup_id);
size_t net_redis_dedup_len(net_redis_dedup_t* handle);
size_t net_redis_dedup_capacity(net_redis_dedup_t* handle);
int net_redis_dedup_is_empty(net_redis_dedup_t* handle);
void net_redis_dedup_clear(net_redis_dedup_t* handle);
#ifdef __cplusplus
}
#endif
#endif