Class: Neo4j::Server::CypherTransaction
- Inherits:
-
Object
- Object
- Neo4j::Server::CypherTransaction
- Includes:
- Core::CypherTranslator, Resource, Transaction::Instance
- Defined in:
- lib/neo4j-server/cypher_transaction.rb
Overview
The CypherTransaction object lifecycle is as follows:
-
It is initialized with the transactional endpoint URL and the connection object to use for communication. It does not communicate with the server to create this.
-
The first query within the transaction sets the commit and execution addresses, :commit_url and :exec_url.
-
At any time, `failure` can be called to mark a transaction failed and trigger a rollback upon closure.
-
`close` is called to end the transaction. It calls `_commit_tx` or `_delete_tx`.
If a transaction is created and then closed without performing any queries, an OpenStruct is returned that behaves like a successfully closed query.
Constant Summary
- ROW_REST =
%w(row REST)
Constants included from Core::CypherTranslator
Core::CypherTranslator::EMPTY_PROPS, Core::CypherTranslator::SANITIZE_ESCAPED_REGEXP
Instance Attribute Summary (collapse)
-
- (Object) base_url
readonly
Returns the value of attribute base_url.
-
- (Object) commit_url
readonly
Returns the value of attribute commit_url.
-
- (Object) connection
readonly
Returns the value of attribute connection.
-
- (Object) exec_url
readonly
Returns the value of attribute exec_url.
Attributes included from Resource
Instance Method Summary (collapse)
- - (Object) _commit_tx
- - (Object) _delete_tx
- - (Object) _query(cypher_query, params = nil)
-
- (CypherTransaction) initialize(url, session_connection)
constructor
A new instance of CypherTransaction.
Methods included from Resource
#convert_from_json_value, #expect_response_code, #handle_response_error, #init_resource_data, #resource_headers, #resource_url_id, #response_exception, #wrap_resource
Methods included from Core::CypherTranslator
#create_escape_value, #cypher_prop_list, #cypher_string, #escape_quotes, #escape_value, #label_string, #prop_identifier, #sanitize_escape_sequences, sanitized_column_names, translate_response
Methods included from Transaction::Instance
#acquire_read_lock, #acquire_write_lock, #close, #expired?, #failed?, #mark_expired, #mark_failed
Constructor Details
- (CypherTransaction) initialize(url, session_connection)
Returns a new instance of CypherTransaction
17 18 19 20 21 |
# File 'lib/neo4j-server/cypher_transaction.rb', line 17 def initialize(url, session_connection) @base_url = url @connection = session_connection register_instance end |
Instance Attribute Details
- (Object) base_url (readonly)
Returns the value of attribute base_url
15 16 17 |
# File 'lib/neo4j-server/cypher_transaction.rb', line 15 def base_url @base_url end |
- (Object) commit_url (readonly)
Returns the value of attribute commit_url
15 16 17 |
# File 'lib/neo4j-server/cypher_transaction.rb', line 15 def commit_url @commit_url end |
- (Object) connection (readonly)
Returns the value of attribute connection
15 16 17 |
# File 'lib/neo4j-server/cypher_transaction.rb', line 15 def connection @connection end |
- (Object) exec_url (readonly)
Returns the value of attribute exec_url
15 16 17 |
# File 'lib/neo4j-server/cypher_transaction.rb', line 15 def exec_url @exec_url end |
Instance Method Details
- (Object) _commit_tx
37 38 39 |
# File 'lib/neo4j-server/cypher_transaction.rb', line 37 def _commit_tx _tx_query(:post, commit_url, nil) end |
- (Object) _delete_tx
33 34 35 |
# File 'lib/neo4j-server/cypher_transaction.rb', line 33 def _delete_tx _tx_query(:delete, exec_url, headers: resource_headers) end |
- (Object) _query(cypher_query, params = nil)
24 25 26 27 28 29 30 31 |
# File 'lib/neo4j-server/cypher_transaction.rb', line 24 def _query(cypher_query, params = nil) fail 'Transaction expired, unable to perform query' if expired? statement = {statement: cypher_query, parameters: params, resultDataContents: ROW_REST} body = {statements: [statement]} response = exec_url && commit_url ? connection.post(exec_url, body) : register_urls(body) _create_cypher_response(response) end |