X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Ffrontend%2Fconnection-private.h;h=a0f28ae985b37a81442ad7145eb3a056e9dffbca;hp=0126e892b1774f2071f255a0362ebb9404d77ef3;hb=ad77ec3d257ac66d74e91452d098882247abdc0a;hpb=b4d485cde96751e1ec832d0e75a3e6081006a1a4 diff --git a/src/frontend/connection-private.h b/src/frontend/connection-private.h index 0126e89..a0f28ae 100644 --- a/src/frontend/connection-private.h +++ b/src/frontend/connection-private.h @@ -36,6 +36,7 @@ #include "core/object.h" #include "core/store.h" +#include "core/timeseries.h" #include "utils/strbuf.h" #include @@ -57,6 +58,12 @@ struct sdb_conn { struct sockaddr_storage client_addr; socklen_t client_addr_len; + /* connection handling */ + ssize_t (*read)(sdb_conn_t *, size_t); + ssize_t (*write)(sdb_conn_t *, const void *, size_t); + int (*finish)(sdb_conn_t *); + void *session; + /* read buffer */ sdb_strbuf_t *buf; @@ -72,6 +79,7 @@ struct sdb_conn { /* user information */ char *username; /* NULL if the user has not been authenticated */ + bool ready; /* indicates that startup finished successfully */ }; #define CONN(obj) ((sdb_conn_t *)(obj)) @@ -79,6 +87,12 @@ struct sdb_conn { * node types */ +typedef struct { + sdb_conn_node_t super; + sdb_store_expr_t *expr; +} conn_expr_t; +#define CONN_EXPR(obj) ((conn_expr_t *)(obj)) + typedef struct { sdb_conn_node_t super; sdb_store_matcher_t *matcher; @@ -87,28 +101,82 @@ typedef struct { typedef struct { sdb_conn_node_t super; + int type; conn_matcher_t *filter; } conn_list_t; #define CONN_LIST(obj) ((conn_list_t *)(obj)) typedef struct { sdb_conn_node_t super; - char *name; + int type; + char *host; + char *name; /* NULL for type == SDB_HOST */ conn_matcher_t *filter; } conn_fetch_t; #define CONN_FETCH(obj) ((conn_fetch_t *)(obj)) typedef struct { sdb_conn_node_t super; + int type; conn_matcher_t *matcher; conn_matcher_t *filter; } conn_lookup_t; #define CONN_LOOKUP(obj) ((conn_lookup_t *)(obj)) +typedef struct { + sdb_conn_node_t super; + char *name; + sdb_time_t last_update; +} conn_store_host_t; +#define CONN_STORE_HOST(obj) ((conn_store_host_t *)(obj)) + +typedef struct { + sdb_conn_node_t super; + char *hostname; + char *name; + sdb_time_t last_update; +} conn_store_svc_t; +#define CONN_STORE_SVC(obj) ((conn_store_svc_t *)(obj)) + +typedef struct { + sdb_conn_node_t super; + char *hostname; + char *name; + char *store_type; /* optional */ + char *store_id; /* optional */ + sdb_time_t last_update; +} conn_store_metric_t; +#define CONN_STORE_METRIC(obj) ((conn_store_metric_t *)(obj)) + +typedef struct { + sdb_conn_node_t super; + int parent_type; + char *hostname; /* optional */ + char *parent; + char *key; + sdb_data_t value; + sdb_time_t last_update; +} conn_store_attr_t; +#define CONN_STORE_ATTR(obj) ((conn_store_attr_t *)(obj)) + +typedef struct { + sdb_conn_node_t super; + char *hostname; + char *metric; + sdb_timeseries_opts_t opts; +} conn_ts_t; +#define CONN_TS(obj) ((conn_ts_t *)(obj)) + /* * type helper functions */ +static void __attribute__((unused)) +conn_expr_destroy(sdb_object_t *obj) +{ + sdb_object_deref(SDB_OBJ(CONN_EXPR(obj)->expr)); +} /* conn_expr_destroy */ + static void __attribute__((unused)) conn_matcher_destroy(sdb_object_t *obj) { @@ -124,6 +192,8 @@ conn_list_destroy(sdb_object_t *obj) static void __attribute__((unused)) conn_fetch_destroy(sdb_object_t *obj) { + if (CONN_FETCH(obj)->host) + free(CONN_FETCH(obj)->host); if (CONN_FETCH(obj)->name) free(CONN_FETCH(obj)->name); sdb_object_deref(SDB_OBJ(CONN_FETCH(obj)->filter)); @@ -136,6 +206,70 @@ conn_lookup_destroy(sdb_object_t *obj) sdb_object_deref(SDB_OBJ(CONN_LOOKUP(obj)->filter)); } /* conn_lookup_destroy */ +static void __attribute__((unused)) +conn_store_host_destroy(sdb_object_t *obj) +{ + conn_store_host_t *host = CONN_STORE_HOST(obj); + if (host->name) + free((void *)host->name); + host->name = NULL; +} /* conn_store_host_destroy */ + +static void __attribute__((unused)) +conn_store_svc_destroy(sdb_object_t *obj) +{ + conn_store_svc_t *svc = CONN_STORE_SVC(obj); + if (svc->hostname) + free((void *)svc->hostname); + svc->hostname = NULL; + if (svc->name) + free((void *)svc->name); + svc->name = NULL; +} /* conn_store_svc_destroy */ + +static void __attribute__((unused)) +conn_store_metric_destroy(sdb_object_t *obj) +{ + conn_store_metric_t *metric = CONN_STORE_METRIC(obj); + if (metric->hostname) + free((void *)metric->hostname); + metric->hostname = NULL; + if (metric->name) + free((void *)metric->name); + metric->name = NULL; + if (metric->store_type) + free((void *)metric->store_type); + metric->store_type = NULL; + if (metric->store_id) + free((void *)metric->store_id); + metric->store_id = NULL; +} /* conn_store_metric_destroy */ + +static void __attribute__((unused)) +conn_store_attr_destroy(sdb_object_t *obj) +{ + conn_store_attr_t *attr = CONN_STORE_ATTR(obj); + if (attr->hostname) + free((void *)attr->hostname); + attr->hostname = NULL; + if (attr->parent) + free((void *)attr->parent); + attr->parent = NULL; + if (attr->key) + free((void *)attr->key); + attr->key = NULL; + sdb_data_free_datum(&attr->value); +} /* conn_store_attr_destroy */ + +static void __attribute__((unused)) +conn_ts_destroy(sdb_object_t *obj) +{ + if (CONN_TS(obj)->hostname) + free(CONN_TS(obj)->hostname); + if (CONN_TS(obj)->metric) + free(CONN_TS(obj)->metric); +} /* conn_ts_destroy */ + #ifdef __cplusplus } /* extern "C" */ #endif