[Openais] Ideas for a cleaner/easier to use objdb API
Angus Salkeld
angus.salkeld at gmail.com
Tue Jul 28 12:30:18 PDT 2009
Hi
Here is a first attempt at an easier to use API for objdb.
1) remove the need for parent_handles.
2) Each object/key must have a unique name (as a string)
2.1) So no child objects named the same (service, logging,...)
3) support persistent & runtime keys to better support IMM
4) assume all objects/keys are synronised (no special attribute for it)
5) less/(no) need for iterators as you can directly asses key using it's path.
eg objdb->key_get("/logging/NTF/debug", &debug_on, &debug_on_len);
Discussion:
1) what is the best API for searching?
2) import for corosync.conf/xml/... (perhaps a separate tool to parse?)
3) export to corosync.conf/xml/...
4) what about basic typing for keys? (int8,int16,int32,int64,string,any)
Lots of feedback please :)
Regards
Angus Salkeld
typedef enum {
OBJECT_TRACK_DEPTH_ONE,
OBJECT_TRACK_DEPTH_RECURSIVE
} objdb_track_depth_t;
typedef enum {
OBJECT_CREATE,
OBJECT_REPLACE,
OBJECT_DELETE,
OBJECT_READ,
OBJECT_WRITE
} objdb_callback_type_t;
#define OBJDB_ATTR_MEMORY 0x01
#define OBJDB_ATTR_PERSISTENT 0x02
#define OBJDB_ATTR_RUNTIME 0x04
#define OBJDB_ATTR_READONLY 0x08
#define OBJDB_ATTR_READWRITE 0x10
typedef int (*data_notification_fn_t) (
const char *path_pt,
objdb_callback_type_t type,
const void *value, size_t value_len,
void *priv_data_pt);
typedef int (*path_notification_fn_t) (
const char *path_pt,
objdb_callback_type_t type,
void *priv_data_pt);
struct objdb_iface_ver_2_0 {
int (*objdb_init) (void);
int (*object_create) (
hdb_handle_t *object_handle,
const char *path,
path_notification_fn_t child_validator,
data_notification_fn_t data_validator);
int (*object_destroy) (
const char *path);
int (*object_path_get) (
hdb_handle_t object_handle,
char *path,
size_t *path_len);
int (*key_create_runtime) (
const char *path,
const uint8_t attributes,
data_notification_fn_t read_write,
void * priv_data_pt);
int (*key_create) (
const char *path,
const uint8_t attributes,
const void *value,
size_t value_len);
int (*key_get) (
const char *path,
void **value,
size_t *value_len);
int (*key_delete) (const char *path);
int (*track_start) (
const char *path,
hdb_handle_t *track_handle,
objdb_track_depth_t depth,
data_notification_fn_t data_changed_notify_fn,
path_notification_fn_t path_changed_notify_fn,
void * priv_data_pt);
void (*track_stop) (hdb_handle_t track_handle);
};
More information about the Openais
mailing list