sidekiq 0.10.0 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

Files changed (234) hide show
  1. checksums.yaml +7 -0
  2. data/Changes.md +2082 -0
  3. data/LICENSE.txt +9 -0
  4. data/README.md +73 -27
  5. data/bin/sidekiq +25 -9
  6. data/bin/sidekiqload +247 -0
  7. data/bin/sidekiqmon +11 -0
  8. data/lib/generators/sidekiq/job_generator.rb +57 -0
  9. data/lib/generators/sidekiq/templates/job.rb.erb +9 -0
  10. data/lib/generators/sidekiq/templates/job_spec.rb.erb +6 -0
  11. data/lib/generators/sidekiq/templates/job_test.rb.erb +8 -0
  12. data/lib/sidekiq/api.rb +1145 -0
  13. data/lib/sidekiq/capsule.rb +127 -0
  14. data/lib/sidekiq/cli.rb +348 -109
  15. data/lib/sidekiq/client.rb +241 -41
  16. data/lib/sidekiq/component.rb +68 -0
  17. data/lib/sidekiq/config.rb +287 -0
  18. data/lib/sidekiq/deploy.rb +62 -0
  19. data/lib/sidekiq/embedded.rb +61 -0
  20. data/lib/sidekiq/fetch.rb +88 -0
  21. data/lib/sidekiq/job.rb +374 -0
  22. data/lib/sidekiq/job_logger.rb +51 -0
  23. data/lib/sidekiq/job_retry.rb +301 -0
  24. data/lib/sidekiq/job_util.rb +107 -0
  25. data/lib/sidekiq/launcher.rb +271 -0
  26. data/lib/sidekiq/logger.rb +131 -0
  27. data/lib/sidekiq/manager.rb +96 -103
  28. data/lib/sidekiq/metrics/query.rb +155 -0
  29. data/lib/sidekiq/metrics/shared.rb +95 -0
  30. data/lib/sidekiq/metrics/tracking.rb +136 -0
  31. data/lib/sidekiq/middleware/chain.rb +149 -38
  32. data/lib/sidekiq/middleware/current_attributes.rb +95 -0
  33. data/lib/sidekiq/middleware/i18n.rb +42 -0
  34. data/lib/sidekiq/middleware/modules.rb +21 -0
  35. data/lib/sidekiq/monitor.rb +146 -0
  36. data/lib/sidekiq/paginator.rb +55 -0
  37. data/lib/sidekiq/processor.rb +246 -61
  38. data/lib/sidekiq/rails.rb +60 -13
  39. data/lib/sidekiq/redis_client_adapter.rb +111 -0
  40. data/lib/sidekiq/redis_connection.rb +68 -15
  41. data/lib/sidekiq/ring_buffer.rb +29 -0
  42. data/lib/sidekiq/scheduled.rb +236 -0
  43. data/lib/sidekiq/sd_notify.rb +149 -0
  44. data/lib/sidekiq/systemd.rb +24 -0
  45. data/lib/sidekiq/testing/inline.rb +30 -0
  46. data/lib/sidekiq/testing.rb +310 -10
  47. data/lib/sidekiq/transaction_aware_client.rb +44 -0
  48. data/lib/sidekiq/version.rb +4 -1
  49. data/lib/sidekiq/web/action.rb +93 -0
  50. data/lib/sidekiq/web/application.rb +463 -0
  51. data/lib/sidekiq/web/csrf_protection.rb +180 -0
  52. data/lib/sidekiq/web/helpers.rb +364 -0
  53. data/lib/sidekiq/web/router.rb +104 -0
  54. data/lib/sidekiq/web.rb +143 -74
  55. data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
  56. data/lib/sidekiq.rb +120 -73
  57. data/sidekiq.gemspec +26 -23
  58. data/web/assets/images/apple-touch-icon.png +0 -0
  59. data/web/assets/images/favicon.ico +0 -0
  60. data/web/assets/images/logo.png +0 -0
  61. data/web/assets/images/status.png +0 -0
  62. data/web/assets/javascripts/application.js +177 -3
  63. data/web/assets/javascripts/base-charts.js +106 -0
  64. data/web/assets/javascripts/chart.min.js +13 -0
  65. data/web/assets/javascripts/chartjs-plugin-annotation.min.js +7 -0
  66. data/web/assets/javascripts/dashboard-charts.js +182 -0
  67. data/web/assets/javascripts/dashboard.js +57 -0
  68. data/web/assets/javascripts/metrics.js +298 -0
  69. data/web/assets/stylesheets/application-dark.css +147 -0
  70. data/web/assets/stylesheets/application-rtl.css +153 -0
  71. data/web/assets/stylesheets/application.css +729 -7
  72. data/web/assets/stylesheets/bootstrap-rtl.min.css +9 -0
  73. data/web/assets/stylesheets/bootstrap.css +5 -0
  74. data/web/locales/ar.yml +87 -0
  75. data/web/locales/cs.yml +78 -0
  76. data/web/locales/da.yml +75 -0
  77. data/web/locales/de.yml +81 -0
  78. data/web/locales/el.yml +87 -0
  79. data/web/locales/en.yml +101 -0
  80. data/web/locales/es.yml +86 -0
  81. data/web/locales/fa.yml +80 -0
  82. data/web/locales/fr.yml +99 -0
  83. data/web/locales/gd.yml +99 -0
  84. data/web/locales/he.yml +80 -0
  85. data/web/locales/hi.yml +75 -0
  86. data/web/locales/it.yml +69 -0
  87. data/web/locales/ja.yml +91 -0
  88. data/web/locales/ko.yml +68 -0
  89. data/web/locales/lt.yml +83 -0
  90. data/web/locales/nb.yml +77 -0
  91. data/web/locales/nl.yml +68 -0
  92. data/web/locales/pl.yml +59 -0
  93. data/web/locales/pt-br.yml +96 -0
  94. data/web/locales/pt.yml +67 -0
  95. data/web/locales/ru.yml +83 -0
  96. data/web/locales/sv.yml +68 -0
  97. data/web/locales/ta.yml +75 -0
  98. data/web/locales/uk.yml +77 -0
  99. data/web/locales/ur.yml +80 -0
  100. data/web/locales/vi.yml +83 -0
  101. data/web/locales/zh-cn.yml +95 -0
  102. data/web/locales/zh-tw.yml +102 -0
  103. data/web/views/_footer.erb +23 -0
  104. data/web/views/_job_info.erb +105 -0
  105. data/web/views/_metrics_period_select.erb +12 -0
  106. data/web/views/_nav.erb +52 -0
  107. data/web/views/_paging.erb +25 -0
  108. data/web/views/_poll_link.erb +4 -0
  109. data/web/views/_status.erb +4 -0
  110. data/web/views/_summary.erb +40 -0
  111. data/web/views/busy.erb +148 -0
  112. data/web/views/dashboard.erb +105 -0
  113. data/web/views/dead.erb +34 -0
  114. data/web/views/filtering.erb +7 -0
  115. data/web/views/layout.erb +42 -0
  116. data/web/views/metrics.erb +91 -0
  117. data/web/views/metrics_for_job.erb +59 -0
  118. data/web/views/morgue.erb +74 -0
  119. data/web/views/queue.erb +55 -0
  120. data/web/views/queues.erb +44 -0
  121. data/web/views/retries.erb +79 -0
  122. data/web/views/retry.erb +34 -0
  123. data/web/views/scheduled.erb +56 -0
  124. data/web/views/scheduled_job_info.erb +8 -0
  125. metadata +159 -237
  126. data/.gitignore +0 -6
  127. data/.rvmrc +0 -4
  128. data/COMM-LICENSE +0 -75
  129. data/Gemfile +0 -10
  130. data/LICENSE +0 -22
  131. data/Rakefile +0 -9
  132. data/TODO.md +0 -1
  133. data/bin/client +0 -7
  134. data/bin/sidekiqctl +0 -43
  135. data/config.ru +0 -8
  136. data/examples/chef/cookbooks/sidekiq/README.rdoc +0 -11
  137. data/examples/chef/cookbooks/sidekiq/recipes/default.rb +0 -55
  138. data/examples/chef/cookbooks/sidekiq/templates/default/monitrc.conf.erb +0 -8
  139. data/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.erb +0 -219
  140. data/examples/chef/cookbooks/sidekiq/templates/default/sidekiq.yml.erb +0 -22
  141. data/examples/config.yml +0 -9
  142. data/examples/monitrc.conf +0 -6
  143. data/examples/por.rb +0 -27
  144. data/examples/scheduling.rb +0 -37
  145. data/examples/sinkiq.rb +0 -57
  146. data/examples/web-ui.png +0 -0
  147. data/lib/sidekiq/capistrano.rb +0 -32
  148. data/lib/sidekiq/extensions/action_mailer.rb +0 -26
  149. data/lib/sidekiq/extensions/active_record.rb +0 -27
  150. data/lib/sidekiq/extensions/generic_proxy.rb +0 -21
  151. data/lib/sidekiq/middleware/client/unique_jobs.rb +0 -32
  152. data/lib/sidekiq/middleware/server/active_record.rb +0 -13
  153. data/lib/sidekiq/middleware/server/exception_handler.rb +0 -38
  154. data/lib/sidekiq/middleware/server/failure_jobs.rb +0 -24
  155. data/lib/sidekiq/middleware/server/logging.rb +0 -27
  156. data/lib/sidekiq/middleware/server/retry_jobs.rb +0 -59
  157. data/lib/sidekiq/middleware/server/unique_jobs.rb +0 -15
  158. data/lib/sidekiq/retry.rb +0 -57
  159. data/lib/sidekiq/util.rb +0 -61
  160. data/lib/sidekiq/worker.rb +0 -37
  161. data/myapp/.gitignore +0 -15
  162. data/myapp/Capfile +0 -5
  163. data/myapp/Gemfile +0 -19
  164. data/myapp/Gemfile.lock +0 -143
  165. data/myapp/Rakefile +0 -7
  166. data/myapp/app/controllers/application_controller.rb +0 -3
  167. data/myapp/app/controllers/work_controller.rb +0 -38
  168. data/myapp/app/helpers/application_helper.rb +0 -2
  169. data/myapp/app/mailers/.gitkeep +0 -0
  170. data/myapp/app/mailers/user_mailer.rb +0 -9
  171. data/myapp/app/models/.gitkeep +0 -0
  172. data/myapp/app/models/post.rb +0 -5
  173. data/myapp/app/views/layouts/application.html.erb +0 -14
  174. data/myapp/app/views/user_mailer/greetings.html.erb +0 -3
  175. data/myapp/app/views/work/index.html.erb +0 -1
  176. data/myapp/app/workers/hard_worker.rb +0 -9
  177. data/myapp/config/application.rb +0 -59
  178. data/myapp/config/boot.rb +0 -6
  179. data/myapp/config/database.yml +0 -25
  180. data/myapp/config/deploy.rb +0 -15
  181. data/myapp/config/environment.rb +0 -5
  182. data/myapp/config/environments/development.rb +0 -38
  183. data/myapp/config/environments/production.rb +0 -67
  184. data/myapp/config/environments/test.rb +0 -37
  185. data/myapp/config/initializers/backtrace_silencers.rb +0 -7
  186. data/myapp/config/initializers/inflections.rb +0 -15
  187. data/myapp/config/initializers/mime_types.rb +0 -5
  188. data/myapp/config/initializers/secret_token.rb +0 -7
  189. data/myapp/config/initializers/session_store.rb +0 -8
  190. data/myapp/config/initializers/sidekiq.rb +0 -6
  191. data/myapp/config/initializers/wrap_parameters.rb +0 -14
  192. data/myapp/config/locales/en.yml +0 -5
  193. data/myapp/config/routes.rb +0 -10
  194. data/myapp/config.ru +0 -4
  195. data/myapp/db/migrate/20120123214055_create_posts.rb +0 -10
  196. data/myapp/db/seeds.rb +0 -7
  197. data/myapp/lib/assets/.gitkeep +0 -0
  198. data/myapp/lib/tasks/.gitkeep +0 -0
  199. data/myapp/log/.gitkeep +0 -0
  200. data/myapp/script/rails +0 -6
  201. data/test/config.yml +0 -9
  202. data/test/fake_env.rb +0 -0
  203. data/test/helper.rb +0 -15
  204. data/test/test_cli.rb +0 -168
  205. data/test/test_client.rb +0 -105
  206. data/test/test_extensions.rb +0 -68
  207. data/test/test_manager.rb +0 -43
  208. data/test/test_middleware.rb +0 -92
  209. data/test/test_processor.rb +0 -32
  210. data/test/test_retry.rb +0 -83
  211. data/test/test_stats.rb +0 -78
  212. data/test/test_testing.rb +0 -65
  213. data/test/test_web.rb +0 -61
  214. data/web/assets/images/bootstrap/glyphicons-halflings-white.png +0 -0
  215. data/web/assets/images/bootstrap/glyphicons-halflings.png +0 -0
  216. data/web/assets/javascripts/vendor/bootstrap/bootstrap-alert.js +0 -91
  217. data/web/assets/javascripts/vendor/bootstrap/bootstrap-button.js +0 -98
  218. data/web/assets/javascripts/vendor/bootstrap/bootstrap-carousel.js +0 -154
  219. data/web/assets/javascripts/vendor/bootstrap/bootstrap-collapse.js +0 -136
  220. data/web/assets/javascripts/vendor/bootstrap/bootstrap-dropdown.js +0 -92
  221. data/web/assets/javascripts/vendor/bootstrap/bootstrap-modal.js +0 -210
  222. data/web/assets/javascripts/vendor/bootstrap/bootstrap-popover.js +0 -95
  223. data/web/assets/javascripts/vendor/bootstrap/bootstrap-scrollspy.js +0 -125
  224. data/web/assets/javascripts/vendor/bootstrap/bootstrap-tab.js +0 -130
  225. data/web/assets/javascripts/vendor/bootstrap/bootstrap-tooltip.js +0 -270
  226. data/web/assets/javascripts/vendor/bootstrap/bootstrap-transition.js +0 -51
  227. data/web/assets/javascripts/vendor/bootstrap/bootstrap-typeahead.js +0 -271
  228. data/web/assets/javascripts/vendor/bootstrap.js +0 -12
  229. data/web/assets/javascripts/vendor/jquery.js +0 -9266
  230. data/web/assets/stylesheets/vendor/bootstrap-responsive.css +0 -567
  231. data/web/assets/stylesheets/vendor/bootstrap.css +0 -3365
  232. data/web/views/index.slim +0 -62
  233. data/web/views/layout.slim +0 -24
  234. data/web/views/queue.slim +0 -11
data/myapp/config/boot.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
-
3
- # Set up gems listed in the Gemfile.
4
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
-
6
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -1,25 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- # Warning: The database defined as "test" will be erased and
13
- # re-generated from your development database when you run "rake".
14
- # Do not set this db to the same as development or production.
15
- test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
20
-
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000
@@ -1,15 +0,0 @@
1
- require 'bundler/capistrano'
2
- require 'sidekiq/capistrano'
3
-
4
- set :scm, :git
5
- set :repository, 'git@github.com:mperham/sidekiq'
6
- ssh_options[:forward_agent] = true
7
-
8
- default_run_options[:pty] = true # needed to run sudo
9
- set :user, 'mperham'
10
- set :application, "myapp"
11
- set :deploy_via, :remote_cache
12
-
13
- role :web, "localhost"
14
- role :app, "localhost"
15
- role :db, "localhost", :primary => true
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Myapp::Application.initialize!
@@ -1,38 +0,0 @@
1
- Myapp::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger
20
- config.active_support.deprecation = :log
21
-
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
-
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
31
-
32
- # Do not compress assets
33
- config.assets.compress = false
34
-
35
- # Expands the lines which load the assets
36
- config.assets.debug = true
37
- config.assets.logger = nil
38
- end
@@ -1,67 +0,0 @@
1
- Myapp::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
6
-
7
- # Full error reports are disabled and caching is turned on
8
- config.consider_all_requests_local = false
9
- config.action_controller.perform_caching = true
10
-
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
13
-
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
16
-
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
18
- config.assets.compile = false
19
-
20
- # Generate digests for assets URLs
21
- config.assets.digest = true
22
-
23
- # Defaults to Rails.root.join("public/assets")
24
- # config.assets.manifest = YOUR_PATH
25
-
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
-
30
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
- # config.force_ssl = true
32
-
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
35
-
36
- # Prepend all log lines with the following tags
37
- # config.log_tags = [ :subdomain, :uuid ]
38
-
39
- # Use a different logger for distributed setups
40
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
-
42
- # Use a different cache store in production
43
- # config.cache_store = :mem_cache_store
44
-
45
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
- # config.action_controller.asset_host = "http://assets.example.com"
47
-
48
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
- # config.assets.precompile += %w( search.js )
50
-
51
- # Disable delivery errors, bad email addresses will be ignored
52
- # config.action_mailer.raise_delivery_errors = false
53
-
54
- # Enable threaded mode
55
- # config.threadsafe!
56
-
57
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
- # the I18n.default_locale when a translation can not be found)
59
- config.i18n.fallbacks = true
60
-
61
- # Send deprecation notices to registered listeners
62
- config.active_support.deprecation = :notify
63
-
64
- # Log the query plan for queries taking more than this (works
65
- # with SQLite, MySQL, and PostgreSQL)
66
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
67
- end
@@ -1,37 +0,0 @@
1
- Myapp::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
13
-
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
16
-
17
- # Show full error reports and disable caching
18
- config.consider_all_requests_local = true
19
- config.action_controller.perform_caching = false
20
-
21
- # Raise exceptions instead of rendering exception templates
22
- config.action_dispatch.show_exceptions = false
23
-
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
-
27
- # Tell Action Mailer not to deliver emails to the real world.
28
- # The :test delivery method accumulates sent emails in the
29
- # ActionMailer::Base.deliveries array.
30
- config.action_mailer.delivery_method = :test
31
-
32
- # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
34
-
35
- # Print deprecation notices to the stderr
36
- config.active_support.deprecation = :stderr
37
- end
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
-
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
@@ -1,15 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
6
- # inflect.plural /^(ox)$/i, '\1en'
7
- # inflect.singular /^(ox)en/i, '\1'
8
- # inflect.irregular 'person', 'people'
9
- # inflect.uncountable %w( fish sheep )
10
- # end
11
- #
12
- # These inflection rules are supported but not enabled by default:
13
- # ActiveSupport::Inflector.inflections do |inflect|
14
- # inflect.acronym 'RESTful'
15
- # end
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
5
- # Mime::Type.register_alias "text/html", :iphone
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- Myapp::Application.config.secret_token = 'bdd335500c81ba1f279f9dd8198d1f334445d0193168ed73c1282502180dca27e3e102ec345e99b2acac6a63f7fe29da69c60cc9e76e8da34fb5d4989db24cd8'
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- Myapp::Application.config.session_store :cookie_store, key: '_myapp_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # Myapp::Application.config.session_store :active_record_store
@@ -1,6 +0,0 @@
1
- Sidekiq.configure_client do |config|
2
- config.redis = { :size => 2 }
3
- end
4
- Sidekiq.configure_server do |config|
5
- config.redis = { :size => 25 }
6
- end
@@ -1,14 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
- #
3
- # This file contains settings for ActionController::ParamsWrapper which
4
- # is enabled by default.
5
-
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
9
- end
10
-
11
- # Disable root element in JSON by default.
12
- ActiveSupport.on_load(:active_record) do
13
- self.include_root_in_json = false
14
- end
@@ -1,5 +0,0 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
@@ -1,10 +0,0 @@
1
- require 'sidekiq/web'
2
-
3
- Myapp::Application.routes.draw do
4
- mount Sidekiq::Web => '/sidekiq'
5
- get "work" => "work#index"
6
- get "work/email" => "work#email"
7
- get "work/post" => "work#delayed_post"
8
- get "work/long" => "work#long"
9
- get "work/crash" => "work#crash"
10
- end
data/myapp/config.ru DELETED
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Myapp::Application
@@ -1,10 +0,0 @@
1
- class CreatePosts < ActiveRecord::Migration
2
- def change
3
- create_table :posts do |t|
4
- t.string :title
5
- t.string :body
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
data/myapp/db/seeds.rb DELETED
@@ -1,7 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # Examples:
5
- #
6
- # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
- # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
File without changes
data/myapp/log/.gitkeep DELETED
File without changes
data/myapp/script/rails DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
data/test/config.yml DELETED
@@ -1,9 +0,0 @@
1
- ---
2
- :verbose: false
3
- :environment: xzibit
4
- :require: ./test/fake_env.rb
5
- :pidfile: /tmp/sidekiq-config-test.pid
6
- :concurrency: 50
7
- :queues:
8
- - [often, 2]
9
- - [seldom, 1]
data/test/fake_env.rb DELETED
File without changes
data/test/helper.rb DELETED
@@ -1,15 +0,0 @@
1
- if ENV.has_key?("SIMPLECOV")
2
- require 'simplecov'
3
- SimpleCov.start
4
- end
5
-
6
- require 'minitest/unit'
7
- require 'minitest/pride'
8
- require 'minitest/autorun'
9
-
10
- require 'sidekiq'
11
- require 'sidekiq/util'
12
- Sidekiq::Util.logger.level = Logger::ERROR
13
-
14
- require 'sidekiq/redis_connection'
15
- REDIS = Sidekiq::RedisConnection.create(:url => "redis://localhost/15")
data/test/test_cli.rb DELETED
@@ -1,168 +0,0 @@
1
- require 'helper'
2
- require 'sidekiq/cli'
3
- require 'tempfile'
4
-
5
- cli = Sidekiq::CLI.instance
6
- def cli.die(code)
7
- @code = code
8
- end
9
-
10
- def cli.valid?
11
- !@code
12
- end
13
-
14
- class TestCli < MiniTest::Unit::TestCase
15
- describe 'with cli' do
16
-
17
- before do
18
- @cli = Sidekiq::CLI.instance
19
- end
20
-
21
- it 'blows up with an invalid require' do
22
- assert_raises ArgumentError do
23
- @cli.parse(['sidekiq', '-r', 'foobar'])
24
- end
25
- end
26
-
27
- it 'requires the specified Ruby code' do
28
- @cli.parse(['sidekiq', '-r', './test/fake_env.rb'])
29
- assert($LOADED_FEATURES.any? { |x| x =~ /fake_env/ })
30
- assert @cli.valid?
31
- end
32
-
33
- it 'changes concurrency' do
34
- @cli.parse(['sidekiq', '-c', '60', '-r', './test/fake_env.rb'])
35
- assert_equal 60, Sidekiq.options[:concurrency]
36
- end
37
-
38
- it 'changes queues' do
39
- @cli.parse(['sidekiq', '-q', 'foo', '-r', './test/fake_env.rb'])
40
- assert_equal ['foo'], Sidekiq.options[:queues]
41
- end
42
-
43
- it 'changes timeout' do
44
- @cli.parse(['sidekiq', '-t', '30', '-r', './test/fake_env.rb'])
45
- assert_equal 30, Sidekiq.options[:timeout]
46
- end
47
-
48
- it 'handles weights' do
49
- @cli.parse(['sidekiq', '-q', 'foo,3', '-q', 'bar', '-r', './test/fake_env.rb'])
50
- assert_equal %w(bar foo foo foo), Sidekiq.options[:queues].sort
51
- end
52
-
53
- it 'sets verbose' do
54
- old = Sidekiq::Util.logger.level
55
- @cli.parse(['sidekiq', '-v', '-r', './test/fake_env.rb'])
56
- assert_equal Logger::DEBUG, Sidekiq::Util.logger.level
57
- # If we leave the logger at DEBUG it'll add a lot of noise to the test output
58
- Sidekiq::Util.logger.level = old
59
- end
60
-
61
- describe 'with pidfile' do
62
- before do
63
- @tmp_file = Tempfile.new('sidekiq-test')
64
- @tmp_path = @tmp_file.path
65
- @tmp_file.close!
66
-
67
- @cli.parse(['sidekiq', '-P', @tmp_path, '-r', './test/fake_env.rb'])
68
- end
69
-
70
- after do
71
- File.unlink @tmp_path if File.exist? @tmp_path
72
- end
73
-
74
- it 'sets pidfile path' do
75
- assert_equal @tmp_path, Sidekiq.options[:pidfile]
76
- end
77
-
78
- it 'writes pidfile' do
79
- assert_equal File.read(@tmp_path).strip.to_i, Process.pid
80
- end
81
- end
82
-
83
- describe 'with config file' do
84
- before do
85
- @cli.parse(['sidekiq', '-C', './test/config.yml'])
86
- end
87
-
88
- it 'takes a path' do
89
- assert_equal './test/config.yml', Sidekiq.options[:config_file]
90
- end
91
-
92
- it 'sets verbose' do
93
- refute Sidekiq.options[:verbose]
94
- end
95
-
96
- it 'sets require file' do
97
- assert_equal './test/fake_env.rb', Sidekiq.options[:require]
98
- end
99
-
100
- it 'sets environment' do
101
- assert_equal 'xzibit', Sidekiq.options[:environment]
102
- end
103
-
104
- it 'sets concurrency' do
105
- assert_equal 50, Sidekiq.options[:concurrency]
106
- end
107
-
108
- it 'sets pid file' do
109
- assert_equal '/tmp/sidekiq-config-test.pid', Sidekiq.options[:pidfile]
110
- end
111
-
112
- it 'sets queues' do
113
- assert_equal 2, Sidekiq.options[:queues].select{ |q| q == 'often' }.length
114
- assert_equal 1, Sidekiq.options[:queues].select{ |q| q == 'seldom' }.length
115
- end
116
- end
117
-
118
- describe 'with config file and flags' do
119
- before do
120
- # We need an actual file here.
121
- @tmp_lib_path = '/tmp/require-me.rb'
122
- File.open(@tmp_lib_path, 'w') do |f|
123
- f.puts "# do work"
124
- end
125
-
126
- @tmp_file = Tempfile.new('sidekiqr')
127
- @tmp_path = @tmp_file.path
128
- @tmp_file.close!
129
-
130
- @cli.parse(['sidekiq',
131
- '-C', './test/config.yml',
132
- '-e', 'snoop',
133
- '-c', '100',
134
- '-r', @tmp_lib_path,
135
- '-P', @tmp_path,
136
- '-q', 'often,7',
137
- '-q', 'seldom,3'])
138
- end
139
-
140
- after do
141
- File.unlink @tmp_lib_path if File.exist? @tmp_lib_path
142
- File.unlink @tmp_path if File.exist? @tmp_path
143
- end
144
-
145
- it 'uses concurrency flag' do
146
- assert_equal 100, Sidekiq.options[:concurrency]
147
- end
148
-
149
- it 'uses require file flag' do
150
- assert_equal @tmp_lib_path, Sidekiq.options[:require]
151
- end
152
-
153
- it 'uses environment flag' do
154
- assert_equal 'snoop', Sidekiq.options[:environment]
155
- end
156
-
157
- it 'uses pidfile flag' do
158
- assert_equal @tmp_path, Sidekiq.options[:pidfile]
159
- end
160
-
161
- it 'sets queues' do
162
- assert_equal 7, Sidekiq.options[:queues].select{ |q| q == 'often' }.length
163
- assert_equal 3, Sidekiq.options[:queues].select{ |q| q == 'seldom' }.length
164
- end
165
- end
166
- end
167
-
168
- end
data/test/test_client.rb DELETED
@@ -1,105 +0,0 @@
1
- require 'helper'
2
- require 'sidekiq/client'
3
- require 'sidekiq/worker'
4
-
5
- class TestClient < MiniTest::Unit::TestCase
6
- describe 'with real redis' do
7
- before do
8
- Sidekiq.redis = REDIS
9
- Sidekiq.redis.flushdb
10
- end
11
-
12
- it 'does not push duplicate messages when configured for unique only' do
13
- Sidekiq.client_middleware.entries.clear
14
- Sidekiq.client_middleware do |chain|
15
- chain.add Sidekiq::Middleware::Client::UniqueJobs
16
- end
17
- 10.times { Sidekiq::Client.push('customqueue', 'class' => 'Foo', 'args' => [1, 2]) }
18
- assert_equal 1, Sidekiq.redis.llen("queue:customqueue")
19
- end
20
-
21
- it 'does push duplicate messages when not configured for unique only' do
22
- Sidekiq.client_middleware.remove(Sidekiq::Middleware::Client::UniqueJobs)
23
- 10.times { Sidekiq::Client.push('customqueue2', 'class' => 'Foo', 'args' => [1, 2]) }
24
- assert_equal 10, Sidekiq.redis.llen("queue:customqueue2")
25
- end
26
- end
27
-
28
- describe 'with mock redis' do
29
- before do
30
- @redis = MiniTest::Mock.new
31
- def @redis.multi; yield if block_given?; end
32
- def @redis.set(*); true; end
33
- def @redis.sadd(*); true; end
34
- def @redis.srem(*); true; end
35
- def @redis.get(*); nil; end
36
- def @redis.del(*); nil; end
37
- def @redis.incrby(*); nil; end
38
- def @redis.setex(*); true; end
39
- def @redis.expire(*); true; end
40
- def @redis.watch(*); true; end
41
- def @redis.with_connection; yield self; end
42
- def @redis.with; yield self; end
43
- def @redis.exec; true; end
44
- Sidekiq.instance_variable_set(:@redis, @redis)
45
- end
46
-
47
- it 'raises ArgumentError with invalid params' do
48
- assert_raises ArgumentError do
49
- Sidekiq::Client.push('foo', 1)
50
- end
51
-
52
- assert_raises ArgumentError do
53
- Sidekiq::Client.push('foo', :class => 'Foo', :noargs => [1, 2])
54
- end
55
- end
56
-
57
- it 'pushes messages to redis' do
58
- @redis.expect :rpush, 1, ['queue:foo', String]
59
- pushed = Sidekiq::Client.push('foo', 'class' => 'Foo', 'args' => [1, 2])
60
- assert pushed
61
- @redis.verify
62
- end
63
-
64
- class MyWorker
65
- include Sidekiq::Worker
66
- end
67
-
68
- it 'handles perform_async' do
69
- @redis.expect :rpush, 1, ['queue:default', String]
70
- pushed = MyWorker.perform_async(1, 2)
71
- assert pushed
72
- @redis.verify
73
- end
74
-
75
- it 'enqueues messages to redis' do
76
- @redis.expect :rpush, 1, ['queue:default', String]
77
- pushed = Sidekiq::Client.enqueue(MyWorker, 1, 2)
78
- assert pushed
79
- @redis.verify
80
- end
81
-
82
- class QueuedWorker
83
- include Sidekiq::Worker
84
-
85
- queue :flimflam
86
- end
87
-
88
- it 'enqueues to the named queue' do
89
- @redis.expect :rpush, 1, ['queue:flimflam', String]
90
- pushed = QueuedWorker.perform_async(1, 2)
91
- assert pushed
92
- @redis.verify
93
- end
94
-
95
- it 'retrieves queues' do
96
- @redis.expect :smembers, ['bob'], ['queues']
97
- assert_equal ['bob'], Sidekiq::Client.registered_queues
98
- end
99
-
100
- it 'retrieves workers' do
101
- @redis.expect :smembers, ['bob'], ['workers']
102
- assert_equal ['bob'], Sidekiq::Client.registered_workers
103
- end
104
- end
105
- end