-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip module check if server doesn't support MODULE LIST (#16)
- Loading branch information
1 parent
c28cc03
commit 9ffba1d
Showing
2 changed files
with
14 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
class RedisGraph | ||
def connect_to_server(options) | ||
@connection = Redis.new(options) | ||
@module_version = module_version() | ||
raise ServerError, "RedisGraph module not loaded." if @module_version.nil? | ||
raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if @module_version < 19900 | ||
check_module_version | ||
end | ||
|
||
# Ensure that the connected Redis server supports modules | ||
# and has loaded the RedisGraph module | ||
def module_version() | ||
def check_module_version() | ||
redis_version = @connection.info["redis_version"] | ||
major_version = redis_version.split('.').first.to_i | ||
raise ServerError, "Redis 4.0 or greater required for RedisGraph support." unless major_version >= 4 | ||
modules = @connection.call("MODULE", "LIST") | ||
|
||
begin | ||
modules = @connection.call("MODULE", "LIST") | ||
rescue Redis::CommandError | ||
# Ignore check if the connected server does not support the "MODULE LIST" command | ||
return | ||
end | ||
|
||
module_graph = modules.detect { |_name_key, name, _ver_key, _ver| name == 'graph' } | ||
module_graph[3] if module_graph | ||
module_version = module_graph[3] if module_graph | ||
raise ServerError, "RedisGraph module not loaded." if module_version.nil? | ||
raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if module_version < 19900 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters