fixed WIN32 build

added subscribe_to_all (wip)
This commit is contained in:
Nicolas Dextraze
2018-03-25 18:03:44 -07:00
parent dcca4b2709
commit 4e585e4372
18 changed files with 411 additions and 52 deletions

View File

@@ -19,6 +19,9 @@ array_t* array_create(size_t n, ...);
void array_destroy(array_t* array, array_deallocator destroyer);
// uuid
#if defined(_WIN32) && defined(UUID_DEFINED)
#undef uuid_t
#endif
typedef struct st_uuid uuid_t;
uuid_t* uuid_create();
void uuid_destroy(uuid_t*);
@@ -45,10 +48,10 @@ typedef struct st_error {
typedef struct st_esc_position esc_position_t;
typedef struct st_esc_connection_settings esc_connection_settings_t;
typedef struct st_connection esc_connection_t;
typedef struct st_credentials esc_credentials_t;
typedef struct st_esc_connection esc_connection_t;
typedef struct st_esc_credentials esc_credentials_t;
struct st_recorded_event {
typedef struct st_esc_recorded_event {
uuid_t* event_id;
const char* event_type;
int64_t event_number;
@@ -56,15 +59,13 @@ struct st_recorded_event {
int64_t created_epoch;
buffer_t* data;
buffer_t* metadata;
};
typedef struct st_recorded_event esc_recorded_event_t;
} esc_recorded_event_t;
struct st_resolved_event {
typedef struct st_esc_resolved_event {
esc_recorded_event_t* event;
esc_recorded_event_t* link;
esc_position_t* original_position;
};
typedef struct st_resolved_event esc_resolved_event_t;
} esc_resolved_event_t;
struct st_all_events_slice {
char* read_direction;
@@ -83,6 +84,20 @@ typedef struct st_esc_write_result {
typedef struct st_esc_event_data esc_event_data_t;
typedef struct st_esc_subscription esc_subscription_t;
typedef void (*esc_event_appeared_t)(void* ctx, esc_subscription_t* s, esc_resolved_event_t* ev);
typedef struct st_event_appeared_callback {
esc_event_appeared_t fn;
void* ctx;
} esc_event_appeared_callback_t;
typedef void (*esc_subscription_droppped_t)(void* ctx, esc_subscription_t* subscription, const char* reason, error_t* error);
typedef struct st_subscription_dropped_callback {
esc_subscription_droppped_t fn;
void* ctx;
} esc_subscription_dropped_callback_t;
esc_connection_settings_t* const esc_default_connection_settings;
// Connection
@@ -105,6 +120,14 @@ void esc_all_events_slice_destroy(esc_all_events_slice_t* all_events_slice);
error_t* esc_connection_last_error(esc_connection_t* conn);
// Subscriptions
extern esc_event_appeared_callback_t esc_empty_event_appeared_callback;
extern esc_subscription_dropped_callback_t esc_empty_subscription_dropped_callback;
esc_subscription_t* esc_connection_subscribe_to_all(esc_connection_t* conn, bool_t resolve_link_tos, esc_event_appeared_callback_t event_appeared_callback, esc_subscription_dropped_callback_t subscription_dropped_callback, esc_credentials_t* credentials);
void esc_subscription_stop(esc_subscription_t* subscription);
void esc_subscription_destroy(esc_subscription_t* subscription);
// Formatting
const char* uuid_format(uuid_t* uuid, char* buf, size_t buf_size);
const char* esc_position_format(esc_position_t* position, char* buffer, size_t buf_size);