taskinator 0.0.16 → 0.0.17

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c4844721e58ee539e62099b0cf6a9181bad692b
4
- data.tar.gz: 00d8e01dbf3b6170231946bbeb18856bde5a6e8d
3
+ metadata.gz: 3936550148208b98dfaa2a841e97d322d14413b9
4
+ data.tar.gz: 92c8caa24c938962f8c5692dc5e45c9cfef012e2
5
5
  SHA512:
6
- metadata.gz: e2b21e17464032c8e59cbe5909ba1121b83e9cb77623f0314352563e416f10056b11e36e30717a3091ffa725d5f4ae6f5cc7f337bedf50b7cc41e606721ca672
7
- data.tar.gz: 9e342b0f899929985f87c86e063b503a310227adec593e6506a591ac8acc7ffc3cebd81b0159b091264f2da33574d842c05721a2d3c55c43759ec463ad6484e9
6
+ metadata.gz: 21b0b016cbdec925215d9a621c60859b2c8ff69cee341e350e0962b557b6b1b27338df3cf5b84a24c7858221461571f5710e7a44af14531f8e7d1ac6e5ce676f
7
+ data.tar.gz: ca89c615cc65798746ccbdcfdb14eca8ac0d5617f24359f1402bd7001e802a4ee6ddbc21cd43fece92971e76b5d22e421dd46c12a43e6090a0f8ea21267284d1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ v0.0.17 - 11 Jul 2015
2
+ ---
3
+ Fixed issue with `Task#each` method, which was causing a Segmentation fault.
4
+ Added `define_sequential_process` and `define_concurrent_process` methods for defining processes.
5
+ Added `ConsoleInstrumenter` instrumenter implementation.
6
+ Required `resque` for console and rake tasks, to make debugging easier
7
+
1
8
  v0.0.16 - 25 Jun 2015
2
9
  ---
3
10
  Added ability to enqueue the creation of processes; added a new worker, `CreateProcessWorker`
data/Gemfile.lock CHANGED
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- taskinator (0.0.16)
11
+ taskinator (0.0.17)
12
12
  connection_pool (>= 2.2.0)
13
13
  json (>= 1.8.2)
14
14
  redis (>= 3.2.1)
data/Rakefile CHANGED
@@ -6,9 +6,6 @@ RSpec::Core::RakeTask.new(:spec)
6
6
  task :test => :spec
7
7
  task :default => :spec
8
8
 
9
-
10
- # require 'resque'
11
- # require 'taskinator'
12
- # require_relative './spec/support/test_flow'
13
-
14
- # require 'resque/tasks'
9
+ require 'resque'
10
+ require 'resque/tasks'
11
+ require 'taskinator'
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "resque"
5
+ require "taskinator"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require "pry"
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -9,9 +9,30 @@ module Taskinator
9
9
  UndefinedProcessError = ProcessUndefinedError
10
10
 
11
11
  # defines a process
12
+
13
+ def define_sequential_process(*arg_list, &block)
14
+ factory = lambda {|definition, options|
15
+ Process.define_sequential_process_for(definition, options)
16
+ }
17
+ define_process(*arg_list + [factory], &block)
18
+ end
19
+
20
+ def define_concurrent_process(*arg_list, &block)
21
+ factory = lambda {|definition, options|
22
+ Process.define_concurrent_process_for(definition, options)
23
+ }
24
+ define_process(*arg_list + [factory], &block)
25
+ end
26
+
12
27
  def define_process(*arg_list, &block)
13
28
  raise ProcessAlreadyDefinedError if respond_to?(:_create_process_)
14
29
 
30
+ factory = arg_list.last.respond_to?(:call) ?
31
+ arg_list.pop :
32
+ lambda {|definition, options|
33
+ Process.define_sequential_process_for(definition, options)
34
+ }
35
+
15
36
  define_singleton_method :_create_process_ do |args, options={}|
16
37
 
17
38
  # TODO: better validation of arguments
@@ -20,7 +41,7 @@ module Taskinator
20
41
 
21
42
  raise ArgumentError, "wrong number of arguments (#{args.length} for #{arg_list.length})" if args.length < arg_list.length
22
43
 
23
- process = Process.define_sequential_process_for(self, options)
44
+ process = factory.call(self, options)
24
45
 
25
46
  # this may take long... up to users definition
26
47
  Taskinator.instrumenter.instrument(:create_process, :uuid => process.uuid) do
@@ -162,6 +162,10 @@ module Taskinator
162
162
  # TODO: optimize this
163
163
  tasks.all?(&:completed?)
164
164
  end
165
+
166
+ def inspect
167
+ %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} state=:#{current_state.name}, tasks=[#{tasks.inspect}]>)
168
+ end
165
169
  end
166
170
 
167
171
  class Concurrent < Process
@@ -199,6 +203,10 @@ module Taskinator
199
203
  super
200
204
  visitor.visit_attribute(:complete_on)
201
205
  end
206
+
207
+ def inspect
208
+ %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} state=:#{current_state.name}, complete_on=:#{complete_on}, tasks=[#{tasks.inspect}]>)
209
+ end
202
210
  end
203
211
 
204
212
  # reloads the process from storage
@@ -166,6 +166,10 @@ module Taskinator
166
166
  visitor.visit_attribute(:method)
167
167
  visitor.visit_args(:args)
168
168
  end
169
+
170
+ def inspect
171
+ %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} method=:#{method}, state=:#{current_state.name}>)
172
+ end
169
173
  end
170
174
 
171
175
  # a task which invokes the specified background job
@@ -208,6 +212,10 @@ module Taskinator
208
212
  visitor.visit_type(:job)
209
213
  visitor.visit_args(:args)
210
214
  end
215
+
216
+ def inspect
217
+ %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} job=#{job}, state=:#{current_state.name}>)
218
+ end
211
219
  end
212
220
 
213
221
  # a task which delegates to another process
@@ -237,6 +245,10 @@ module Taskinator
237
245
  super
238
246
  visitor.visit_process(:sub_process)
239
247
  end
248
+
249
+ def inspect
250
+ %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} sub_process=#{sub_process.inspect}, state=:#{current_state.name}>)
251
+ end
240
252
  end
241
253
 
242
254
  # reloads the task from storage
@@ -31,7 +31,7 @@ module Taskinator
31
31
  @head.nil?
32
32
  end
33
33
 
34
- def each
34
+ def each(&block)
35
35
  return to_enum(__method__) unless block_given?
36
36
 
37
37
  current = @head
@@ -41,5 +41,9 @@ module Taskinator
41
41
  end
42
42
  end
43
43
 
44
+ def inspect
45
+ %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} tasks=[#{collect(&:inspect).join(', ')}]>)
46
+ end
47
+
44
48
  end
45
49
  end
@@ -1,3 +1,3 @@
1
1
  module Taskinator
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
data/lib/taskinator.rb CHANGED
@@ -34,6 +34,7 @@ module Taskinator
34
34
  LICENSE = 'See LICENSE.txt for licensing details.'
35
35
 
36
36
  DEFAULTS = {
37
+ # none for now...
37
38
  }
38
39
 
39
40
  class << self
@@ -121,4 +122,12 @@ module Taskinator
121
122
  end
122
123
  end
123
124
 
125
+ class ConsoleInstrumenter
126
+ # just yield to the given block
127
+ def instrument(event, payload={})
128
+ puts [event.inspect, payload.to_yaml]
129
+ yield(payload) if block_given?
130
+ end
131
+ end
132
+
124
133
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taskinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Stefano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-25 00:00:00.000000000 Z
11
+ date: 2015-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -237,7 +237,9 @@ dependencies:
237
237
  description: Simple process orchestration
238
238
  email:
239
239
  - virtualstaticvoid@gmail.com
240
- executables: []
240
+ executables:
241
+ - console
242
+ - setup
241
243
  extensions: []
242
244
  extra_rdoc_files: []
243
245
  files:
@@ -253,6 +255,8 @@ files:
253
255
  - LICENSE.txt
254
256
  - README.md
255
257
  - Rakefile
258
+ - bin/console
259
+ - bin/setup
256
260
  - lib/taskinator.rb
257
261
  - lib/taskinator/api.rb
258
262
  - lib/taskinator/complete_on.rb