MCPcopy Create free account
hub / github.com/RedisGears/RedisGears / RedisGearsPy_LoadRegistrations

Function RedisGearsPy_LoadRegistrations

plugins/python/redisgears_python.c:7069–7119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7067}
7068
7069static int RedisGearsPy_LoadRegistrations(RedisModuleIO *rdb, int encver, int when){
7070 if(encver > REDISGEARSPY_REQ_DATATYPE_VERSION){
7071 RedisModule_LogIOError(rdb, "warning", "Give requirement version is not supported, please upgrade to newer RedisGears.");
7072 return REDISMODULE_ERR;
7073 }
7074
7075 RedisGearsPy_ClearAllData();
7076
7077 char* err = NULL;
7078 char *data = NULL;
7079 PythonRequirementCtx* req = NULL;
7080 while(RedisModule_LoadUnsigned(rdb)){
7081 size_t len;
7082 char *data = RedisModule_LoadStringBuffer(rdb, &len);
7083 Gears_Buffer buff = {
7084 .buff = data,
7085 .size = len,
7086 .cap = len,
7087 };
7088 Gears_BufferReader br;
7089 Gears_BufferReaderInit(&br, &buff);
7090 req = PythonRequirement_Deserialize(&br, &err);
7091 if(!req){
7092 goto error;
7093 }
7094
7095 // now we also need to install the requirement
7096 if(!PythonRequirementCtx_InstallRequirement(req)){
7097 err = RG_STRDUP("Failed install requirement on shard, check shard log for more info.");
7098 goto error;
7099 }
7100
7101 RedisModule_Free(data);
7102 PythonRequirementCtx_Free(req);
7103 }
7104 return REDISMODULE_OK;
7105
7106error:
7107 RedisModule_LogIOError(rdb, "warning", "Failed deserialize requirements (%s)", err ? err : "unknown error");
7108 if(err){
7109 RG_FREE(err);
7110 }
7111 if(data){
7112 RedisModule_Free(data);
7113 }
7114 if(req){
7115 PythonRequirementCtx_Free(req);
7116 }
7117 RedisGearsPy_ClearRequirements();
7118 return REDISMODULE_ERR;
7119}
7120
7121static void RedisGearsPy_SaveRegistrations(RedisModuleIO *rdb, int when){
7122 Gears_dictIterator *iter = Gears_dictGetIterator(RequirementsDict);

Callers

nothing calls this directly

Tested by

no test coverage detected