neo4j 8.0.0.alpha.5 → 8.0.0.alpha.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/neo4j/active_base.rb +9 -1
- data/lib/neo4j/railtie.rb +50 -10
- data/lib/neo4j/session_manager.rb +3 -51
- data/lib/neo4j/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac1f95d91c95d7a8d809de657a186fe9a98f0872
|
4
|
+
data.tar.gz: b1fb1a75eaacc95293219bdc997513a523222ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a01f591a8e12eb3d305f9c7fcba1779bba18034d1ad413e8b856ee362a61e66cc5a06dbe5e810f9f9fe9542a25f336b052f8a1a34669c16582ac509de6ab8c7
|
7
|
+
data.tar.gz: aad90232c15f4c746195237be20f98e2a4bf091c4f32a65f7a205660a90ca6f3af73fdf5e8176493fa2d201714ae07bb2357bb58716dedf3a4f88b16e6503a0d
|
data/CHANGELOG.md
CHANGED
@@ -14,10 +14,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
14
14
|
### Changed
|
15
15
|
|
16
16
|
- `ActiveNode#destroy` and `ActiveRel#destroy` now return the object in question rather than `true` to be compatible with `ActiveRecord` (see #1254)
|
17
|
+
- Multiple sessions in Rails config no longer supported
|
18
|
+
- Instead of using `session_type`, `session_url`, `session_path`, and `session_options` in config `session.type`, `session.url`, `session.path`, and `session.options` should now be used.
|
17
19
|
|
18
20
|
### Fixed
|
19
21
|
|
20
22
|
- Bugs with using `neo_id` as `ActiveNode` `id_property` (thanks klobuczek / see #1274)
|
23
|
+
- Issue where `session_url` (now `session.url`) was not working
|
24
|
+
- Various issues with not be able to run migrations when migration were pending
|
25
|
+
- Broken sessions when threading
|
21
26
|
|
22
27
|
## [8.0.0.alpha.2] 2016-08-05
|
23
28
|
|
data/lib/neo4j/active_base.rb
CHANGED
@@ -5,11 +5,19 @@ module Neo4j
|
|
5
5
|
class << self
|
6
6
|
# private?
|
7
7
|
def current_session
|
8
|
-
SessionRegistry.current_session.tap do |session|
|
8
|
+
(SessionRegistry.current_session ||= establish_session).tap do |session|
|
9
9
|
fail 'No session defined!' if session.nil?
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def on_establish_session(&block)
|
14
|
+
@establish_session_block = block
|
15
|
+
end
|
16
|
+
|
17
|
+
def establish_session
|
18
|
+
@establish_session_block.call if @establish_session_block
|
19
|
+
end
|
20
|
+
|
13
21
|
def current_transaction_or_session
|
14
22
|
current_transaction || current_session
|
15
23
|
end
|
data/lib/neo4j/railtie.rb
CHANGED
@@ -45,27 +45,69 @@ module Neo4j
|
|
45
45
|
# Starting Neo after :load_config_initializers allows apps to
|
46
46
|
# register migrations in config/initializers
|
47
47
|
initializer 'neo4j.start', after: :load_config_initializers do |app|
|
48
|
-
|
49
|
-
# Set Rails specific defaults
|
50
|
-
Neo4j::SessionManager.setup! cfg
|
48
|
+
Neo4j::ActiveBase.on_establish_session { setup! app.config.neo4j }
|
51
49
|
|
52
50
|
Neo4j::Config[:logger] ||= Rails.logger
|
53
51
|
|
54
|
-
session_types = cfg.sessions.map { |session_opts| session_opts[:type] }
|
55
|
-
|
56
|
-
register_neo4j_cypher_logging(session_types)
|
57
52
|
if Rails.env.development? && !Neo4j::Migrations.currently_running_migrations && Neo4j::Config.fail_on_pending_migrations
|
58
53
|
Neo4j::Migrations.check_for_pending_migrations!
|
59
54
|
end
|
60
55
|
end
|
61
56
|
|
57
|
+
def setup!(cfg = nil)
|
58
|
+
neo4j_config ||= ActiveSupport::OrderedOptions.new
|
59
|
+
cfg.each {|k, v| neo4j_config[k] = v } if cfg
|
60
|
+
|
61
|
+
support_deprecated_session_configs!(neo4j_config)
|
62
|
+
|
63
|
+
Neo4j::Config.configuration.merge!(neo4j_config.to_h)
|
64
|
+
|
65
|
+
type, url, path, options, wait_for_connection = neo4j_config.session.values_at(:type, :path, :url, :options, :wait_for_connection)
|
66
|
+
register_neo4j_cypher_logging(type || default_session_type)
|
67
|
+
|
68
|
+
Neo4j::SessionManager.open_neo4j_session(type || default_session_type,
|
69
|
+
url || path || default_session_path_or_url,
|
70
|
+
wait_for_connection,
|
71
|
+
options || {})
|
72
|
+
end
|
73
|
+
|
74
|
+
def support_deprecated_session_configs!(neo4j_config)
|
75
|
+
ActiveSupport::Deprecation.warn('neo4j.config.sessions is deprecated, please use neo4j.config.session (not an array)') if neo4j_config.sessions.present?
|
76
|
+
neo4j_config.session ||= (neo4j_config.sessions && neo4j_config.sessions[0]) || {}
|
77
|
+
|
78
|
+
%w(type path url options).each do |key|
|
79
|
+
value = neo4j_config.send("session_#{key}")
|
80
|
+
if value.present?
|
81
|
+
ActiveSupport::Deprecation.warn("neo4j.config.session_#{key} is deprecated, please use neo4j.config.session.#{key}")
|
82
|
+
neo4j_config.session[key] = value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def default_session_type
|
88
|
+
if ENV['NEO4J_URL']
|
89
|
+
URI(ENV['NEO4J_URL']).scheme.tap do |scheme|
|
90
|
+
fail "Invalid scheme for NEO4J_URL: #{scheme}" if !%w(http bolt).include?(scheme)
|
91
|
+
end
|
92
|
+
else
|
93
|
+
ENV['NEO4J_TYPE'] || config_data[:type] || :http
|
94
|
+
end.to_sym
|
95
|
+
end
|
96
|
+
|
97
|
+
def default_session_path_or_url
|
98
|
+
ENV['NEO4J_URL'] || ENV['NEO4J_PATH'] ||
|
99
|
+
config_data[:url] || config_data[:path] ||
|
100
|
+
'http://localhost:7474'
|
101
|
+
end
|
102
|
+
|
103
|
+
|
62
104
|
TYPE_SUBSCRIBERS = {
|
63
105
|
http: Neo4j::Core::CypherSession::Adaptors::HTTP.method(:subscribe_to_request),
|
64
106
|
bolt: Neo4j::Core::CypherSession::Adaptors::Bolt.method(:subscribe_to_request),
|
65
107
|
embedded: Neo4j::Core::CypherSession::Adaptors::Embedded.method(:subscribe_to_transaction)
|
66
108
|
}
|
67
109
|
|
68
|
-
def register_neo4j_cypher_logging(
|
110
|
+
def register_neo4j_cypher_logging(session_type)
|
69
111
|
return if @neo4j_cypher_logging_registered
|
70
112
|
|
71
113
|
Neo4j::Core::Query.pretty_cypher = Neo4j::Config[:pretty_logged_cypher_queries]
|
@@ -74,9 +116,7 @@ module Neo4j
|
|
74
116
|
(Neo4j::Config[:logger] ||= Rails.logger).debug message
|
75
117
|
end
|
76
118
|
Neo4j::Core::CypherSession::Adaptors::Base.subscribe_to_query(&logger_proc)
|
77
|
-
|
78
|
-
TYPE_SUBSCRIBERS[type].call(&logger_proc)
|
79
|
-
end
|
119
|
+
TYPE_SUBSCRIBERS[session_type.to_sym].call(&logger_proc)
|
80
120
|
|
81
121
|
@neo4j_cypher_logging_registered = true
|
82
122
|
end
|
@@ -7,46 +7,14 @@ require 'neo4j/core/cypher_session/adaptors/embedded'
|
|
7
7
|
module Neo4j
|
8
8
|
class SessionManager
|
9
9
|
class << self
|
10
|
-
def
|
11
|
-
cfg ||= ActiveSupport::OrderedOptions.new
|
12
|
-
|
13
|
-
setup_default_session(cfg)
|
14
|
-
|
15
|
-
cfg.sessions.each do |session_opts|
|
16
|
-
open_neo4j_session(session_opts, cfg.wait_for_connection)
|
17
|
-
end
|
18
|
-
|
19
|
-
Neo4j::Config.configuration.merge!(cfg.to_h)
|
20
|
-
end
|
21
|
-
|
22
|
-
# TODO: Remove ability for multiple sessions?
|
23
|
-
# Ability to overwrite default session per-model like ActiveRecord?
|
24
|
-
def setup_default_session(cfg)
|
25
|
-
setup_config_defaults!(cfg)
|
26
|
-
|
27
|
-
return if !cfg.sessions.empty?
|
28
|
-
|
29
|
-
cfg.sessions << {type: cfg.session_type, path: cfg.session_path, options: cfg.session_options.merge(default: true)}
|
30
|
-
end
|
31
|
-
|
32
|
-
# TODO: Support `session_url` config for server mode
|
33
|
-
def setup_config_defaults!(cfg)
|
34
|
-
cfg.session_type ||= default_session_type
|
35
|
-
cfg.session_path ||= default_session_path
|
36
|
-
cfg.session_options ||= {}
|
37
|
-
cfg.sessions ||= []
|
38
|
-
end
|
39
|
-
|
40
|
-
def open_neo4j_session(options, wait_for_connection = false)
|
41
|
-
session_type, path, url = options.values_at(:type, :path, :url)
|
42
|
-
|
10
|
+
def open_neo4j_session(type, url_or_path, url, wait_for_connection = false, options = {})
|
43
11
|
enable_unlimited_strength_crypto! if java_platform? && session_type_is_embedded?(session_type)
|
44
12
|
|
45
13
|
adaptor = wait_for_value(wait_for_connection) do
|
46
|
-
cypher_session_adaptor(
|
14
|
+
cypher_session_adaptor(type, url_or_path, options.merge(wrap_level: :proc))
|
47
15
|
end
|
48
16
|
|
49
|
-
Neo4j::
|
17
|
+
Neo4j::Core::CypherSession.new(adaptor)
|
50
18
|
end
|
51
19
|
|
52
20
|
protected
|
@@ -94,22 +62,6 @@ module Neo4j
|
|
94
62
|
end
|
95
63
|
end
|
96
64
|
|
97
|
-
def default_session_type
|
98
|
-
if ENV['NEO4J_URL']
|
99
|
-
URI(ENV['NEO4J_URL']).scheme.tap do |scheme|
|
100
|
-
fail "Invalid scheme for NEO4J_URL: #{scheme}" if !%w(http bolt).include?(scheme)
|
101
|
-
end
|
102
|
-
else
|
103
|
-
ENV['NEO4J_TYPE'] || config_data[:type] || :http
|
104
|
-
end.to_sym
|
105
|
-
end
|
106
|
-
|
107
|
-
def default_session_path
|
108
|
-
ENV['NEO4J_URL'] || ENV['NEO4J_PATH'] ||
|
109
|
-
config_data[:url] || config_data[:path] ||
|
110
|
-
'http://localhost:7474'
|
111
|
-
end
|
112
|
-
|
113
65
|
def java_platform?
|
114
66
|
RUBY_PLATFORM =~ /java/
|
115
67
|
end
|
data/lib/neo4j/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.0.alpha.
|
4
|
+
version: 8.0.0.alpha.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge, Brian Underwood, Chris Grigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: orm_adapter
|