rocketjob 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ class WorkerTest < Minitest::Test
7
7
  [true, false].each do |inline_mode|
8
8
  setup do
9
9
  RocketJob::Config.inline_mode = inline_mode
10
+
10
11
  @worker = RocketJob::Worker.new
11
12
  @worker.started
12
13
  end
@@ -21,36 +22,36 @@ class WorkerTest < Minitest::Test
21
22
  @job = Jobs::TestJob.perform_later(1) do |job|
22
23
  job.destroy_on_complete = false
23
24
  end
24
- assert_nil @job.worker_name
25
- assert_nil @job.completed_at
26
- assert @job.created_at
27
- assert_nil @job.description
25
+ assert_nil @job.worker_name
26
+ assert_nil @job.completed_at
27
+ assert @job.created_at
28
+ assert_nil @job.description
28
29
  assert_equal false, @job.destroy_on_complete
29
- assert_nil @job.expires_at
30
+ assert_nil @job.expires_at
30
31
  assert_equal 0, @job.percent_complete
31
32
  assert_equal 50, @job.priority
32
33
  assert_equal 0, @job.failure_count
33
- assert_nil @job.run_at
34
- assert_nil @job.started_at
34
+ assert_nil @job.run_at
35
+ assert_nil @job.started_at
35
36
  assert_equal :queued, @job.state
36
37
 
37
38
  @job.worker_name = 'me'
38
39
  @job.start
39
- assert_equal false, @job.work(@worker), @job.exception.inspect
40
+ assert_equal false, @job.work(@worker), @job.exception.inspect
40
41
  assert_equal true, @job.completed?
41
- assert_equal 2, Jobs::TestJob.result
42
+ assert_equal 2, Jobs::TestJob.result
42
43
 
43
- assert_nil @job.worker_name
44
- assert @job.completed_at
45
- assert @job.created_at
46
- assert_nil @job.description
44
+ assert_nil @job.worker_name
45
+ assert @job.completed_at
46
+ assert @job.created_at
47
+ assert_nil @job.description
47
48
  assert_equal false, @job.destroy_on_complete
48
- assert_nil @job.expires_at
49
+ assert_nil @job.expires_at
49
50
  assert_equal 100, @job.percent_complete
50
51
  assert_equal 50, @job.priority
51
52
  assert_equal 0, @job.failure_count
52
- assert_nil @job.run_at
53
- assert @job.started_at
53
+ assert_nil @job.run_at
54
+ assert @job.started_at
54
55
  end
55
56
  end
56
57
 
@@ -59,24 +60,24 @@ class WorkerTest < Minitest::Test
59
60
  @job = Jobs::TestJob.later(:sum, 23, 45)
60
61
  @job.start
61
62
  assert_equal false, @job.work(@worker), @job.exception.inspect
62
- assert_equal true, @job.completed?
63
- assert_equal 68, Jobs::TestJob.result
63
+ assert_equal true, @job.completed?
64
+ assert_equal 68, Jobs::TestJob.result
64
65
  end
65
66
  end
66
67
 
67
68
  context '.perform_now' do
68
69
  should "process perform (inline_mode=#{inline_mode})" do
69
70
  @job = Jobs::TestJob.perform_now(5)
70
- assert_equal true, @job.completed?
71
- assert_equal 6, Jobs::TestJob.result
71
+ assert_equal true, @job.completed?
72
+ assert_equal 6, Jobs::TestJob.result
72
73
  end
73
74
  end
74
75
 
75
76
  context '.now' do
76
77
  should "process non default method (inline_mode=#{inline_mode})" do
77
78
  @job = Jobs::TestJob.now(:sum, 23, 45)
78
- assert_equal true, @job.completed?, @job.inspect
79
- assert_equal 68, Jobs::TestJob.result
79
+ assert_equal true, @job.completed?, @job.inspect
80
+ assert_equal 68, Jobs::TestJob.result
80
81
  end
81
82
  end
82
83
 
data/test/test_helper.rb CHANGED
@@ -15,20 +15,21 @@ SemanticLogger.add_appender('test.log', &SemanticLogger::Appender::Base.colorize
15
15
  SemanticLogger.default_level = :debug
16
16
 
17
17
  # Setup MongoMapper from mongo config file
18
- config_file = File.join(File.dirname(__FILE__), 'config', 'mongo.yml')
19
- if config = YAML.load(ERB.new(File.read(config_file)).result)
20
- cfg = config['test']
21
- options = cfg['options'] || {}
22
- options[:logger] = SemanticLogger::DebugAsTraceLogger.new('Mongo')
18
+ config_file = File.join(File.dirname(__FILE__), 'config', 'mongo.yml')
19
+ config = YAML.load(ERB.new(File.read(config_file)).result)
20
+ if config
21
+ cfg = config['test']
22
+ options = cfg['options'] || {}
23
+ options[:logger] = SemanticLogger::DebugAsTraceLogger.new('Mongo')
23
24
 
24
25
  MongoMapper.config = cfg
25
26
  MongoMapper.connection = Mongo::MongoClient.from_uri(cfg['uri'], options)
26
27
  MongoMapper.database = MongoMapper.connection.db.name
27
28
 
28
29
  # If this environment has a separate Work server
29
- if cfg = config['test_work']
30
- options = cfg['options'] || {}
31
- options[:logger] = SemanticLogger::DebugAsTraceLogger.new('MongoWork')
30
+ if (cfg = config['test_work'])
31
+ options = cfg['options'] || {}
32
+ options[:logger] = SemanticLogger::DebugAsTraceLogger.new('MongoWork')
32
33
  RocketJob::Config.mongo_work_connection = Mongo::MongoClient.from_uri(cfg['uri'], options)
33
34
  end
34
35
  end
@@ -40,4 +41,3 @@ SymmetricEncryption.cipher = SymmetricEncryption::Cipher.new(
40
41
  iv: '1234567890ABCDEF',
41
42
  encoding: :base64strict
42
43
  )
43
-
data/test/worker_test.rb CHANGED
@@ -7,10 +7,11 @@ class WorkerTest < Minitest::Test
7
7
  setup do
8
8
  RocketJob::Config.instance.heartbeat_seconds = 0.1
9
9
  RocketJob::Config.instance.max_poll_seconds = 0.1
10
- @worker = RocketJob::Worker.new
10
+
11
+ @worker = RocketJob::Worker.new
11
12
  @description = 'Hello World'
12
- @arguments = [ 1 ]
13
- @job = Jobs::TestJob.new(
13
+ @arguments = [1]
14
+ @job = Jobs::TestJob.new(
14
15
  description: @description,
15
16
  arguments: @arguments,
16
17
  destroy_on_complete: false
@@ -29,7 +30,10 @@ class WorkerTest < Minitest::Test
29
30
 
30
31
  context '#run' do
31
32
  should 'run a worker' do
32
- Thread.new { sleep 1; @worker.stop!}
33
+ Thread.new do
34
+ sleep 1
35
+ @worker.stop!
36
+ end
33
37
  @worker.run
34
38
  assert_equal :stopping, @worker.state, @worker.inspect
35
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm
@@ -108,8 +108,8 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.0'
111
- description: High volume, priority based, distributed, background job processing solution
112
- for Ruby
111
+ description: Next generation, high performance, priority based, distributed, background
112
+ job processing solution
113
113
  email:
114
114
  - reidmo@gmail.com
115
115
  executables:
@@ -121,6 +121,7 @@ files:
121
121
  - Rakefile
122
122
  - bin/rocketjob
123
123
  - lib/rocket_job/cli.rb
124
+ - lib/rocket_job/concerns/singleton.rb
124
125
  - lib/rocket_job/concerns/worker.rb
125
126
  - lib/rocket_job/config.rb
126
127
  - lib/rocket_job/dirmon_entry.rb
@@ -162,7 +163,7 @@ rubyforge_project:
162
163
  rubygems_version: 2.4.8
163
164
  signing_key:
164
165
  specification_version: 4
165
- summary: Background job processing system for Ruby
166
+ summary: Next generation background job processing system for Ruby, JRuby and Rubinius
166
167
  test_files:
167
168
  - test/config/mongo.yml
168
169
  - test/dirmon_entry_test.rb