Code

frontend: Added the SERVER_VERSION command.
[sysdb.git] / src / include / frontend / proto.h
index 7aae68dde622a0ebe7835c796a46c216838b7de8..ade3a7cb192eaa7fc1ccf0fa5c01c050723c69e8 100644 (file)
@@ -245,6 +245,44 @@ typedef enum {
         */
        SDB_CONNECTION_TIMESERIES,
 
+       /*
+        * SDB_CONNECTION_STORE:
+        * Execute the 'STORE' command in the server. The message body shall
+        * include the type of the object to be stored, the timestamp of the last
+        * update, and a list of fields describing the object depending on the
+        * object type. Object types are encoded as 32bit integers in network
+        * byte-order where attribute types are bitwise ORed with the appropriate
+        * parent object type. Timestamps are encoded as 64bit integers in network
+        * byte-order. Fields are null-terminated strings.
+        *
+        * 0               32              64
+        * +---------------+---------------+
+        * | STORE         | length        |
+        * +---------------+---------------+
+        * | object type   | last_update.. |
+        * +---------------+---------------+
+        * | ...           | fields        |
+        * +---------------+               |
+        * | ...                           |
+        *
+        * Fields:
+        *
+        *      HOST: name
+        *   SERVICE: hostname, name
+        *    METRIC: hostname, name, [store type, store id]
+        * ATTRIBUTE: [hostname], parent object name, key, <value>
+        *
+        * Values are encoded as their type (32bit integer in network byte-order),
+        * and their content as implemented by sdb_proto_marshal_data.
+        */
+       SDB_CONNECTION_STORE = 50,
+
+       /* Only used internally: */
+       SDB_CONNECTION_STORE_HOST,
+       SDB_CONNECTION_STORE_SERVICE,
+       SDB_CONNECTION_STORE_METRIC,
+       SDB_CONNECTION_STORE_ATTRIBUTE,
+
        /*
         * Command subcomponents.
         */
@@ -260,8 +298,39 @@ typedef enum {
         * A parsed expression. Only used internally.
         */
        SDB_CONNECTION_EXPR,
+
+       /*
+        * Server status queries.
+        */
+
+       /*
+        * SDB_CONNECTION_SERVER_VERSION:
+        * Retrieve the server version. The server replies with SDB_CONNECTION_OK
+        * on success and the server version as an unsigned 32-bit integer,
+        * optionally followed by a string describing extra version components.
+        * The integer server version is encoded as 100000 * major + 100 * minor +
+        * patch.
+        *
+        * 0               32              64
+        * +---------------+---------------+
+        * | SERVER_VERSION| 0             |
+        * +---------------+---------------+
+        */
+       SDB_CONNECTION_SERVER_VERSION = 1000,
 } sdb_conn_state_t;
 
+#define SDB_CONN_MSGTYPE_TO_STRING(t) \
+       (((t) == SDB_CONNECTION_IDLE) ? "IDLE" \
+               : ((t) == SDB_CONNECTION_PING) ? "PING" \
+               : ((t) == SDB_CONNECTION_STARTUP) ? "STARTUP" \
+               : ((t) == SDB_CONNECTION_QUERY) ? "QUERY" \
+               : ((t) == SDB_CONNECTION_FETCH) ? "FETCH" \
+               : ((t) == SDB_CONNECTION_LIST) ? "LIST" \
+               : ((t) == SDB_CONNECTION_LOOKUP) ? "LOOKUP" \
+               : ((t) == SDB_CONNECTION_TIMESERIES) ? "TIMESERIES" \
+               : ((t) == SDB_CONNECTION_STORE) ? "STORE" \
+               : "UNKNOWN")
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif