pallets 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/lib/pallets.rb +5 -3
- data/lib/pallets/dsl/workflow.rb +2 -5
- data/lib/pallets/serializers/msgpack.rb +15 -0
- data/lib/pallets/util.rb +27 -0
- data/lib/pallets/version.rb +1 -1
- data/lib/pallets/worker.rb +1 -1
- data/pallets.gemspec +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 388f932d85cba341084169563b80c6d18a0959f5
|
4
|
+
data.tar.gz: 04bbaa05f08caf6e53eaf632c13ee481abec2399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cde6012d314a8c543cb63a156f2a667cb8b926c9a18c18c89b5c52bed6c680c07e9f8235a9f4b37a36dba17031f8923f6d445a9f019bce4e7c97757954242409
|
7
|
+
data.tar.gz: 9493181596052789e359bdf5e079e23707f740bd9e97b6ebc56ab0974f85f528c4fbc905bb8695c61cfb6b6e1f77ce2b675c0213a9f6f39251e4b95dad7f71fe
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ That's basically it! Curious for more? Read on!
|
|
37
37
|
* reliable
|
38
38
|
* retries failed tasks
|
39
39
|
* Redis backend out of the box
|
40
|
-
* JSON
|
40
|
+
* JSON and msgpack serializers out of the box
|
41
41
|
* beautiful DSL
|
42
42
|
* convention over configuration
|
43
43
|
* thoroughly tested
|
data/lib/pallets.rb
CHANGED
@@ -11,12 +11,14 @@ require 'pallets/pool'
|
|
11
11
|
require 'pallets/scheduler'
|
12
12
|
require 'pallets/serializers/base'
|
13
13
|
require 'pallets/serializers/json'
|
14
|
+
require 'pallets/serializers/msgpack'
|
14
15
|
require 'pallets/task'
|
16
|
+
require 'pallets/util'
|
15
17
|
require 'pallets/worker'
|
16
18
|
require 'pallets/workflow'
|
17
19
|
|
18
|
-
require 'active_support/inflector'
|
19
20
|
require 'logger'
|
21
|
+
require 'securerandom'
|
20
22
|
|
21
23
|
module Pallets
|
22
24
|
def self.configuration
|
@@ -29,7 +31,7 @@ module Pallets
|
|
29
31
|
|
30
32
|
def self.backend
|
31
33
|
@backend ||= begin
|
32
|
-
cls = "Pallets::Backends::#{configuration.backend.capitalize}"
|
34
|
+
cls = Pallets::Util.constantize("Pallets::Backends::#{configuration.backend.capitalize}")
|
33
35
|
cls.new(
|
34
36
|
namespace: configuration.namespace,
|
35
37
|
blocking_timeout: configuration.blocking_timeout,
|
@@ -42,7 +44,7 @@ module Pallets
|
|
42
44
|
|
43
45
|
def self.serializer
|
44
46
|
@serializer ||= begin
|
45
|
-
cls = "Pallets::Serializers::#{configuration.serializer.capitalize}"
|
47
|
+
cls = Pallets::Util.constantize("Pallets::Serializers::#{configuration.serializer.capitalize}")
|
46
48
|
cls.new
|
47
49
|
end
|
48
50
|
end
|
data/lib/pallets/dsl/workflow.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
require 'active_support'
|
2
|
-
|
3
1
|
module Pallets
|
4
2
|
module DSL
|
5
3
|
module Workflow
|
6
|
-
def task(*args, &block)
|
7
|
-
options = args.extract_options!
|
4
|
+
def task(*args, **options, &block)
|
8
5
|
name, depends_on = if args.any?
|
9
6
|
[args.first, options[:depends_on]]
|
10
7
|
else
|
@@ -17,7 +14,7 @@ module Pallets
|
|
17
14
|
dependencies = Array(depends_on).compact.map(&:to_sym)
|
18
15
|
graph.add(name, dependencies)
|
19
16
|
|
20
|
-
class_name = options[:class_name] ||
|
17
|
+
class_name = options[:class_name] || Pallets::Util.camelize(name)
|
21
18
|
max_failures = options[:max_failures] || Pallets.configuration.max_failures
|
22
19
|
|
23
20
|
task_config[name] = {
|
data/lib/pallets/util.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Pallets
|
2
|
+
module Util
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def camelize(str)
|
6
|
+
str.to_s.gsub(/(?:^|_)([a-z])/) { $1.upcase }
|
7
|
+
end
|
8
|
+
|
9
|
+
def constantize(str)
|
10
|
+
names = str.split('::')
|
11
|
+
|
12
|
+
# Raise the "usual" NameError
|
13
|
+
Object.const_get(str) if names.empty?
|
14
|
+
|
15
|
+
# Handle "::Const" cases
|
16
|
+
names.shift if names.first.empty?
|
17
|
+
|
18
|
+
names.inject(Object) do |constant, name|
|
19
|
+
if constant.const_defined?(name, false)
|
20
|
+
constant.const_get(name, false)
|
21
|
+
else
|
22
|
+
constant.const_missing(name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/pallets/version.rb
CHANGED
data/lib/pallets/worker.rb
CHANGED
data/pallets.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = ["pallets"]
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "activesupport"
|
22
21
|
spec.add_dependency "redis"
|
22
|
+
spec.add_dependency "msgpack"
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.11"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pallets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Horak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: redis
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: msgpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -146,7 +146,9 @@ files:
|
|
146
146
|
- lib/pallets/scheduler.rb
|
147
147
|
- lib/pallets/serializers/base.rb
|
148
148
|
- lib/pallets/serializers/json.rb
|
149
|
+
- lib/pallets/serializers/msgpack.rb
|
149
150
|
- lib/pallets/task.rb
|
151
|
+
- lib/pallets/util.rb
|
150
152
|
- lib/pallets/version.rb
|
151
153
|
- lib/pallets/worker.rb
|
152
154
|
- lib/pallets/workflow.rb
|
@@ -170,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
172
|
version: '0'
|
171
173
|
requirements: []
|
172
174
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.6.14.1
|
174
176
|
signing_key:
|
175
177
|
specification_version: 4
|
176
178
|
summary: Toy workflow engine, written in Ruby
|