jason-rails 0.6.4 → 0.6.5
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/client/package.json +1 -1
- data/lib/jason.rb +0 -1
- data/lib/jason/graph_helper.rb +15 -4
- data/lib/jason/subscription.rb +17 -2
- data/lib/jason/version.rb +1 -1
- 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: 3dcf3cd2febb358e030ebe12ca382b463a8ca97dcdbb228d9a4354f2687b2cd1
|
4
|
+
data.tar.gz: fb385f90db387e2e4dfc1ce8016b1d800ac3ba6b78e3a54f59a1ec17d670aaef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17ff6a77e7076e887bc2730ae32607d5c7afcd272dbe535f66259a758867296a759580be3f4385bd878fd908d22e883b0047fbd0bee0134f443457422edf1975
|
7
|
+
data.tar.gz: 398111401a126b189398baff186284e11f580e653af6391be7a0576c9d1c4832ec6915400071fd66e4819b676deeeae52d35b75fe9499b480c73c5c88c135cfb
|
data/Gemfile.lock
CHANGED
data/client/package.json
CHANGED
data/lib/jason.rb
CHANGED
@@ -37,7 +37,6 @@ module Jason
|
|
37
37
|
|
38
38
|
previous_schema = JSON.parse($redis_jason.get('jason:last_schema') || '{}')
|
39
39
|
current_schema = Jason.schema.deep_stringify_keys.deep_transform_values { |v| v.is_a?(Symbol) ? v.to_s : v }
|
40
|
-
pp current_schema
|
41
40
|
current_schema.each do |model, config|
|
42
41
|
if config != previous_schema[model]
|
43
42
|
puts "Config changed for #{model}"
|
data/lib/jason/graph_helper.rb
CHANGED
@@ -33,7 +33,8 @@ class Jason::GraphHelper
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Add and remove edges, return graph before and after
|
36
|
-
|
36
|
+
# Enforce means make the graph contain only the add_edges
|
37
|
+
def apply_update(add: nil, remove: nil, enforce: false)
|
37
38
|
add_edges = []
|
38
39
|
remove_edges = []
|
39
40
|
|
@@ -48,11 +49,21 @@ class Jason::GraphHelper
|
|
48
49
|
remove_edges += build_edges(edge_set[:model_names], edge_set[:instance_ids], include_root: false)
|
49
50
|
end
|
50
51
|
end
|
51
|
-
|
52
|
+
|
53
|
+
diff_edges_from_graph(add_edges: add_edges, remove_edges: remove_edges, enforce: enforce)
|
52
54
|
end
|
53
55
|
|
54
|
-
def diff_edges_from_graph(add_edges: [], remove_edges: [])
|
55
|
-
|
56
|
+
def diff_edges_from_graph(add_edges: [], remove_edges: [], enforce: false)
|
57
|
+
if enforce
|
58
|
+
old_edges = $redis_jason.multi do |r|
|
59
|
+
r.smembers("jason:subscriptions:#{id}:graph")
|
60
|
+
r.del("jason:subscriptions:#{id}:graph")
|
61
|
+
r.sadd("jason:subscriptions:#{id}:graph", add_edges) if add_edges.present?
|
62
|
+
end[0]
|
63
|
+
new_edges = add_edges
|
64
|
+
else
|
65
|
+
old_edges, new_edges = Jason::LuaGenerator.new.update_set_with_diff("jason:subscriptions:#{id}:graph", add_edges.flatten, remove_edges.flatten)
|
66
|
+
end
|
56
67
|
|
57
68
|
old_graph = build_graph_from_edges(old_edges)
|
58
69
|
new_graph = build_graph_from_edges(new_edges)
|
data/lib/jason/subscription.rb
CHANGED
@@ -269,7 +269,8 @@ class Jason::Subscription
|
|
269
269
|
|
270
270
|
# Build the tree
|
271
271
|
id_changeset = graph_helper.apply_update({
|
272
|
-
add: [edge_set]
|
272
|
+
add: [edge_set],
|
273
|
+
enforce: enforce
|
273
274
|
})
|
274
275
|
apply_id_changeset(id_changeset)
|
275
276
|
end
|
@@ -320,7 +321,7 @@ class Jason::Subscription
|
|
320
321
|
$redis_jason.hset("jason:consumers", consumer_id, Time.now.utc)
|
321
322
|
|
322
323
|
if before_consumer_count == 0
|
323
|
-
set_ids_for_sub_models
|
324
|
+
set_ids_for_sub_models(enforce: true)
|
324
325
|
end
|
325
326
|
end
|
326
327
|
|
@@ -375,6 +376,20 @@ class Jason::Subscription
|
|
375
376
|
}
|
376
377
|
end
|
377
378
|
|
379
|
+
# To be used as a fallback when some corruption of the subscription has taken place
|
380
|
+
def reset!(hard: false)
|
381
|
+
# Remove subscription state
|
382
|
+
if hard
|
383
|
+
clear_all_ids
|
384
|
+
$redis_jason.del("jason:subscriptions:#{id}:graph")
|
385
|
+
end
|
386
|
+
|
387
|
+
set_ids_for_sub_models(enforce: true)
|
388
|
+
includes_helper.all_models.each do |model_name|
|
389
|
+
broadcaster.broadcast(get_for_model(model_name))
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
378
393
|
def add(model_name, instance_id)
|
379
394
|
idx = $redis_jason.incr("jason:subscription:#{id}:#{model_name}:idx")
|
380
395
|
payload = JSON.parse($redis_jason.hget("jason:cache:#{model_name}", instance_id) || '{}')
|
data/lib/jason/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jason-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Rees
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|