scales-core 0.0.1.beta.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/scales-core.rb +0 -2
- data/lib/scales-core/config.rb +6 -5
- data/lib/scales-core/scalify/templates/cache.yml +4 -1
- data/lib/scales-core/storage.rb +4 -2
- data/lib/scales-core/storage/async.rb +8 -0
- data/lib/scales-core/storage/sync.rb +8 -0
- data/lib/scales-core/version.rb +1 -1
- metadata +25 -35
- data/lib/scales-core/pub_sub.rb +0 -6
- data/lib/scales-core/pub_sub/async.rb +0 -19
- data/lib/scales-core/pub_sub/sync.rb +0 -17
- data/lib/scales-core/queue.rb +0 -8
- data/lib/scales-core/queue/async.rb +0 -18
- data/lib/scales-core/queue/sync.rb +0 -18
- data/spec/pub_sub_spec.rb +0 -51
- data/spec/queue_spec.rb +0 -37
data/lib/scales-core.rb
CHANGED
@@ -4,8 +4,6 @@ module Scales
|
|
4
4
|
autoload :Helper, "scales-core/helper"
|
5
5
|
autoload :Config, "scales-core/config"
|
6
6
|
autoload :Storage, "scales-core/storage"
|
7
|
-
autoload :Queue, "scales-core/queue"
|
8
|
-
autoload :PubSub, "scales-core/pub_sub"
|
9
7
|
autoload :Scalify, "scales-core/scalify"
|
10
8
|
end
|
11
9
|
|
data/lib/scales-core/config.rb
CHANGED
@@ -3,11 +3,12 @@ module Scales
|
|
3
3
|
require 'ostruct'
|
4
4
|
|
5
5
|
DEFAULTS = {
|
6
|
-
:host
|
7
|
-
:port
|
8
|
-
:password
|
9
|
-
:database
|
10
|
-
:partials
|
6
|
+
:host => "localhost",
|
7
|
+
:port => 6379,
|
8
|
+
:password => nil,
|
9
|
+
:database => 0,
|
10
|
+
:partials => false,
|
11
|
+
:worker_threads => 30
|
11
12
|
}
|
12
13
|
|
13
14
|
@@pwd = "."
|
@@ -4,6 +4,7 @@ development:
|
|
4
4
|
password:
|
5
5
|
database: 1
|
6
6
|
partials: false
|
7
|
+
worker_threads: 10
|
7
8
|
|
8
9
|
test:
|
9
10
|
host: localhost
|
@@ -11,10 +12,12 @@ test:
|
|
11
12
|
password:
|
12
13
|
database: 2
|
13
14
|
partials: false
|
15
|
+
worker_threads: 5
|
14
16
|
|
15
17
|
production:
|
16
18
|
host: localhost
|
17
19
|
port: 6379
|
18
20
|
password:
|
19
21
|
database: 0
|
20
|
-
partials: false
|
22
|
+
partials: false
|
23
|
+
worker_threads: 30
|
data/lib/scales-core/storage.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Scales
|
2
2
|
module Storage
|
3
|
-
|
4
|
-
|
3
|
+
REQUEST_QUEUE = "scales_request_queue"
|
4
|
+
RESPONSE_CHANNEL = "scales_response_channel"
|
5
|
+
RESOURCE_PREFIX = "scales_resource_"
|
6
|
+
PARTIAL_PREFIX = "scales_partial_"
|
5
7
|
|
6
8
|
autoload :Sync, "scales-core/storage/sync"
|
7
9
|
autoload :Async, "scales-core/storage/async"
|
@@ -2,6 +2,7 @@ module Scales
|
|
2
2
|
module Storage
|
3
3
|
module Async
|
4
4
|
@@redis = nil
|
5
|
+
@@pids = [Process.pid]
|
5
6
|
|
6
7
|
class << self
|
7
8
|
|
@@ -69,6 +70,13 @@ module Scales
|
|
69
70
|
private
|
70
71
|
|
71
72
|
def with_connection
|
73
|
+
|
74
|
+
# Reconnects forks
|
75
|
+
unless @@pids.include?(Process.pid)
|
76
|
+
force_reconnect!
|
77
|
+
@@pids << Process.pid
|
78
|
+
end
|
79
|
+
|
72
80
|
connect!
|
73
81
|
yield
|
74
82
|
end
|
@@ -2,6 +2,7 @@ module Scales
|
|
2
2
|
module Storage
|
3
3
|
module Sync
|
4
4
|
@@redis = nil
|
5
|
+
@@pids = [Process.pid]
|
5
6
|
|
6
7
|
class << self
|
7
8
|
|
@@ -74,6 +75,13 @@ module Scales
|
|
74
75
|
private
|
75
76
|
|
76
77
|
def with_connection
|
78
|
+
|
79
|
+
# Reconnects forks
|
80
|
+
unless @@pids.include?(Process.pid)
|
81
|
+
force_reconnect!
|
82
|
+
@@pids << Process.pid
|
83
|
+
end
|
84
|
+
|
77
85
|
connect!
|
78
86
|
yield
|
79
87
|
end
|
data/lib/scales-core/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scales-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thomas Fankhauser
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70234372078440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.9.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70234372078440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70234372077940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.11'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70234372077940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: redis
|
38
|
-
requirement: &
|
38
|
+
requirement: &70234372077480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 3.0.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70234372077480
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: eventmachine
|
49
|
-
requirement: &
|
49
|
+
requirement: &70234372077020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.0.beta.4
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70234372077020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: em-http-request
|
60
|
-
requirement: &
|
60
|
+
requirement: &70234372076560 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.0.2
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70234372076560
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: em-synchrony
|
71
|
-
requirement: &
|
71
|
+
requirement: &70234372076100 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.0.2
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70234372076100
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: em-hiredis
|
82
|
-
requirement: &
|
82
|
+
requirement: &70234355518060 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.1.1
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70234355518060
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: json
|
93
|
-
requirement: &
|
93
|
+
requirement: &70234355517600 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.7.4
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70234355517600
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: colorize
|
104
|
-
requirement: &
|
104
|
+
requirement: &70234355517140 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 0.5.8
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70234355517140
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: thor
|
115
|
-
requirement: &
|
115
|
+
requirement: &70234355516680 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version: 0.15.4
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70234355516680
|
124
124
|
description: Super Scale Caching Framework - Core
|
125
125
|
email:
|
126
126
|
- tommylefunk@googlemail.com
|
@@ -152,12 +152,6 @@ files:
|
|
152
152
|
- lib/scales-core/helper.rb
|
153
153
|
- lib/scales-core/helper/content_types.rb
|
154
154
|
- lib/scales-core/helper/partial_resolver.rb
|
155
|
-
- lib/scales-core/pub_sub.rb
|
156
|
-
- lib/scales-core/pub_sub/async.rb
|
157
|
-
- lib/scales-core/pub_sub/sync.rb
|
158
|
-
- lib/scales-core/queue.rb
|
159
|
-
- lib/scales-core/queue/async.rb
|
160
|
-
- lib/scales-core/queue/sync.rb
|
161
155
|
- lib/scales-core/scalify.rb
|
162
156
|
- lib/scales-core/scalify/templates/cache.yml
|
163
157
|
- lib/scales-core/scalify/templates/scaleup.rb
|
@@ -172,8 +166,6 @@ files:
|
|
172
166
|
- spec/gem_spec.rb
|
173
167
|
- spec/helper.rb
|
174
168
|
- spec/partial_resolver_spec.rb
|
175
|
-
- spec/pub_sub_spec.rb
|
176
|
-
- spec/queue_spec.rb
|
177
169
|
- spec/scalify_spec.rb
|
178
170
|
- spec/storage_spec.rb
|
179
171
|
homepage: http://itscales.org
|
@@ -191,9 +183,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
191
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
184
|
none: false
|
193
185
|
requirements:
|
194
|
-
- - ! '
|
186
|
+
- - ! '>='
|
195
187
|
- !ruby/object:Gem::Version
|
196
|
-
version:
|
188
|
+
version: '0'
|
197
189
|
requirements: []
|
198
190
|
rubyforge_project:
|
199
191
|
rubygems_version: 1.8.11
|
@@ -207,7 +199,5 @@ test_files:
|
|
207
199
|
- spec/gem_spec.rb
|
208
200
|
- spec/helper.rb
|
209
201
|
- spec/partial_resolver_spec.rb
|
210
|
-
- spec/pub_sub_spec.rb
|
211
|
-
- spec/queue_spec.rb
|
212
202
|
- spec/scalify_spec.rb
|
213
203
|
- spec/storage_spec.rb
|
data/lib/scales-core/pub_sub.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Scales
|
2
|
-
module PubSub
|
3
|
-
module Async
|
4
|
-
class << self
|
5
|
-
|
6
|
-
def publish(channel, message)
|
7
|
-
Storage::Async.publish(channel, message)
|
8
|
-
end
|
9
|
-
|
10
|
-
def subscribe(channel)
|
11
|
-
out = Storage::Async.subscribe(channel)
|
12
|
-
Storage::Async.connection.del(channel)
|
13
|
-
out
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/scales-core/queue.rb
DELETED
data/spec/pub_sub_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Scales::PubSub::Async do
|
4
|
-
|
5
|
-
it "should publish a few responses" do
|
6
|
-
async do
|
7
|
-
Scales::PubSub::Async.publish "channel1", "response 1"
|
8
|
-
Scales::PubSub::Async.publish "channel2", "response 2"
|
9
|
-
Scales::PubSub::Async.publish "channel3", "response 3"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should subscribe to a few channels" do
|
14
|
-
async do
|
15
|
-
Scales::PubSub::Async.subscribe("channel1").should == "response 1"
|
16
|
-
Scales::PubSub::Async.subscribe("channel2").should == "response 2"
|
17
|
-
Scales::PubSub::Async.subscribe("channel3").should == "response 3"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
describe Scales::PubSub::Sync do
|
24
|
-
|
25
|
-
it "should publish a few responses" do
|
26
|
-
Scales::PubSub::Sync.publish "channel1", "response 1"
|
27
|
-
Scales::PubSub::Sync.publish "channel2", "response 2"
|
28
|
-
Scales::PubSub::Sync.publish "channel3", "response 3"
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should subscribe to a few channels" do
|
32
|
-
Scales::PubSub::Sync.subscribe("channel1").should == "response 1"
|
33
|
-
Scales::PubSub::Sync.subscribe("channel2").should == "response 2"
|
34
|
-
Scales::PubSub::Sync.subscribe("channel3").should == "response 3"
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
describe Scales::PubSub do
|
40
|
-
|
41
|
-
it "subscribes async and pushes sync" do
|
42
|
-
Thread.new do
|
43
|
-
sleep 2
|
44
|
-
Scales::PubSub::Sync.publish "channel1", "response 1"
|
45
|
-
end
|
46
|
-
async do
|
47
|
-
Scales::PubSub::Async.subscribe("channel1").should == "response 1"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/spec/queue_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Scales::Queue::Sync do
|
4
|
-
|
5
|
-
it "should place a few jobs" do
|
6
|
-
Scales::Queue::Sync.add "job 1"
|
7
|
-
Scales::Queue::Sync.add "job 2"
|
8
|
-
Scales::Queue::Sync.add "job 3"
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should take them out blocking" do
|
12
|
-
Scales::Queue::Sync.pop.should == "job 1"
|
13
|
-
Scales::Queue::Sync.pop.should == "job 2"
|
14
|
-
Scales::Queue::Sync.pop.should == "job 3"
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
describe Scales::Queue::Async do
|
20
|
-
|
21
|
-
it "should place a few jobs" do
|
22
|
-
async do
|
23
|
-
Scales::Queue::Async.add "job 1"
|
24
|
-
Scales::Queue::Async.add "job 2"
|
25
|
-
Scales::Queue::Async.add "job 3"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should take them out blocking" do
|
30
|
-
async do
|
31
|
-
Scales::Queue::Async.pop.should == "job 1"
|
32
|
-
Scales::Queue::Async.pop.should == "job 2"
|
33
|
-
Scales::Queue::Async.pop.should == "job 3"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|