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.
@@ -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
 
@@ -3,11 +3,12 @@ module Scales
3
3
  require 'ostruct'
4
4
 
5
5
  DEFAULTS = {
6
- :host => "localhost",
7
- :port => 6379,
8
- :password => nil,
9
- :database => 0,
10
- :partials => false
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
@@ -1,7 +1,9 @@
1
1
  module Scales
2
2
  module Storage
3
- RESOURCE_PREFIX = "scales_resource_"
4
- PARTIAL_PREFIX = "scales_partial_"
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
@@ -1,5 +1,5 @@
1
1
  module Scales
2
2
  module Core
3
- VERSION = "0.0.1.beta.2"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
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.1.beta.2
5
- prerelease: 6
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-01 00:00:00.000000000 Z
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: &70255207144860 !ruby/object:Gem::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: *70255207144860
24
+ version_requirements: *70234372078440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70255207165340 !ruby/object:Gem::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: *70255207165340
35
+ version_requirements: *70234372077940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: redis
38
- requirement: &70255207164180 !ruby/object:Gem::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: *70255207164180
46
+ version_requirements: *70234372077480
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eventmachine
49
- requirement: &70255207162480 !ruby/object:Gem::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: *70255207162480
57
+ version_requirements: *70234372077020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: em-http-request
60
- requirement: &70255207159640 !ruby/object:Gem::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: *70255207159640
68
+ version_requirements: *70234372076560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: em-synchrony
71
- requirement: &70255207158940 !ruby/object:Gem::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: *70255207158940
79
+ version_requirements: *70234372076100
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: em-hiredis
82
- requirement: &70255207180260 !ruby/object:Gem::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: *70255207180260
90
+ version_requirements: *70234355518060
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: json
93
- requirement: &70255207179000 !ruby/object:Gem::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: *70255207179000
101
+ version_requirements: *70234355517600
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: colorize
104
- requirement: &70255207176620 !ruby/object:Gem::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: *70255207176620
112
+ version_requirements: *70234355517140
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: thor
115
- requirement: &70255207175620 !ruby/object:Gem::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: *70255207175620
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: 1.3.1
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
@@ -1,6 +0,0 @@
1
- module Scales
2
- module PubSub
3
- autoload :Sync, "scales-core/pub_sub/sync"
4
- autoload :Async, "scales-core/pub_sub/async"
5
- end
6
- end
@@ -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
@@ -1,17 +0,0 @@
1
- module Scales
2
- module PubSub
3
- module Sync
4
- class << self
5
-
6
- def publish(channel, message)
7
- Storage::Sync.publish(channel, message)
8
- end
9
-
10
- def subscribe(channel)
11
- Storage::Sync.subscribe(channel)
12
- end
13
-
14
- end
15
- end
16
- end
17
- end
@@ -1,8 +0,0 @@
1
- module Scales
2
- module Queue
3
- NAME = "scales_request_queue"
4
-
5
- autoload :Sync, "scales-core/queue/sync"
6
- autoload :Async, "scales-core/queue/async"
7
- end
8
- end
@@ -1,18 +0,0 @@
1
- module Scales
2
- module Queue
3
- module Async
4
- class << self
5
-
6
- def add(job)
7
- Storage::Async.add(Queue::NAME, job)
8
- end
9
-
10
- def pop
11
- Storage::Async.pop(Queue::NAME)
12
- end
13
-
14
- end
15
-
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- module Scales
2
- module Queue
3
- module Sync
4
- class << self
5
-
6
- def add(job)
7
- Storage::Sync.add(Queue::NAME, job)
8
- end
9
-
10
- def pop
11
- Storage::Sync.pop(Queue::NAME)
12
- end
13
-
14
- end
15
-
16
- end
17
- end
18
- end
@@ -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
@@ -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