2016-09-13 18:54:26 -07:00
|
|
|
#ifndef DB_H
|
|
|
|
#define DB_H
|
|
|
|
|
|
|
|
#include "event_loop.h"
|
|
|
|
|
2016-09-25 21:52:06 -07:00
|
|
|
typedef struct db_handle_impl db_handle;
|
2016-09-13 18:54:26 -07:00
|
|
|
|
2016-09-25 21:52:06 -07:00
|
|
|
/* Connect to the global system store at address and port. Returns
|
|
|
|
* a handle to the database, which must be freed with db_disconnect
|
|
|
|
* after use. */
|
|
|
|
db_handle *db_connect(const char *db_address,
|
|
|
|
int db_port,
|
|
|
|
const char *client_type,
|
|
|
|
const char *client_addr,
|
|
|
|
int client_port);
|
2016-09-13 18:54:26 -07:00
|
|
|
|
2016-09-23 22:53:58 -07:00
|
|
|
/* Attach global system store connection to event loop. */
|
2016-09-25 21:52:06 -07:00
|
|
|
void db_attach(db_handle *db, event_loop *loop);
|
2016-09-13 18:54:26 -07:00
|
|
|
|
|
|
|
/* Disconnect from the global system store. */
|
2016-09-25 21:52:06 -07:00
|
|
|
void db_disconnect(db_handle *db);
|
2016-09-13 18:54:26 -07:00
|
|
|
|
2016-10-18 15:12:41 -07:00
|
|
|
/**
|
|
|
|
* Returns the client ID, according to the database.
|
|
|
|
*
|
|
|
|
* @param db The handle to the database.
|
|
|
|
* @returns int The client ID for this connection to the database. If
|
|
|
|
* this client has no connection to the database, returns -1.
|
|
|
|
*/
|
|
|
|
int get_client_id(db_handle *db);
|
|
|
|
|
2016-09-13 18:54:26 -07:00
|
|
|
#endif
|