asynchronic 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/asynchronic.gemspec +1 -1
- data/lib/asynchronic.rb +2 -2
- data/lib/asynchronic/data_store/in_memory.rb +3 -1
- data/lib/asynchronic/data_store/lazy_value.rb +3 -3
- data/lib/asynchronic/data_store/redis.rb +10 -9
- data/lib/asynchronic/data_store/scoped_store.rb +13 -11
- data/lib/asynchronic/environment.rb +1 -1
- data/lib/asynchronic/version.rb +1 -1
- data/spec/data_store/lazy_value_examples.rb +1 -1
- data/spec/data_store/redis_spec.rb +2 -2
- data/spec/facade_spec.rb +2 -2
- data/spec/minitest_helper.rb +1 -5
- data/spec/process/life_cycle_redis_spec.rb +3 -3
- data/spec/worker/redis_spec.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1f6b6846abc0d662921131cdab188869fa36354
|
4
|
+
data.tar.gz: abaa211fac95e8fdd69795859341fb57d09547b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f484b72c6ed24f16b6633fe42b63ffecdcb9d1bcbce4345a62980b648233a5f76abaf0bd2ecbb534500645609a1d856e4169ba3d7d4fa7a2ba2036e05611a071
|
7
|
+
data.tar.gz: 674e42cba4808664ea3d5e006d2737e813c28a5a348de533bbcaf18606200b2d3cf5a2a357bf4d1102f0212018caa782d54cdc55df41f5c3330b6cf00311d445
|
data/Rakefile
CHANGED
data/asynchronic.gemspec
CHANGED
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'minitest-colorin', '~> 0.1'
|
30
30
|
spec.add_development_dependency 'minitest-great_expectations', '~> 0.0'
|
31
31
|
spec.add_development_dependency 'simplecov'
|
32
|
-
spec.add_development_dependency 'pry'
|
32
|
+
spec.add_development_dependency 'pry-nav'
|
33
33
|
end
|
data/lib/asynchronic.rb
CHANGED
@@ -17,7 +17,7 @@ module Asynchronic
|
|
17
17
|
attr_config :data_store, DataStore::InMemory.new
|
18
18
|
attr_config :logger, Logger.new($stdout)
|
19
19
|
|
20
|
-
|
20
|
+
RETRY_TIMEOUT = 30
|
21
21
|
|
22
22
|
def self.environment
|
23
23
|
Environment.new queue_engine, data_store
|
@@ -36,7 +36,7 @@ module Asynchronic
|
|
36
36
|
result = yield
|
37
37
|
rescue Exception => ex
|
38
38
|
logger.info(a_class) { "Retrying #{message}. ERROR: #{ex.message}" }
|
39
|
-
sleep
|
39
|
+
sleep RETRY_TIMEOUT
|
40
40
|
retry
|
41
41
|
end
|
42
42
|
result
|
@@ -4,7 +4,7 @@ module Asynchronic
|
|
4
4
|
|
5
5
|
def initialize(data_store, key)
|
6
6
|
@data_store_class = data_store.class
|
7
|
-
@
|
7
|
+
@data_store_connection_args = data_store.connection_args
|
8
8
|
@key = key
|
9
9
|
end
|
10
10
|
|
@@ -14,11 +14,11 @@ module Asynchronic
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def inspect
|
17
|
-
"#<#{proxy_class} @data_store_class=#{@data_store_class} @
|
17
|
+
"#<#{proxy_class} @data_store_class=#{@data_store_class} @data_store_connection_args=#{@data_store_connection_args} @key=#{@key}>"
|
18
18
|
end
|
19
19
|
|
20
20
|
def data_store
|
21
|
-
@data_store_class.connect
|
21
|
+
@data_store_class.connect *@data_store_connection_args
|
22
22
|
end
|
23
23
|
|
24
24
|
def to_value
|
@@ -4,12 +4,13 @@ module Asynchronic
|
|
4
4
|
|
5
5
|
include Helper
|
6
6
|
|
7
|
-
def initialize(*args)
|
7
|
+
def initialize(scope, *args)
|
8
|
+
@scope = Key.new scope
|
8
9
|
@connection = ::Redis.new *args
|
9
10
|
end
|
10
11
|
|
11
12
|
def [](key)
|
12
|
-
value = @connection.get key
|
13
|
+
value = @connection.get @scope[key]
|
13
14
|
value ? Marshal.load(value) : nil
|
14
15
|
rescue => ex
|
15
16
|
Asynchronic.logger.warn('Asynchronic') { ex.message }
|
@@ -17,23 +18,23 @@ module Asynchronic
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def []=(key, value)
|
20
|
-
@connection.set key
|
21
|
+
@connection.set @scope[key], Marshal.dump(value)
|
21
22
|
end
|
22
23
|
|
23
24
|
def delete(key)
|
24
|
-
@connection.del key
|
25
|
+
@connection.del @scope[key]
|
25
26
|
end
|
26
27
|
|
27
28
|
def keys
|
28
|
-
@connection.keys.map { |k| Key.new
|
29
|
+
@connection.keys(@scope['*']).map { |k| Key.new(k).remove_first }
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
-
@connection.client.options
|
32
|
+
def connection_args
|
33
|
+
[@scope, @connection.client.options]
|
33
34
|
end
|
34
35
|
|
35
|
-
def self.connect(
|
36
|
-
new
|
36
|
+
def self.connect(*args)
|
37
|
+
new *args
|
37
38
|
end
|
38
39
|
|
39
40
|
end
|
@@ -30,17 +30,19 @@ module Asynchronic
|
|
30
30
|
map { |k| Key.new(k).remove_first @scope.sections.count }
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
def connection_args
|
34
|
+
[
|
35
|
+
{
|
36
|
+
data_store_class: @data_store.class,
|
37
|
+
data_store_connection_args: @data_store.connection_args,
|
38
|
+
scope: @scope
|
39
|
+
}
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.connect(*args)
|
44
|
+
data_store = args[0][:data_store_class].connect *args[0][:data_store_connection_args]
|
45
|
+
new data_store, args[0][:scope]
|
44
46
|
end
|
45
47
|
|
46
48
|
def to_s
|
data/lib/asynchronic/version.rb
CHANGED
@@ -32,7 +32,7 @@ module LazyValueExamples
|
|
32
32
|
|
33
33
|
it 'Inspect' do
|
34
34
|
value = lazy_value :key
|
35
|
-
value.inspect.must_match /#<Asynchronic::DataStore::LazyValue @data_store_class=.+ @
|
35
|
+
value.inspect.must_match /#<Asynchronic::DataStore::LazyValue @data_store_class=.+ @data_store_connection_args=.+ @key=key>/
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -4,9 +4,9 @@ require_relative './lazy_value_examples'
|
|
4
4
|
|
5
5
|
describe Asynchronic::DataStore::Redis do
|
6
6
|
|
7
|
-
let(:data_store) { Asynchronic::DataStore::Redis.new }
|
7
|
+
let(:data_store) { Asynchronic::DataStore::Redis.new :asynchronic_test }
|
8
8
|
|
9
|
-
|
9
|
+
after do
|
10
10
|
data_store.clear
|
11
11
|
end
|
12
12
|
|
data/spec/facade_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'minitest_helper'
|
|
2
2
|
|
3
3
|
describe Asynchronic, 'Facade' do
|
4
4
|
|
5
|
-
|
5
|
+
after do
|
6
6
|
Asynchronic.environment.data_store.clear
|
7
7
|
Asynchronic.environment.queue_engine.clear
|
8
8
|
end
|
@@ -26,7 +26,7 @@ describe Asynchronic, 'Facade' do
|
|
26
26
|
it 'Environment' do
|
27
27
|
Asynchronic.environment.tap do |env|
|
28
28
|
env.queue_engine.must_equal Asynchronic.queue_engine
|
29
|
-
env.data_store.
|
29
|
+
env.data_store.must_equal Asynchronic.data_store
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/spec/minitest_helper.rb
CHANGED
@@ -5,6 +5,7 @@ require 'minitest/colorin'
|
|
5
5
|
require 'minitest/great_expectations'
|
6
6
|
require 'jobs'
|
7
7
|
require 'expectations'
|
8
|
+
require 'pry-nav'
|
8
9
|
|
9
10
|
class Module
|
10
11
|
include Minitest::Spec::DSL
|
@@ -16,11 +17,6 @@ class Minitest::Spec
|
|
16
17
|
before do
|
17
18
|
Asynchronic.restore_default_configuration
|
18
19
|
end
|
19
|
-
|
20
|
-
after do
|
21
|
-
Asynchronic::DataStore::Redis.new.clear
|
22
|
-
Asynchronic::QueueEngine::Ost.new.clear
|
23
|
-
end
|
24
20
|
end
|
25
21
|
|
26
22
|
module Asynchronic::DataStore::Helper
|
@@ -4,10 +4,10 @@ require_relative './life_cycle_examples.rb'
|
|
4
4
|
describe Asynchronic::Process, 'Life cycle - Redis' do
|
5
5
|
|
6
6
|
let(:queue_engine) { Asynchronic::QueueEngine::Ost.new }
|
7
|
-
let(:data_store) { Asynchronic::DataStore::Redis.new }
|
7
|
+
let(:data_store) { Asynchronic::DataStore::Redis.new :asynchronic_test }
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
after do
|
10
|
+
data_store.clear
|
11
11
|
end
|
12
12
|
|
13
13
|
include LifeCycleExamples
|
data/spec/worker/redis_spec.rb
CHANGED
@@ -4,9 +4,9 @@ require_relative './worker_examples'
|
|
4
4
|
describe Asynchronic::Worker, 'Redis' do
|
5
5
|
|
6
6
|
let(:queue_engine) { Asynchronic::QueueEngine::Ost.new }
|
7
|
-
let(:data_store) { Asynchronic::DataStore::Redis.new }
|
7
|
+
let(:data_store) { Asynchronic::DataStore::Redis.new :asynchronic_test}
|
8
8
|
|
9
|
-
|
9
|
+
after do
|
10
10
|
data_store.clear
|
11
11
|
queue_engine.clear
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asynchronic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name: pry
|
154
|
+
name: pry-nav
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - '>='
|