MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / RedisModule_OnLoad

Function RedisModule_OnLoad

src/module.c:96–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
97 if(RedisModule_Init(ctx, "graph", REDISGRAPH_MODULE_VERSION,
98 REDISMODULE_APIVER_1) == REDISMODULE_ERR) {
99 return REDISMODULE_ERR;
100 }
101
102 // initialize GraphBLAS
103 int res = GraphBLAS_Init(ctx);
104 if(res != REDISMODULE_OK) return res;
105
106 // validate minimum redis-server version
107 if(!Redis_Version_GreaterOrEqual(MIN_REDIS_VERION_MAJOR,
108 MIN_REDIS_VERION_MINOR, MIN_REDIS_VERION_PATCH)) {
109 RedisModule_Log(ctx, "warning", "RedisGraph requires redis-server version %d.%d.%d and up",
110 MIN_REDIS_VERION_MAJOR, MIN_REDIS_VERION_MINOR, MIN_REDIS_VERION_PATCH);
111 return REDISMODULE_ERR;
112 }
113
114 if(RediSearch_Init(ctx, REDISEARCH_INIT_LIBRARY) != REDISMODULE_OK) {
115 return REDISMODULE_ERR;
116 }
117
118 RedisModule_Log(ctx, "notice", "Starting up RedisGraph version %d.%d.%d.",
119 REDISGRAPH_VERSION_MAJOR, REDISGRAPH_VERSION_MINOR, REDISGRAPH_VERSION_PATCH);
120
121 Proc_Register(); // register procedures
122 AR_RegisterFuncs(); // register arithmetic functions
123
124 // set up the module's configurable variables,
125 // using user-defined values where provided
126 // register for config updates
127 Config_Subscribe_Changes(reconf_handler);
128 if(Config_Init(ctx, argv, argc) != REDISMODULE_OK) return REDISMODULE_ERR;
129
130 RegisterEventHandlers(ctx);
131
132 // create thread local storage keys for query and error contexts
133 if(!_Cron_Start()) return REDISMODULE_ERR;
134 if(!QueryCtx_Init()) return REDISMODULE_ERR;
135 if(!ErrorCtx_Init()) return REDISMODULE_ERR;
136 if(!ThreadPools_Init()) return REDISMODULE_ERR;
137 if(!Indexer_Init()) return REDISMODULE_ERR;
138 if(!AST_ValidationsMappingInit()) return REDISMODULE_ERR;
139
140 RedisModule_Log(ctx, "notice", "Thread pool created, using %d threads.",
141 ThreadPools_ReadersCount());
142
143 int ompThreadCount;
144 Config_Option_get(Config_OPENMP_NTHREAD, &ompThreadCount);
145
146 if(GxB_set(GxB_NTHREADS, ompThreadCount) != GrB_SUCCESS) {
147 RedisModule_Log(ctx, "warning", "Failed to set OpenMP thread count to %d", ompThreadCount);
148 return REDISMODULE_ERR;
149 }
150
151 // log configuration
152 _Print_Config(ctx);
153

Callers

nothing calls this directly

Calls 15

RedisModule_InitFunction · 0.85
GraphBLAS_InitFunction · 0.85
Proc_RegisterFunction · 0.85
AR_RegisterFuncsFunction · 0.85
Config_Subscribe_ChangesFunction · 0.85
Config_InitFunction · 0.85
RegisterEventHandlersFunction · 0.85
_Cron_StartFunction · 0.85
QueryCtx_InitFunction · 0.85
ErrorCtx_InitFunction · 0.85
ThreadPools_InitFunction · 0.85

Tested by

no test coverage detected