Skip to content

Session execute_read/write implementation #251

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

Merged
merged 12 commits into from
May 22, 2025

Conversation

JuliaKovtun
Copy link
Contributor

@JuliaKovtun JuliaKovtun commented May 14, 2025

@JuliaKovtun JuliaKovtun force-pushed the impl-execute-read-write branch from 6a47c16 to db04fb7 Compare May 14, 2025 15:18
Copy link
Member

@klobuczek klobuczek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our spec write transaction function retries deadlocks corresponds to java test writeTransactionFunctionShouldRetryDeadlocks. That test is marked as deprecated. I don't see any tests testing the same functionality with executeWrite in java so we should not either. Let's exclude this test.
Furthermore, I think it would make sense to disable the deprecation message in test environment for readability.

Comment on lines 25 to 30
check do
super(
->(tx) { Struct::Wrapper.new(reverse_check { block.call(tx) }) },
to_java_config(Neo4j::Driver::TransactionConfig, **config)
).object
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would extract this to a separate private method. So the above logic can be simplified.

%i[read write].each do |mode|
["#{mode}_transaction", "execute_#{mode}"].each do |method_name|
define_method(method_name) do |**config, &block|
if method_name.include? 'transaction'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of backwards and sort of duplication.
I think in this case it would be better to have 2 separate method definitions. One with deprecation and another without.

super(
->(tx) { Struct::Wrapper.new(reverse_check { block.call(tx) }) },
to_java_config(Neo4j::Driver::TransactionConfig, **config)
).object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's increase our max line length to 160. That's what we have on all our projects.


check do
super(
->(tx) { Struct::Wrapper.new(reverse_check { block.call(tx) }) },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if Struct::Wrapper is still required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, will check

Comment on lines 17 to 25
# implementation of read_transaction, write_transaction, execute_read, execute_write
%i[read write].each do |mode|
define_method("execute_#{mode}") do |**config, &block|
execute_transaction(__method__, **config, &block)
end

define_method("#{mode}_transaction") do |**config, &block|
Neo4j::Driver::Internal::Deprecator.log_warning("#{mode}_transaction", "execute_#{mode}".to_sym, '6.0')
execute_transaction(__method__, **config, &block)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch! That got complex. I didn't realize that when making the recommendation.
Seeing that I would prefer to duplicate the method implementation or go back to the conditional deprecation you had until we remove the method.

end

define_method("#{mode}_transaction") do |**config, &block|
Neo4j::Driver::Internal::Deprecator.log_warning("#{mode}_transaction", "execute_#{mode}".to_sym, '6.0')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use relative namespace

Suggested change
Neo4j::Driver::Internal::Deprecator.log_warning("#{mode}_transaction", "execute_#{mode}".to_sym, '6.0')
Internal::Deprecator.log_warning("#{mode}_transaction", "execute_#{mode}".to_sym, '6.0')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried Internal::Deprecator.log_warning but it raised a NameError, so left here Driver::Internal::Deprecator.log_warning

@JuliaKovtun JuliaKovtun changed the title WIP: Session execute_read/write implementation Session execute_read/write implementation May 21, 2025
@klobuczek klobuczek merged commit 47b71d8 into neo4jrb:5.0 May 22, 2025
9 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants