peplum 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/peplum/application/services/shared_hash.rb +22 -9
- data/lib/peplum/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: aec29bf9b09d3b32cb143536ea66a1550b41008e7856108949ef2a45f74c3761
|
4
|
+
data.tar.gz: 656a2e85c329a0005da906ba9f649553277c40feb772930ca66c99b5115be906
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3894e8846b387ab36ba705b9137ab7ea4a122057d62378224bc43f29caaf1600ce27d41ffb3472e81b0524b5d03330f935a3d79a3ae0f7197d4ae8500c218e91
|
7
|
+
data.tar.gz: 8c420ac4afbb2788b0434971e6865e33b03d086cc2275bc504fe65f0f06ced8ea729abf26494bc360875c2a3be1ea13a06da5940062a907bc48d0148172c82db
|
@@ -4,6 +4,8 @@ module Services
|
|
4
4
|
|
5
5
|
class SharedHash
|
6
6
|
|
7
|
+
CONCURRENCY = 20
|
8
|
+
|
7
9
|
def initialize(*)
|
8
10
|
super
|
9
11
|
|
@@ -17,33 +19,41 @@ class SharedHash
|
|
17
19
|
@hash[k]
|
18
20
|
end
|
19
21
|
|
20
|
-
def set( k, v, broadcast = true )
|
21
|
-
|
22
|
+
def set( k, v, broadcast = true, &block )
|
23
|
+
if @hash[k] == v
|
24
|
+
block.call if block_given?
|
25
|
+
return
|
26
|
+
end
|
22
27
|
|
23
28
|
@hash[k] = v
|
24
29
|
call_on_set( k, v )
|
25
30
|
|
26
31
|
if broadcast
|
27
|
-
each_peer do |peer|
|
28
|
-
peer.send( name ).set( k, v, false )
|
32
|
+
each_peer do |peer, iterator|
|
33
|
+
peer.send( name ).set( k, v, false ) { iterator.next }
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
37
|
+
block.call if block_given?
|
32
38
|
nil
|
33
39
|
end
|
34
40
|
|
35
|
-
def delete( k, broadcast = true )
|
36
|
-
|
41
|
+
def delete( k, broadcast = true, &block )
|
42
|
+
if !@hash.include? k
|
43
|
+
block.call if block_given?
|
44
|
+
return
|
45
|
+
end
|
37
46
|
|
38
47
|
@hash.delete( k )
|
39
48
|
call_on_delete( k )
|
40
49
|
|
41
50
|
if broadcast
|
42
|
-
each_peer do |
|
43
|
-
peer.send( name ).delete( k, false )
|
51
|
+
each_peer do |peer, iterator|
|
52
|
+
peer.send( name ).delete( k, false ) { iterator.next }
|
44
53
|
end
|
45
54
|
end
|
46
55
|
|
56
|
+
block.call if block_given?
|
47
57
|
nil
|
48
58
|
end
|
49
59
|
|
@@ -82,7 +92,10 @@ class SharedHash
|
|
82
92
|
end
|
83
93
|
|
84
94
|
def each_peer( &block )
|
85
|
-
|
95
|
+
each = proc do |client, iterator|
|
96
|
+
block.call client, iterator
|
97
|
+
end
|
98
|
+
Raktr.global.create_iterator( Cuboid::Application.application.peers.to_a, CONCURRENCY ).each( each )
|
86
99
|
end
|
87
100
|
|
88
101
|
end
|
data/lib/peplum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peplum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tasos Laskos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cuboid
|