grumlin 1.0.0.rc1 → 1.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -1
- data/lib/grumlin/dummy_transaction.rb +3 -2
- data/lib/grumlin/shortcuts/upserts.rb +2 -1
- data/lib/grumlin/steppable.rb +0 -1
- data/lib/grumlin/transaction.rb +1 -1
- data/lib/grumlin/traversal_start.rb +5 -1
- data/lib/grumlin/version.rb +1 -1
- data/lib/grumlin.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00b4b216f2e14d752c8ada35d0bb511e850ba1bc7eefc4b474ae17348060efc5
|
4
|
+
data.tar.gz: ae38aae9acdbbc6163c6c1e6759955074f8ae416d04ce5cec2b06853009a44c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47c0afe0c2708158a16b76efc64d4212ddb7a610f5f72f2afed4f7da4b75b921685c396b10984d4ebb1577387ba55ca92c95253fe98f36c58b7e1202ee0adf49
|
7
|
+
data.tar.gz: 07eab1e1fb55641f58a09ca3ed3a478e58a52635a7059e62eda656d0a16a1d2797d0cb5f2d66fcfa1bca513fe05f6ab7791e459b2867c44eadfcc15a89f0ac3b
|
data/Gemfile.lock
CHANGED
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
|
-
|
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:
|
9
|
-
|
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
|
data/lib/grumlin/steppable.rb
CHANGED
data/lib/grumlin/transaction.rb
CHANGED
@@ -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
|
|
data/lib/grumlin/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-pool
|