Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESP2REDIS: Refine error reporting from server #25

Merged
merged 13 commits into from
Oct 26, 2023
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# librdb

C library for parsing RDB files.
This is C library for parsing RDB files.

The Parser is implemented in the spirit of SAX parser. It fires off a series of events as
it reads the RDB file from beginning to end, and callbacks to handlers registered on
Expand Down Expand Up @@ -123,9 +123,9 @@ Level0. The same goes between Level2 and Level1 correspondingly.
### Handlers
The **Handlers** represent a set of builtin or user-defined functions that will be called on the
parsed data. Future plan to support built-in Handlers:
* Convert RDB to JSON file handlers. (Status: WIP)
* Convert RDB to RESP protocol handlers. (Status: WIP)
* Memory Analyze (Status: Todo)
* Convert RDB to JSON file handlers.
* Convert RDB to RESP protocol handlers.
* Memory Analyze (TODO)

It is possible to attach to parser more than one set of handlers at the same level.
That is, for a given data at a given level, the parser will call each of the handlers that
Expand Down
2 changes: 1 addition & 1 deletion api/librdb-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ _LIBRDB_API RdbState RDB_getState(RdbParser *p);
/* get number of handlers registered at given level */
_LIBRDB_API int RDB_getNumHandlers(RdbParser *p, RdbHandlersLevel lvl);

/* set the parser to ignore checksum errors */
/* To ignore on checksum error. Else parser return RDB_ERR_CHECKSUM_FAILURE */
_LIBRDB_API void RDB_IgnoreChecksum(RdbParser *p);

/* There could be relatively large strings stored within Redis, which are
Expand Down
20 changes: 18 additions & 2 deletions api/librdb-ext-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,36 @@ _LIBRDB_API RdbxToResp *RDBX_createHandlersToResp(RdbParser *, RdbxToRespConf *)
/****************************************************************
* RESP writer
*
* Create instance for writing RDB to RESP stream.
* Interface to create writer instance for RDB to RESP stream.
*
* Imp by: RDBX_createRespToRedisTcp
* RDBX_createRespToRedisFd
* RDBX_createRespToFileWriter
* <user-defined-writer>
****************************************************************/

/* On start command pass command info. NULL otherwise. */
typedef struct RdbxRespWriterStartCmd {
/* Redis Command name (Ex: "SET", "RESTORE"). Owned by the caller. It is
* constant static string and Valid for ref behind the duration of the call. */
const char *cmd;
/* If key available as part of command. Else empty string.
* Owned by the caller. */
const char *key;
} RdbxRespWriterStartCmd;

typedef struct RdbxRespWriter {
void *ctx;
void (*delete)(void *ctx);

/* return 0 on success. Otherwise 1 */
int (*writev) (void *ctx, struct iovec *ioVec, int iovCnt, int startCmd, int endCmd);
int (*writev) (void *ctx,
struct iovec *ioVec, /* Standard C scatter/gather IO array */
int iovCnt, /* Number of iovec elements */
RdbxRespWriterStartCmd *startCmd, /* If start of RESP command then not NULL. Owned by
* the caller. Valid for the duration of the call. */
int endCmd); /* 1, if this is end of RESP command, 0 otherwise */

int (*flush) (void *ctx);
} RdbxRespWriter;

Expand Down
2 changes: 1 addition & 1 deletion examples/example1.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* The following C file serves as an illustration of how to use the librdb
* library for transforming Redis RDB files into JSON format. If you wish to see
* the various parsing components being invoked in the background, simply set
* the environment variable ENV_VAR_DEBUG_DATA to 1.
* the environment variable LIBRDB_DEBUG_DATA to 1.
*
* $ export LIBRDB_DEBUG_DATA=1
* $ make example
Expand Down
Loading