arsenicum 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/arsenicum.gemspec +5 -0
- data/bin/arsenicum +1 -7
- data/lib/arsenicum.rb +23 -12
- data/lib/arsenicum/async.rb +3 -0
- data/lib/arsenicum/async/queue.rb +37 -0
- data/lib/arsenicum/async/queue/sqs.rb +27 -0
- data/lib/arsenicum/configuration.rb +114 -63
- data/lib/arsenicum/core.rb +6 -0
- data/lib/arsenicum/core/broker.rb +98 -0
- data/lib/arsenicum/core/commands.rb +15 -0
- data/lib/arsenicum/core/io_helper.rb +34 -0
- data/lib/arsenicum/core/worker.rb +91 -0
- data/lib/arsenicum/formatter.rb +127 -0
- data/lib/arsenicum/io.rb +3 -0
- data/lib/arsenicum/main.rb +23 -0
- data/lib/arsenicum/routing.rb +3 -0
- data/lib/arsenicum/routing/default.rb +3 -0
- data/lib/arsenicum/serializer.rb +3 -0
- data/lib/arsenicum/serializer/json.rb +11 -0
- data/lib/arsenicum/task.rb +10 -50
- data/lib/arsenicum/task/class_dispatcher.rb +15 -0
- data/lib/arsenicum/util.rb +48 -0
- data/lib/arsenicum/version.rb +1 -1
- data/lib/generators/arsenicum/migration/migration_generator.rb +32 -0
- data/lib/generators/arsenicum/migration/templates/active_record/migration.rb +15 -0
- data/spec/arsenicum/queueing/post_office_spec.rb +123 -0
- data/spec/arsenicum/queueing/serializer_spec.rb +70 -0
- data/spec/config/config.example.yml +22 -0
- data/spec/config/post_office_spec.yml +24 -0
- data/spec/rails_project/.gitignore +16 -0
- data/spec/rails_project/Gemfile +45 -0
- data/spec/rails_project/README.rdoc +28 -0
- data/spec/rails_project/Rakefile +6 -0
- data/spec/rails_project/app/assets/images/.keep +0 -0
- data/spec/rails_project/app/assets/javascripts/application.js +16 -0
- data/spec/rails_project/app/assets/stylesheets/application.css +13 -0
- data/spec/rails_project/app/controllers/application_controller.rb +5 -0
- data/spec/rails_project/app/controllers/concerns/.keep +0 -0
- data/spec/rails_project/app/helpers/application_helper.rb +2 -0
- data/spec/rails_project/app/mailers/.keep +0 -0
- data/spec/rails_project/app/models/.keep +0 -0
- data/spec/rails_project/app/models/concerns/.keep +0 -0
- data/spec/rails_project/app/models/sample.rb +2 -0
- data/spec/rails_project/app/views/layouts/application.html.erb +14 -0
- data/spec/rails_project/bin/bundle +3 -0
- data/spec/rails_project/bin/rails +4 -0
- data/spec/rails_project/bin/rake +4 -0
- data/spec/rails_project/config.ru +4 -0
- data/spec/rails_project/config/application.rb +23 -0
- data/spec/rails_project/config/boot.rb +4 -0
- data/spec/rails_project/config/database.yml +25 -0
- data/spec/rails_project/config/environment.rb +5 -0
- data/spec/rails_project/config/environments/development.rb +29 -0
- data/spec/rails_project/config/environments/production.rb +80 -0
- data/spec/rails_project/config/environments/test.rb +36 -0
- data/spec/rails_project/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_project/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/rails_project/config/initializers/inflections.rb +16 -0
- data/spec/rails_project/config/initializers/mime_types.rb +5 -0
- data/spec/rails_project/config/initializers/secret_token.rb +12 -0
- data/spec/rails_project/config/initializers/session_store.rb +3 -0
- data/spec/rails_project/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails_project/config/locales/en.yml +23 -0
- data/spec/rails_project/config/routes.rb +56 -0
- data/spec/rails_project/db/migrate/20131210025434_create_samples.rb +9 -0
- data/spec/rails_project/db/schema.rb +22 -0
- data/spec/rails_project/db/seeds.rb +7 -0
- data/spec/rails_project/lib/assets/.keep +0 -0
- data/spec/rails_project/lib/tasks/.keep +0 -0
- data/spec/rails_project/log/.keep +0 -0
- data/spec/rails_project/public/404.html +58 -0
- data/spec/rails_project/public/422.html +58 -0
- data/spec/rails_project/public/500.html +57 -0
- data/spec/rails_project/public/favicon.ico +0 -0
- data/spec/rails_project/public/robots.txt +5 -0
- data/spec/rails_project/test/controllers/.keep +0 -0
- data/spec/rails_project/test/helpers/.keep +0 -0
- data/spec/rails_project/test/integration/.keep +0 -0
- data/spec/rails_project/test/mailers/.keep +0 -0
- data/spec/rails_project/test/test_helper.rb +15 -0
- data/spec/rails_project/vendor/assets/javascripts/.keep +0 -0
- data/spec/rails_project/vendor/assets/stylesheets/.keep +0 -0
- data/spec/spec_helper.rb +5 -0
- metadata +217 -27
- data/lib/arsenicum/actor.rb +0 -14
- data/lib/arsenicum/cli.rb +0 -54
- data/lib/arsenicum/cli/rails.rb +0 -26
- data/lib/arsenicum/queue.rb +0 -58
- data/lib/arsenicum/queue_proxy.rb +0 -73
- data/lib/arsenicum/rake_tasks.rake +0 -24
- data/lib/arsenicum/serialization.rb +0 -110
- data/lib/arsenicum/server.rb +0 -40
- data/lib/arsenicum/sqs.rb +0 -5
- data/lib/arsenicum/sqs/queue.rb +0 -76
- data/lib/arsenicum/syntax.rb +0 -11
- data/lib/arsenicum/syntax/delayed_job.rb +0 -25
- data/lib/arsenicum/watchdog.rb +0 -68
- data/spec/config.example.yml +0 -21
data/lib/arsenicum/syntax.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
module Arsenucum
|
2
|
-
module Syntax
|
3
|
-
autoload :DelayedJob, 'arsenicum/syntax/delayed_job'
|
4
|
-
|
5
|
-
def self.choose(syntax)
|
6
|
-
syntax_impl =
|
7
|
-
const_get syntax.to_s.gsub(/_([a-z])/){$1.upcase}.gsub(/^([a-z])/){$1.upcase}.to_sym
|
8
|
-
syntax_impl.enable!
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Arsenicum::Syntax
|
2
|
-
module DelayedJob
|
3
|
-
class DelayedObject < BasicObject
|
4
|
-
def initialize(wrapped_object)
|
5
|
-
@wrapped_object = wrapped_object
|
6
|
-
end
|
7
|
-
|
8
|
-
def method_missing(method_id, *arguments)
|
9
|
-
Arsenicum::QueueProxy.instance.async(@wrapped_object, method_id, *arguments)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module ObjectExt
|
14
|
-
def delay
|
15
|
-
DelayedObject.new(self)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class <<self
|
20
|
-
def enable!
|
21
|
-
Object.__send__(:include, ObjectExt)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/arsenicum/watchdog.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
module Arsenicum
|
2
|
-
class WatchDog
|
3
|
-
attr_reader :queue, :logger
|
4
|
-
|
5
|
-
def initialize(queue, logger)
|
6
|
-
@queue = queue
|
7
|
-
@logger = logger
|
8
|
-
|
9
|
-
@task_queue = Array.new
|
10
|
-
@mutex = Mutex.new
|
11
|
-
@workers = queue.concurrency.times.map{|_|create_worker}
|
12
|
-
end
|
13
|
-
|
14
|
-
def boot
|
15
|
-
@main_thread = Thread.new do
|
16
|
-
loop do
|
17
|
-
message = queue.poll
|
18
|
-
logger.debug { "received message #{message.inspect}" }
|
19
|
-
next unless message
|
20
|
-
|
21
|
-
# FIXME: overtime queue stocking.
|
22
|
-
@mutex.synchronize do
|
23
|
-
@task_queue.push Task.parse(message[:message_body], message[:message_id])
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def shutdown
|
30
|
-
@workers.each do |worker|
|
31
|
-
begin
|
32
|
-
worker.terminate
|
33
|
-
rescue Exception
|
34
|
-
end
|
35
|
-
end
|
36
|
-
begin
|
37
|
-
@main_thread.terminate
|
38
|
-
rescue Exception
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
def create_worker
|
44
|
-
Worker.new(@task_queue, @queue, @mutex)
|
45
|
-
end
|
46
|
-
|
47
|
-
#:nodoc:
|
48
|
-
class Worker < ::Thread
|
49
|
-
attr_reader :running
|
50
|
-
|
51
|
-
def initialize(task_queue, queue, mutex)
|
52
|
-
super do
|
53
|
-
loop do
|
54
|
-
mutex.synchronize { task = task_queue.shift }
|
55
|
-
|
56
|
-
unless task
|
57
|
-
sleep 0.1
|
58
|
-
next
|
59
|
-
end
|
60
|
-
|
61
|
-
task.execute!
|
62
|
-
queue.update_message_status(task.message_id, task.successful?, task.serialize)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/spec/config.example.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
queue_type: sqs
|
2
|
-
queues:
|
3
|
-
default:
|
4
|
-
concurrency: 10
|
5
|
-
sample01:
|
6
|
-
concurrency: 3
|
7
|
-
methods:
|
8
|
-
- 'SampleA#hoge1'
|
9
|
-
- 'SampleB.hoge2'
|
10
|
-
classes:
|
11
|
-
- 'ClassInvocation1'
|
12
|
-
sample02:
|
13
|
-
concurrency: 2
|
14
|
-
methods:
|
15
|
-
- 'SampleA#hoge2'
|
16
|
-
- 'SampleB.hoge1'
|
17
|
-
sqs:
|
18
|
-
account:
|
19
|
-
access_key_id: 'YOUR_ACCESS_KEY_ID'
|
20
|
-
secret_access_key: 'YOUR SECRET ACCESS KEY'
|
21
|
-
region: 'ap-northeast-1'
|