metacosm 0.2.14 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/gemspec.yml +1 -1
- data/lib/metacosm/remote_simulation.rb +2 -0
- data/lib/metacosm/simulation.rb +23 -22
- data/lib/metacosm/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66827fd4b46abafb5968f2e5edfbc81fb0d0bf6a
|
4
|
+
data.tar.gz: be2c788d20092c47e8ce694f301a35c02c7fbf3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f4b1ed809a9ae97e6912ac49e53c27994b5931d7931037ce5c99ceff02587bf0d3acef582005664bf421c6ae97919ea5f36255fe4d474650c54df1c28e3bbdf
|
7
|
+
data.tar.gz: 744ddc7537917dd4b691076c33cc8bc07b2ad142c309148e903c3635eee8125cbe555d461fcb889a7239e60c42f7595944261ec1f8b61d43489e1044c67097b4
|
data/Gemfile
CHANGED
data/gemspec.yml
CHANGED
@@ -10,6 +10,8 @@ module Metacosm
|
|
10
10
|
Redis.new
|
11
11
|
end
|
12
12
|
|
13
|
+
def apply(command); fire command end
|
14
|
+
|
13
15
|
def fire(command)
|
14
16
|
command_dto = command.attrs.merge(handler_module: command.handler_module_name, handler_class_name: command.handler_class_name)
|
15
17
|
redis = redis_connection
|
data/lib/metacosm/simulation.rb
CHANGED
@@ -20,7 +20,6 @@ module Metacosm
|
|
20
20
|
while true
|
21
21
|
if (command=command_queue.pop)
|
22
22
|
apply(command)
|
23
|
-
sleep 0.01
|
24
23
|
end
|
25
24
|
Thread.pass
|
26
25
|
end
|
@@ -84,26 +83,28 @@ module Metacosm
|
|
84
83
|
|
85
84
|
def subscribe_for_commands(channel:)
|
86
85
|
p [ :subscribe_to_command_channel, channel: channel ]
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
86
|
+
@command_subscription_thread = Thread.new do
|
87
|
+
redis = Redis.new
|
88
|
+
begin
|
89
|
+
redis.subscribe(channel) do |on|
|
90
|
+
on.subscribe do |chan, subscriptions|
|
91
|
+
puts "Subscribed to ##{chan} (#{subscriptions} subscriptions)"
|
92
|
+
end
|
93
|
+
|
94
|
+
on.message do |chan, message|
|
95
|
+
puts "##{chan}: #{message}"
|
96
|
+
apply(Marshal.load(message))
|
97
|
+
end
|
98
|
+
|
99
|
+
on.unsubscribe do |chan, subscriptions|
|
100
|
+
puts "Unsubscribed from ##{chan} (#{subscriptions} subscriptions)"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
rescue Redis::BaseConnectionError => error
|
104
|
+
puts "#{error}, retrying in 1s"
|
105
|
+
sleep 1
|
106
|
+
retry
|
107
|
+
end
|
107
108
|
end
|
108
109
|
end
|
109
110
|
|
@@ -130,7 +131,7 @@ module Metacosm
|
|
130
131
|
|
131
132
|
def clear!
|
132
133
|
@events = []
|
133
|
-
@command_queue
|
134
|
+
@command_queue && @command_queue.clear
|
134
135
|
end
|
135
136
|
|
136
137
|
protected
|
data/lib/metacosm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metacosm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Weissman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: passive_record
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: redis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.
|
197
|
+
rubygems_version: 2.4.6
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: reactive simulation framework
|