#include <distcache/dc_plug.h>
int DC_PLUG_read(DC_PLUG *plug, int resume, unsigned long *request_uid, DC_CMD *cmd, const unsigned char **payload_data, unsigned int *payload_len); int DC_PLUG_consume(DC_PLUG *plug); int DC_PLUG_write(DC_PLUG *plug, int resume, unsigned long request_uid, DC_CMD cmd, const unsigned char *payload_data, unsigned int payload_len); int DC_PLUG_write_more(DC_PLUG *plug, const unsigned char *data, unsigned int data_len); int DC_PLUG_commit(DC_PLUG *plug); int DC_PLUG_rollback(DC_PLUG *plug);
typedef enum { DC_CMD_ERROR, DC_CMD_ADD, DC_CMD_GET, DC_CMD_REMOVE, DC_CMD_HAVE } DC_CMD;
DC_PLUG_consume() will close the message currently opened for reading in plug, and will allow a future call to DC_PLUG_read() to succeed if there any subsequent (complete) messages received from the plug object's connection.
DC_PLUG_write() will attempt to open a distcache message for writing in plug. If successful, this message will block the writing of any other messages until the message is committed with DC_PLUG_commit() or discarded with DC_PLUG_rollback(). If a message has already been opened for writing, DC_PLUG_write() will fail unless resume is non-zero in which case the message will be re-opened and will overwrite the settings from the previous DC_PLUG_write() call. This is equivalent to DC_PLUG_rollback() followed immediately by DC_PLUG_write() with a zero resume value. Note that payload_len can be zero (and thus payload_data can be NULL) even if the message will eventually have payload data - this can be supplemented afterwards using the DC_PLUG_write_more() function. request_uid and cmd, on the other hand, must be specified at once in DC_PLUG_write().
DC_PLUG_write_more() will attempt to add more payload data to the message currently opened for writing in plug. This data will be concatenated to the end of any payload data already provided in prior calls to DC_PLUG_write() or DC_PLUG_write_more().
DC_PLUG_commit() will close the message currently opened for writing, and queue it for serialisation out on the plug object's connection.
DC_PLUG_rollback() will discard the message currently opened for writing.
distcache(8) - Overview of the distcache architecture.
http://www.distcache.org/ - Distcache home page.
Home Page: http://www.distcache.org