massive 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +141 -0
- data/Guardfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +196 -0
- data/Rakefile +8 -0
- data/lib/massive.rb +63 -0
- data/lib/massive/cancelling.rb +20 -0
- data/lib/massive/file.rb +80 -0
- data/lib/massive/file_job.rb +9 -0
- data/lib/massive/file_process.rb +7 -0
- data/lib/massive/file_step.rb +7 -0
- data/lib/massive/job.rb +115 -0
- data/lib/massive/locking.rb +27 -0
- data/lib/massive/memory_consumption.rb +15 -0
- data/lib/massive/notifications.rb +40 -0
- data/lib/massive/notifiers.rb +6 -0
- data/lib/massive/notifiers/base.rb +32 -0
- data/lib/massive/notifiers/pusher.rb +17 -0
- data/lib/massive/process.rb +69 -0
- data/lib/massive/process_serializer.rb +12 -0
- data/lib/massive/retry.rb +49 -0
- data/lib/massive/status.rb +59 -0
- data/lib/massive/step.rb +143 -0
- data/lib/massive/step_serializer.rb +12 -0
- data/lib/massive/timing_support.rb +10 -0
- data/lib/massive/version.rb +3 -0
- data/massive.gemspec +23 -0
- data/spec/fixtures/custom_job.rb +4 -0
- data/spec/fixtures/custom_step.rb +19 -0
- data/spec/models/massive/cancelling_spec.rb +83 -0
- data/spec/models/massive/file_job_spec.rb +24 -0
- data/spec/models/massive/file_spec.rb +209 -0
- data/spec/models/massive/file_step_spec.rb +22 -0
- data/spec/models/massive/job_spec.rb +319 -0
- data/spec/models/massive/locking_spec.rb +52 -0
- data/spec/models/massive/memory_consumption_spec.rb +24 -0
- data/spec/models/massive/notifications_spec.rb +107 -0
- data/spec/models/massive/notifiers/base_spec.rb +48 -0
- data/spec/models/massive/notifiers/pusher_spec.rb +49 -0
- data/spec/models/massive/process_serializer_spec.rb +38 -0
- data/spec/models/massive/process_spec.rb +235 -0
- data/spec/models/massive/status_spec.rb +104 -0
- data/spec/models/massive/step_serializer_spec.rb +40 -0
- data/spec/models/massive/step_spec.rb +490 -0
- data/spec/models/massive/timing_support_spec.rb +55 -0
- data/spec/shared/step_context.rb +25 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/mongoid.yml +78 -0
- metadata +175 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
shared_examples_for Massive::TimingSupport do
|
2
|
+
include_context "frozen time"
|
3
|
+
|
4
|
+
context "when it has not been started" do
|
5
|
+
its(:elapsed_time) { should be_zero }
|
6
|
+
end
|
7
|
+
|
8
|
+
context "when it has been started" do
|
9
|
+
let(:started_at) { 1.minute.ago }
|
10
|
+
before { subject.started_at = started_at }
|
11
|
+
|
12
|
+
context "1 minute ago" do
|
13
|
+
context "and it has not been finished yet" do
|
14
|
+
its(:elapsed_time) { should eq(now - started_at) }
|
15
|
+
|
16
|
+
it { should_not be_completed }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "and it has been finished 10 seconds ago" do
|
20
|
+
let(:finished_at) { 10.seconds.ago }
|
21
|
+
before { subject.finished_at = finished_at }
|
22
|
+
|
23
|
+
its(:elapsed_time) { should eq(finished_at - started_at) }
|
24
|
+
|
25
|
+
it { should be_completed }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "2 hours ago" do
|
30
|
+
let(:started_at) { 2.hours.ago }
|
31
|
+
|
32
|
+
context "and it has not been finished yet" do
|
33
|
+
its(:elapsed_time) { should eq(now - started_at) }
|
34
|
+
|
35
|
+
it { should_not be_completed }
|
36
|
+
end
|
37
|
+
|
38
|
+
context "and has been finished 30 minutes ago" do
|
39
|
+
let(:finished_at) { 30.minutes.ago }
|
40
|
+
before { subject.finished_at = finished_at }
|
41
|
+
|
42
|
+
its(:elapsed_time) { should eq(finished_at - started_at) }
|
43
|
+
it { should be_completed }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe Massive::Step do
|
50
|
+
it_should_behave_like Massive::TimingSupport
|
51
|
+
end
|
52
|
+
|
53
|
+
describe Massive::Job do
|
54
|
+
it_should_behave_like Massive::TimingSupport
|
55
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
shared_context "stubbed memory_consumption" do
|
2
|
+
let(:current_memory_consumption) { 123456 }
|
3
|
+
|
4
|
+
before { subject.stub(:current_memory_consumption).and_return(current_memory_consumption) }
|
5
|
+
end
|
6
|
+
|
7
|
+
shared_context "frozen time" do
|
8
|
+
let!(:now) do
|
9
|
+
Time.now.tap do |now|
|
10
|
+
Time.stub(:now).and_return(now)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
shared_context "job processing" do
|
16
|
+
let(:item) { double(:item) }
|
17
|
+
let(:index) { 0 }
|
18
|
+
let(:retry_interval) { job.class.retry_interval }
|
19
|
+
let(:maximum_retries) { job.class.maximum_retries }
|
20
|
+
|
21
|
+
before do
|
22
|
+
Kernel.stub(:sleep)
|
23
|
+
job.stub(:each_item).and_yield(item, index)
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter 'spec'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'bundler/setup'
|
8
|
+
|
9
|
+
ENV['RACK_ENV'] ||= 'test'
|
10
|
+
|
11
|
+
Bundler.require :default, ENV['RACK_ENV']
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'debugger'
|
15
|
+
rescue LoadError
|
16
|
+
end
|
17
|
+
|
18
|
+
root = File.expand_path('../..', __FILE__)
|
19
|
+
|
20
|
+
Mongoid.load!(File.join(root, "spec/support/mongoid.yml"), :test)
|
21
|
+
|
22
|
+
Dir["#{root}/spec/shared/**/*.rb"].each { |f| require f }
|
23
|
+
Dir["#{root}/spec/fixtures/**/*.rb"].each { |f| require f }
|
24
|
+
|
25
|
+
RSpec.configure do |config|
|
26
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
27
|
+
config.run_all_when_everything_filtered = true
|
28
|
+
config.filter_run :focus
|
29
|
+
|
30
|
+
# Run specs in random order to surface order dependencies. If you find an
|
31
|
+
# order dependency and want to debug it, you can fix the order by providing
|
32
|
+
# the seed, which is printed after each run.
|
33
|
+
# --seed 1234
|
34
|
+
# config.order = 'random'
|
35
|
+
|
36
|
+
config.before do
|
37
|
+
DatabaseCleaner.clean_with(:truncation)
|
38
|
+
end
|
39
|
+
|
40
|
+
config.before { Massive.redis.flushdb }
|
41
|
+
config.after { Massive.redis.flushdb }
|
42
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
default_options: &default_options
|
2
|
+
raise_not_found_error: false
|
3
|
+
|
4
|
+
session_default_options: &session_default_options
|
5
|
+
consistency: :strong
|
6
|
+
safe: true
|
7
|
+
|
8
|
+
development:
|
9
|
+
# Configure available database sessions. (required)
|
10
|
+
sessions:
|
11
|
+
# Defines the default session. (required)
|
12
|
+
default:
|
13
|
+
# Defines the name of the default database that Mongoid can connect to.
|
14
|
+
# (required).
|
15
|
+
database: massive_development
|
16
|
+
# Provides the hosts the default session can connect to. Must be an array
|
17
|
+
# of host:port pairs. (required)
|
18
|
+
hosts:
|
19
|
+
- localhost:27017
|
20
|
+
options:
|
21
|
+
# Change whether the session persists in safe mode by default.
|
22
|
+
# (default: false)
|
23
|
+
# safe: false
|
24
|
+
|
25
|
+
# Change the default consistency model to :eventual or :strong.
|
26
|
+
# :eventual will send reads to secondaries, :strong sends everything
|
27
|
+
# to master. (default: :eventual)
|
28
|
+
<<: *session_default_options
|
29
|
+
# Configure Mongoid specific options. (optional)
|
30
|
+
options:
|
31
|
+
<<: *default_options
|
32
|
+
# Configuration for whether or not to allow access to fields that do
|
33
|
+
# not have a field definition on the model. (default: true)
|
34
|
+
# allow_dynamic_fields: true
|
35
|
+
|
36
|
+
# Enable the identity map, needed for eager loading. (default: false)
|
37
|
+
# identity_map_enabled: false
|
38
|
+
|
39
|
+
# Includes the root model name in json serialization. (default: false)
|
40
|
+
# include_root_in_json: false
|
41
|
+
|
42
|
+
# Include the _type field in serializaion. (default: false)
|
43
|
+
# include_type_for_serialization: false
|
44
|
+
|
45
|
+
# Preload all models in development, needed when models use
|
46
|
+
# inheritance. (default: false)
|
47
|
+
# preload_models: false
|
48
|
+
|
49
|
+
# Protect id and type from mass assignment. (default: true)
|
50
|
+
# protect_sensitive_fields: true
|
51
|
+
|
52
|
+
# Raise an error when performing a #find and the document is not found.
|
53
|
+
# (default: true)
|
54
|
+
# raise_not_found_error: false
|
55
|
+
|
56
|
+
# Raise an error when defining a scope with the same name as an
|
57
|
+
# existing method. (default: false)
|
58
|
+
# scope_overwrite_exception: false
|
59
|
+
|
60
|
+
# Skip the database version check, used when connecting to a db without
|
61
|
+
# admin access. (default: false)
|
62
|
+
# skip_version_check: false
|
63
|
+
|
64
|
+
# User Active Support's time zone in conversions. (default: true)
|
65
|
+
# use_activesupport_time_zone: true
|
66
|
+
|
67
|
+
# Ensure all times are UTC in the app side. (default: false)
|
68
|
+
# use_utc: false
|
69
|
+
test:
|
70
|
+
sessions:
|
71
|
+
default:
|
72
|
+
database: massive_test
|
73
|
+
hosts:
|
74
|
+
- localhost:27017
|
75
|
+
options:
|
76
|
+
<<: *session_default_options
|
77
|
+
options:
|
78
|
+
<<: *default_options
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: massive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vicente Mundim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: resque
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mongoid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.1.x
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.1.x
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: file_processor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: active_model_serializers
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Parallelize processing of large files and/or data using Resque, Redis
|
70
|
+
and MongoDB
|
71
|
+
email:
|
72
|
+
- vicente.mundim@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .rspec
|
79
|
+
- .rvmrc
|
80
|
+
- .travis.yml
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- Guardfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- lib/massive.rb
|
88
|
+
- lib/massive/cancelling.rb
|
89
|
+
- lib/massive/file.rb
|
90
|
+
- lib/massive/file_job.rb
|
91
|
+
- lib/massive/file_process.rb
|
92
|
+
- lib/massive/file_step.rb
|
93
|
+
- lib/massive/job.rb
|
94
|
+
- lib/massive/locking.rb
|
95
|
+
- lib/massive/memory_consumption.rb
|
96
|
+
- lib/massive/notifications.rb
|
97
|
+
- lib/massive/notifiers.rb
|
98
|
+
- lib/massive/notifiers/base.rb
|
99
|
+
- lib/massive/notifiers/pusher.rb
|
100
|
+
- lib/massive/process.rb
|
101
|
+
- lib/massive/process_serializer.rb
|
102
|
+
- lib/massive/retry.rb
|
103
|
+
- lib/massive/status.rb
|
104
|
+
- lib/massive/step.rb
|
105
|
+
- lib/massive/step_serializer.rb
|
106
|
+
- lib/massive/timing_support.rb
|
107
|
+
- lib/massive/version.rb
|
108
|
+
- massive.gemspec
|
109
|
+
- spec/fixtures/custom_job.rb
|
110
|
+
- spec/fixtures/custom_step.rb
|
111
|
+
- spec/models/massive/cancelling_spec.rb
|
112
|
+
- spec/models/massive/file_job_spec.rb
|
113
|
+
- spec/models/massive/file_spec.rb
|
114
|
+
- spec/models/massive/file_step_spec.rb
|
115
|
+
- spec/models/massive/job_spec.rb
|
116
|
+
- spec/models/massive/locking_spec.rb
|
117
|
+
- spec/models/massive/memory_consumption_spec.rb
|
118
|
+
- spec/models/massive/notifications_spec.rb
|
119
|
+
- spec/models/massive/notifiers/base_spec.rb
|
120
|
+
- spec/models/massive/notifiers/pusher_spec.rb
|
121
|
+
- spec/models/massive/process_serializer_spec.rb
|
122
|
+
- spec/models/massive/process_spec.rb
|
123
|
+
- spec/models/massive/status_spec.rb
|
124
|
+
- spec/models/massive/step_serializer_spec.rb
|
125
|
+
- spec/models/massive/step_spec.rb
|
126
|
+
- spec/models/massive/timing_support_spec.rb
|
127
|
+
- spec/shared/step_context.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
- spec/support/mongoid.yml
|
130
|
+
homepage:
|
131
|
+
licenses: []
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.2.2
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Parallelize processing of large files and/or data using Resque, Redis and
|
153
|
+
MongoDB
|
154
|
+
test_files:
|
155
|
+
- spec/fixtures/custom_job.rb
|
156
|
+
- spec/fixtures/custom_step.rb
|
157
|
+
- spec/models/massive/cancelling_spec.rb
|
158
|
+
- spec/models/massive/file_job_spec.rb
|
159
|
+
- spec/models/massive/file_spec.rb
|
160
|
+
- spec/models/massive/file_step_spec.rb
|
161
|
+
- spec/models/massive/job_spec.rb
|
162
|
+
- spec/models/massive/locking_spec.rb
|
163
|
+
- spec/models/massive/memory_consumption_spec.rb
|
164
|
+
- spec/models/massive/notifications_spec.rb
|
165
|
+
- spec/models/massive/notifiers/base_spec.rb
|
166
|
+
- spec/models/massive/notifiers/pusher_spec.rb
|
167
|
+
- spec/models/massive/process_serializer_spec.rb
|
168
|
+
- spec/models/massive/process_spec.rb
|
169
|
+
- spec/models/massive/status_spec.rb
|
170
|
+
- spec/models/massive/step_serializer_spec.rb
|
171
|
+
- spec/models/massive/step_spec.rb
|
172
|
+
- spec/models/massive/timing_support_spec.rb
|
173
|
+
- spec/shared/step_context.rb
|
174
|
+
- spec/spec_helper.rb
|
175
|
+
- spec/support/mongoid.yml
|