grumlin 1.0.0.rc1 → 1.0.0.rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5a4223c6fde72d3f4ce23f3da0081a816f395a070d8737d9915f15b166c9721
4
- data.tar.gz: 8c95dcb15d4f55741cc370298e1e763427858908abebaec33f945e404d3a6fa3
3
+ metadata.gz: 00b4b216f2e14d752c8ada35d0bb511e850ba1bc7eefc4b474ae17348060efc5
4
+ data.tar.gz: ae38aae9acdbbc6163c6c1e6759955074f8ae416d04ce5cec2b06853009a44c2
5
5
  SHA512:
6
- metadata.gz: 69162f44551c45c0898ffa0c3650cee448a155d1950de5ea0a2a4b570c1b2b41612f3b97bd063f88f683af5fad3c18d4b874b96392a30334c77ab0e1fb1fd226
7
- data.tar.gz: 1fdb7d10a84da7d8c8173e2b0edb0f5b0f913fb0418fce59bb92d28de9c2e9a1743b89eca1f0ed8495b4d0519d2068c2314e9f17f23b77a4297e080512ace082
6
+ metadata.gz: 47c0afe0c2708158a16b76efc64d4212ddb7a610f5f72f2afed4f7da4b75b921685c396b10984d4ebb1577387ba55ca92c95253fe98f36c58b7e1202ee0adf49
7
+ data.tar.gz: 07eab1e1fb55641f58a09ca3ed3a478e58a52635a7059e62eda656d0a16a1d2797d0cb5f2d66fcfa1bca513fe05f6ab7791e459b2867c44eadfcc15a89f0ac3b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (1.0.0.rc1)
4
+ grumlin (1.0.0.rc3)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (>= 0.19, < 0.20)
7
7
  ibsciss-middleware (~> 0.4.0)
data/README.md CHANGED
@@ -148,9 +148,14 @@ Each `return_mode` is mapped to a particular termination step:
148
148
 
149
149
  and a few methods that emulate upserts:
150
150
  - `upsert_vertex(label, id, create_properties: {}, update_properties: {}, on_failure: :retry, start: g, **params)`
151
+ - `upsert_vertices(edges, batch_size: 100, on_failure: :retry, start: g, **params)`
151
152
  - `upsert_edge(label, from:, to:, create_properties: {}, update_properties: {}, on_failure: :retry, start: g, **params)`
152
153
  - `upsert_edges(edges, batch_size: 100, on_failure: :retry, start: g, **params)`
153
- - `upsert_vertices(edges, batch_size: 100, on_failure: :retry, start: g, **params)`
154
+
155
+ **Note**: all upsert methods expect your provider has support for user supplied string ids for nodes and edges
156
+ respectively. For edges and if `create_properties[T.id]` if nil, grumlin will generate a uuid-like id out of `from` and
157
+ `to` vertex ids and edge's label to ensure uniqueness of the edge. If you manually provide an id, it's your
158
+ responsibility to ensure it's uniquely identifies the edge using it's `from`, `to` and `label`.
154
159
 
155
160
  All of them support 3 different modes for error handling: `:retry`, `:ignore` and `:raise`. Retry mode is implemented
156
161
  with [retryable](https://github.com/nfedyashev/retryable). **params will be merged to the default config for upserts
@@ -5,8 +5,9 @@ class Grumlin::DummyTransaction < Grumlin::Transaction
5
5
 
6
6
  include Console
7
7
 
8
- def initialize(traversal_start_class, middlewares:, pool: nil) # rubocop:disable Lint/MissingSuper, Lint/UnusedMethodArgument
9
- @traversal_start_class = traversal_start_class
8
+ def initialize(traversal_start_class, middlewares:, pool:)
9
+ super
10
+ @session_id = nil
10
11
 
11
12
  logger.info(self) do
12
13
  "#{Grumlin.config.provider} does not support transactions. commit and rollback are ignored, data will be saved"
@@ -13,12 +13,13 @@ module Grumlin::Shortcuts::Upserts
13
13
  end
14
14
 
15
15
  shortcut :upsertE do |label, from, to, create_properties = {}, update_properties = {}|
16
+ id = create_properties[T.id] || Grumlin.fake_uuid(from, label, to)
16
17
  self.V(from)
17
18
  .outE(label).where(__.inV.hasId(to))
18
19
  .fold
19
20
  .coalesce(
20
21
  __.unfold,
21
- __.addE(label).from(__.V(from)).to(__.V(to)).props(**create_properties)
22
+ __.addE(label).from(__.V(from)).to(__.V(to)).props(**create_properties.merge(T.id => id))
22
23
  ).props(**update_properties)
23
24
  end
24
25
  end
@@ -14,7 +14,6 @@ class Grumlin::Steppable
14
14
  def initialize(pool: nil, session_id: nil, middlewares: Grumlin.default_middlewares)
15
15
  @pool = pool
16
16
  @session_id = session_id
17
-
18
17
  @middlewares = middlewares
19
18
 
20
19
  return if respond_to?(:shortcuts)
@@ -16,7 +16,7 @@ class Grumlin::Transaction
16
16
  end
17
17
 
18
18
  def begin
19
- @traversal_start_class.new(session_id: @session_id)
19
+ @traversal_start_class.new(session_id: @session_id, pool: @pool)
20
20
  end
21
21
 
22
22
  def commit
@@ -12,15 +12,19 @@ class Grumlin::TraversalStart < Grumlin::Steppable
12
12
  transaction = tx_class.new(self.class, pool: @pool, middlewares: @middlewares)
13
13
  return transaction unless block_given?
14
14
 
15
+ result = nil
16
+
15
17
  begin
16
- yield transaction.begin
18
+ result = yield transaction.begin
17
19
  rescue Grumlin::Rollback
18
20
  transaction.rollback
21
+ result
19
22
  rescue StandardError
20
23
  transaction.rollback
21
24
  raise
22
25
  else
23
26
  transaction.commit
27
+ result
24
28
  end
25
29
  end
26
30
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "1.0.0.rc1"
4
+ VERSION = "1.0.0.rc3"
5
5
  end
data/lib/grumlin.rb CHANGED
@@ -184,6 +184,19 @@ module Grumlin
184
184
  def definitions
185
185
  @definitions ||= YAML.safe_load(File.read(File.join(__dir__, "definitions.yml")), symbolize_names: true)
186
186
  end
187
+
188
+ def fake_uuid(*parts, separator: "->")
189
+ uuid = Digest::MD5.hexdigest(parts.join(separator))
190
+
191
+ segments = [8, 4, 4, 4, 12]
192
+ parts = segments.map do |n|
193
+ uuid[0...n].tap do
194
+ uuid = uuid[n..]
195
+ end
196
+ end
197
+
198
+ parts.join("-")
199
+ end
187
200
  end
188
201
  end
189
202
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grumlin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-13 00:00:00.000000000 Z
11
+ date: 2022-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool