Code

core: Add the store writer plugin type.
[sysdb.git] / src / include / core / store.h
index a8208bf7d9a0a849e16c6316616af092e4b1e9b5..30ad0ab386b81517128c47fbe0995d8dcf030c86 100644 (file)
@@ -94,6 +94,14 @@ enum {
 struct sdb_store_obj;
 typedef struct sdb_store_obj sdb_store_obj_t;
 
 struct sdb_store_obj;
 typedef struct sdb_store_obj sdb_store_obj_t;
 
+/*
+ * A metric store describes how to access a metric's data.
+ */
+typedef struct {
+       const char *type;
+       const char *id;
+} sdb_metric_store_t;
+
 /*
  * Expressions represent arithmetic expressions based on stored objects and
  * their various attributes.
 /*
  * Expressions represent arithmetic expressions based on stored objects and
  * their various attributes.
@@ -125,6 +133,28 @@ typedef struct sdb_store_matcher sdb_store_matcher_t;
 struct sdb_store_json_formatter;
 typedef struct sdb_store_json_formatter sdb_store_json_formatter_t;
 
 struct sdb_store_json_formatter;
 typedef struct sdb_store_json_formatter sdb_store_json_formatter_t;
 
+/*
+ * A store writer describes the interface for plugins implementing a store.
+ */
+typedef struct {
+       int (*store_host)(const char *name, sdb_time_t last_update,
+                       sdb_object_t *user_data);
+       int (*store_service)(const char *hostname, const char *name,
+                       sdb_time_t last_update, sdb_object_t *user_data);
+       int (*store_metric)(const char *hostname, const char *name,
+                       sdb_metric_store_t *store, sdb_time_t last_update,
+                       sdb_object_t *user_data);
+       int (*store_attribute)(const char *hostname,
+                       const char *key, const sdb_data_t *value, sdb_time_t last_update,
+                       sdb_object_t *user_data);
+       int (*store_service_attr)(const char *hostname, const char *service,
+                       const char *key, const sdb_data_t *value, sdb_time_t last_update,
+                       sdb_object_t *user_data);
+       int (*store_metric_attr)(const char *hostname, const char *metric,
+                       const char *key, const sdb_data_t *value, sdb_time_t last_update,
+                       sdb_object_t *user_data);
+} sdb_store_writer_t;
+
 /*
  * sdb_store_clear:
  * Clear the entire store and remove all stored objects.
 /*
  * sdb_store_clear:
  * Clear the entire store and remove all stored objects.
@@ -220,14 +250,6 @@ int
 sdb_store_service_attr(const char *hostname, const char *service,
                const char *key, const sdb_data_t *value, sdb_time_t last_update);
 
 sdb_store_service_attr(const char *hostname, const char *service,
                const char *key, const sdb_data_t *value, sdb_time_t last_update);
 
-/*
- * A metric store describes how to access a metric's data.
- */
-typedef struct {
-       const char *type;
-       const char *id;
-} sdb_metric_store_t;
-
 /*
  * sdb_store_metric:
  * Add/update a metric in the store. If the metric, identified by its name,
 /*
  * sdb_store_metric:
  * Add/update a metric in the store. If the metric, identified by its name,