arsenicum 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/arsenicum.gemspec +5 -0
  4. data/bin/arsenicum +1 -7
  5. data/lib/arsenicum.rb +23 -12
  6. data/lib/arsenicum/async.rb +3 -0
  7. data/lib/arsenicum/async/queue.rb +37 -0
  8. data/lib/arsenicum/async/queue/sqs.rb +27 -0
  9. data/lib/arsenicum/configuration.rb +114 -63
  10. data/lib/arsenicum/core.rb +6 -0
  11. data/lib/arsenicum/core/broker.rb +98 -0
  12. data/lib/arsenicum/core/commands.rb +15 -0
  13. data/lib/arsenicum/core/io_helper.rb +34 -0
  14. data/lib/arsenicum/core/worker.rb +91 -0
  15. data/lib/arsenicum/formatter.rb +127 -0
  16. data/lib/arsenicum/io.rb +3 -0
  17. data/lib/arsenicum/main.rb +23 -0
  18. data/lib/arsenicum/routing.rb +3 -0
  19. data/lib/arsenicum/routing/default.rb +3 -0
  20. data/lib/arsenicum/serializer.rb +3 -0
  21. data/lib/arsenicum/serializer/json.rb +11 -0
  22. data/lib/arsenicum/task.rb +10 -50
  23. data/lib/arsenicum/task/class_dispatcher.rb +15 -0
  24. data/lib/arsenicum/util.rb +48 -0
  25. data/lib/arsenicum/version.rb +1 -1
  26. data/lib/generators/arsenicum/migration/migration_generator.rb +32 -0
  27. data/lib/generators/arsenicum/migration/templates/active_record/migration.rb +15 -0
  28. data/spec/arsenicum/queueing/post_office_spec.rb +123 -0
  29. data/spec/arsenicum/queueing/serializer_spec.rb +70 -0
  30. data/spec/config/config.example.yml +22 -0
  31. data/spec/config/post_office_spec.yml +24 -0
  32. data/spec/rails_project/.gitignore +16 -0
  33. data/spec/rails_project/Gemfile +45 -0
  34. data/spec/rails_project/README.rdoc +28 -0
  35. data/spec/rails_project/Rakefile +6 -0
  36. data/spec/rails_project/app/assets/images/.keep +0 -0
  37. data/spec/rails_project/app/assets/javascripts/application.js +16 -0
  38. data/spec/rails_project/app/assets/stylesheets/application.css +13 -0
  39. data/spec/rails_project/app/controllers/application_controller.rb +5 -0
  40. data/spec/rails_project/app/controllers/concerns/.keep +0 -0
  41. data/spec/rails_project/app/helpers/application_helper.rb +2 -0
  42. data/spec/rails_project/app/mailers/.keep +0 -0
  43. data/spec/rails_project/app/models/.keep +0 -0
  44. data/spec/rails_project/app/models/concerns/.keep +0 -0
  45. data/spec/rails_project/app/models/sample.rb +2 -0
  46. data/spec/rails_project/app/views/layouts/application.html.erb +14 -0
  47. data/spec/rails_project/bin/bundle +3 -0
  48. data/spec/rails_project/bin/rails +4 -0
  49. data/spec/rails_project/bin/rake +4 -0
  50. data/spec/rails_project/config.ru +4 -0
  51. data/spec/rails_project/config/application.rb +23 -0
  52. data/spec/rails_project/config/boot.rb +4 -0
  53. data/spec/rails_project/config/database.yml +25 -0
  54. data/spec/rails_project/config/environment.rb +5 -0
  55. data/spec/rails_project/config/environments/development.rb +29 -0
  56. data/spec/rails_project/config/environments/production.rb +80 -0
  57. data/spec/rails_project/config/environments/test.rb +36 -0
  58. data/spec/rails_project/config/initializers/backtrace_silencers.rb +7 -0
  59. data/spec/rails_project/config/initializers/filter_parameter_logging.rb +4 -0
  60. data/spec/rails_project/config/initializers/inflections.rb +16 -0
  61. data/spec/rails_project/config/initializers/mime_types.rb +5 -0
  62. data/spec/rails_project/config/initializers/secret_token.rb +12 -0
  63. data/spec/rails_project/config/initializers/session_store.rb +3 -0
  64. data/spec/rails_project/config/initializers/wrap_parameters.rb +14 -0
  65. data/spec/rails_project/config/locales/en.yml +23 -0
  66. data/spec/rails_project/config/routes.rb +56 -0
  67. data/spec/rails_project/db/migrate/20131210025434_create_samples.rb +9 -0
  68. data/spec/rails_project/db/schema.rb +22 -0
  69. data/spec/rails_project/db/seeds.rb +7 -0
  70. data/spec/rails_project/lib/assets/.keep +0 -0
  71. data/spec/rails_project/lib/tasks/.keep +0 -0
  72. data/spec/rails_project/log/.keep +0 -0
  73. data/spec/rails_project/public/404.html +58 -0
  74. data/spec/rails_project/public/422.html +58 -0
  75. data/spec/rails_project/public/500.html +57 -0
  76. data/spec/rails_project/public/favicon.ico +0 -0
  77. data/spec/rails_project/public/robots.txt +5 -0
  78. data/spec/rails_project/test/controllers/.keep +0 -0
  79. data/spec/rails_project/test/helpers/.keep +0 -0
  80. data/spec/rails_project/test/integration/.keep +0 -0
  81. data/spec/rails_project/test/mailers/.keep +0 -0
  82. data/spec/rails_project/test/test_helper.rb +15 -0
  83. data/spec/rails_project/vendor/assets/javascripts/.keep +0 -0
  84. data/spec/rails_project/vendor/assets/stylesheets/.keep +0 -0
  85. data/spec/spec_helper.rb +5 -0
  86. metadata +217 -27
  87. data/lib/arsenicum/actor.rb +0 -14
  88. data/lib/arsenicum/cli.rb +0 -54
  89. data/lib/arsenicum/cli/rails.rb +0 -26
  90. data/lib/arsenicum/queue.rb +0 -58
  91. data/lib/arsenicum/queue_proxy.rb +0 -73
  92. data/lib/arsenicum/rake_tasks.rake +0 -24
  93. data/lib/arsenicum/serialization.rb +0 -110
  94. data/lib/arsenicum/server.rb +0 -40
  95. data/lib/arsenicum/sqs.rb +0 -5
  96. data/lib/arsenicum/sqs/queue.rb +0 -76
  97. data/lib/arsenicum/syntax.rb +0 -11
  98. data/lib/arsenicum/syntax/delayed_job.rb +0 -25
  99. data/lib/arsenicum/watchdog.rb +0 -68
  100. data/spec/config.example.yml +0 -21
@@ -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
@@ -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
@@ -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'