Code

Let the network protocol and SysQL support last_update for metric stores.
[sysdb.git] / src / include / utils / proto.h
index df24278742227e1b845e23f20145ef194f141c14..a9ea1e321d4368fb61ae87fda233056e561b7cf2 100644 (file)
@@ -46,12 +46,14 @@ typedef struct {
        sdb_time_t last_update;
        const char *name;
 } sdb_proto_host_t;
+#define SDB_PROTO_HOST_INIT { 0, NULL }
 
 typedef struct {
        sdb_time_t last_update;
        const char *hostname;
        const char *name;
 } sdb_proto_service_t;
+#define SDB_PROTO_SERVICE_INIT { 0, NULL, NULL }
 
 typedef struct {
        sdb_time_t last_update;
@@ -59,7 +61,9 @@ typedef struct {
        const char *name;
        const char *store_type; /* optional */
        const char *store_id;   /* optional */
+       sdb_time_t store_last_update; /* optional */
 } sdb_proto_metric_t;
+#define SDB_PROTO_METRIC_INIT { 0, NULL, NULL, NULL, NULL, 0 }
 
 typedef struct {
        sdb_time_t last_update;
@@ -69,6 +73,7 @@ typedef struct {
        const char *key;
        sdb_data_t value;
 } sdb_proto_attribute_t;
+#define SDB_PROTO_ATTRIBUTE_INIT { 0, 0, NULL, NULL, NULL, SDB_DATA_INIT }
 
 /*
  * sdb_proto_marshal:
@@ -87,6 +92,20 @@ ssize_t
 sdb_proto_marshal(char *buf, size_t buf_len, uint32_t code,
                uint32_t msg_len, const char *msg);
 
+/*
+ * sdb_proto_marshal_int32:
+ * Encode the 32-bit integer into the wire format and write it to buf.
+ *
+ * Returns:
+ *  - The number of bytes of the encoded value on success. The function does
+ *    not write more than 'buf_len' bytes. If the output was truncated then
+ *    the return value is the number of bytes which would have been written if
+ *    enough space had been available.
+ *  - a negative value else
+ */
+ssize_t
+sdb_proto_marshal_int32(char *buf, size_t buf_len, uint32_t v);
+
 /*
  * sdb_proto_marshal_data:
  * Encode a datum into the wire format and write it to buf.