-
Notifications
You must be signed in to change notification settings - Fork 4
Skip module check if server doesn't support MODULE LIST #16
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
rescue Redis::CommandError | ||
# Ignore check if the connected server does not support the "MODULE LIST" command | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [87/80] |
||
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? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if module_version < 19900 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ def create_graph() | |
it "should print property strings correctly after updates" do | ||
q = """MATCH (a {name: 'src1'}) RETURN a""" | ||
res = @r.query(q) | ||
expect(res.resultset).to eq([[[{"name"=>"src1"}, {"color"=>"cyan"}, {"newval"=>TRUE}]]]) | ||
expect(res.resultset).to eq([[[{"name"=>"src1"}, {"color"=>"cyan"}, {"newval"=>true}]]]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/SpaceInsideHashLiteralBraces: Space inside { missing. |
||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/AbcSize: Assignment Branch Condition size for check_module_version is too high. [16.58/15]
Metrics/MethodLength: Method has too many lines. [12/10]
Style/DefWithParentheses: Omit the parentheses in defs when the method doesn't accept any arguments.