sidekiq-unique-jobs 4.0.18 → 7.1.28

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

Potentially problematic release.


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

Files changed (296) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1889 -94
  3. data/LICENSE.txt +21 -0
  4. data/README.md +927 -119
  5. data/bin/uniquejobs +7 -0
  6. data/lib/sidekiq-unique-jobs.rb +2 -78
  7. data/lib/sidekiq_unique_jobs/batch_delete.rb +124 -0
  8. data/lib/sidekiq_unique_jobs/changelog.rb +78 -0
  9. data/lib/sidekiq_unique_jobs/cli.rb +79 -21
  10. data/lib/sidekiq_unique_jobs/config.rb +310 -14
  11. data/lib/sidekiq_unique_jobs/connection.rb +23 -0
  12. data/lib/sidekiq_unique_jobs/constants.rb +52 -16
  13. data/lib/sidekiq_unique_jobs/core_ext.rb +114 -33
  14. data/lib/sidekiq_unique_jobs/deprecation.rb +65 -0
  15. data/lib/sidekiq_unique_jobs/digests.rb +111 -0
  16. data/lib/sidekiq_unique_jobs/exceptions.rb +105 -0
  17. data/lib/sidekiq_unique_jobs/expiring_digests.rb +14 -0
  18. data/lib/sidekiq_unique_jobs/job.rb +58 -0
  19. data/lib/sidekiq_unique_jobs/json.rb +47 -0
  20. data/lib/sidekiq_unique_jobs/key.rb +98 -0
  21. data/lib/sidekiq_unique_jobs/lock/base_lock.rb +165 -0
  22. data/lib/sidekiq_unique_jobs/lock/client_validator.rb +28 -0
  23. data/lib/sidekiq_unique_jobs/lock/server_validator.rb +27 -0
  24. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +65 -7
  25. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +34 -64
  26. data/lib/sidekiq_unique_jobs/lock/until_executing.rb +37 -4
  27. data/lib/sidekiq_unique_jobs/lock/until_expired.rb +42 -0
  28. data/lib/sidekiq_unique_jobs/lock/validator.rb +96 -0
  29. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +53 -35
  30. data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +21 -0
  31. data/lib/sidekiq_unique_jobs/lock.rb +338 -6
  32. data/lib/sidekiq_unique_jobs/lock_args.rb +127 -0
  33. data/lib/sidekiq_unique_jobs/lock_config.rb +126 -0
  34. data/lib/sidekiq_unique_jobs/lock_digest.rb +79 -0
  35. data/lib/sidekiq_unique_jobs/lock_info.rb +68 -0
  36. data/lib/sidekiq_unique_jobs/lock_timeout.rb +62 -0
  37. data/lib/sidekiq_unique_jobs/lock_ttl.rb +77 -0
  38. data/lib/sidekiq_unique_jobs/locksmith.rb +383 -0
  39. data/lib/sidekiq_unique_jobs/logging/middleware_context.rb +44 -0
  40. data/lib/sidekiq_unique_jobs/logging.rb +236 -0
  41. data/lib/sidekiq_unique_jobs/lua/delete.lua +51 -0
  42. data/lib/sidekiq_unique_jobs/lua/delete_by_digest.lua +42 -0
  43. data/lib/sidekiq_unique_jobs/lua/delete_job_by_digest.lua +38 -0
  44. data/lib/sidekiq_unique_jobs/lua/find_digest_in_queues.lua +26 -0
  45. data/lib/sidekiq_unique_jobs/lua/lock.lua +99 -0
  46. data/lib/sidekiq_unique_jobs/lua/lock_until_expired.lua +92 -0
  47. data/lib/sidekiq_unique_jobs/lua/locked.lua +35 -0
  48. data/lib/sidekiq_unique_jobs/lua/queue.lua +87 -0
  49. data/lib/sidekiq_unique_jobs/lua/reap_orphans.lua +122 -0
  50. data/lib/sidekiq_unique_jobs/lua/shared/_common.lua +40 -0
  51. data/lib/sidekiq_unique_jobs/lua/shared/_current_time.lua +8 -0
  52. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_queue.lua +22 -0
  53. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_sorted_set.lua +18 -0
  54. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua +53 -0
  55. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua +43 -0
  56. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_sorted_set.lua +24 -0
  57. data/lib/sidekiq_unique_jobs/lua/shared/_hgetall.lua +13 -0
  58. data/lib/sidekiq_unique_jobs/lua/shared/_upgrades.lua +3 -0
  59. data/lib/sidekiq_unique_jobs/lua/unlock.lua +107 -0
  60. data/lib/sidekiq_unique_jobs/lua/update_version.lua +40 -0
  61. data/lib/sidekiq_unique_jobs/lua/upgrade.lua +68 -0
  62. data/lib/sidekiq_unique_jobs/middleware/client.rb +42 -0
  63. data/lib/sidekiq_unique_jobs/middleware/server.rb +31 -0
  64. data/lib/sidekiq_unique_jobs/middleware.rb +34 -29
  65. data/lib/sidekiq_unique_jobs/normalizer.rb +11 -1
  66. data/lib/sidekiq_unique_jobs/on_conflict/log.rb +24 -0
  67. data/lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb +16 -0
  68. data/lib/sidekiq_unique_jobs/on_conflict/raise.rb +17 -0
  69. data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +118 -0
  70. data/lib/sidekiq_unique_jobs/on_conflict/replace.rb +82 -0
  71. data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +35 -0
  72. data/lib/sidekiq_unique_jobs/on_conflict/strategy.rb +51 -0
  73. data/lib/sidekiq_unique_jobs/on_conflict.rb +44 -0
  74. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +54 -31
  75. data/lib/sidekiq_unique_jobs/orphans/lua_reaper.rb +29 -0
  76. data/lib/sidekiq_unique_jobs/orphans/manager.rb +241 -0
  77. data/lib/sidekiq_unique_jobs/orphans/null_reaper.rb +24 -0
  78. data/lib/sidekiq_unique_jobs/orphans/observer.rb +42 -0
  79. data/lib/sidekiq_unique_jobs/orphans/reaper.rb +114 -0
  80. data/lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb +170 -0
  81. data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +298 -0
  82. data/lib/sidekiq_unique_jobs/redis/entity.rb +112 -0
  83. data/lib/sidekiq_unique_jobs/redis/hash.rb +56 -0
  84. data/lib/sidekiq_unique_jobs/redis/list.rb +32 -0
  85. data/lib/sidekiq_unique_jobs/redis/set.rb +32 -0
  86. data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +86 -0
  87. data/lib/sidekiq_unique_jobs/redis/string.rb +51 -0
  88. data/lib/sidekiq_unique_jobs/redis.rb +11 -0
  89. data/lib/sidekiq_unique_jobs/reflectable.rb +26 -0
  90. data/lib/sidekiq_unique_jobs/reflections.rb +79 -0
  91. data/lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb +51 -0
  92. data/lib/sidekiq_unique_jobs/rspec/matchers.rb +26 -0
  93. data/lib/sidekiq_unique_jobs/script/caller.rb +127 -0
  94. data/lib/sidekiq_unique_jobs/script.rb +15 -0
  95. data/lib/sidekiq_unique_jobs/server.rb +61 -0
  96. data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +116 -104
  97. data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +304 -0
  98. data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +84 -0
  99. data/lib/sidekiq_unique_jobs/testing.rb +115 -50
  100. data/lib/sidekiq_unique_jobs/timer_task.rb +299 -0
  101. data/lib/sidekiq_unique_jobs/timing.rb +58 -0
  102. data/lib/sidekiq_unique_jobs/unlockable.rb +29 -33
  103. data/lib/sidekiq_unique_jobs/update_version.rb +25 -0
  104. data/lib/sidekiq_unique_jobs/upgrade_locks.rb +155 -0
  105. data/lib/sidekiq_unique_jobs/version.rb +5 -1
  106. data/lib/sidekiq_unique_jobs/version_check.rb +114 -0
  107. data/lib/sidekiq_unique_jobs/web/helpers.rb +173 -0
  108. data/lib/sidekiq_unique_jobs/web/views/_paging.erb +10 -0
  109. data/lib/sidekiq_unique_jobs/web/views/changelogs.erb +54 -0
  110. data/lib/sidekiq_unique_jobs/web/views/lock.erb +108 -0
  111. data/lib/sidekiq_unique_jobs/web/views/locks.erb +54 -0
  112. data/lib/sidekiq_unique_jobs/web.rb +109 -0
  113. data/lib/sidekiq_unique_jobs.rb +81 -0
  114. data/lib/tasks/changelog.rake +23 -0
  115. metadata +173 -251
  116. data/.codeclimate.yml +0 -22
  117. data/.dockerignore +0 -4
  118. data/.editorconfig +0 -14
  119. data/.fasterer.yml +0 -23
  120. data/.gitignore +0 -14
  121. data/.rspec +0 -3
  122. data/.rubocop.yml +0 -45
  123. data/.simplecov +0 -12
  124. data/.travis.yml +0 -43
  125. data/Appraisals +0 -31
  126. data/Gemfile +0 -16
  127. data/LICENSE +0 -13
  128. data/Rakefile +0 -12
  129. data/bin/bench +0 -19
  130. data/bin/jobs +0 -6
  131. data/circle.yml +0 -38
  132. data/gemfiles/sidekiq_2.15.gemfile +0 -9
  133. data/gemfiles/sidekiq_2.16.gemfile +0 -9
  134. data/gemfiles/sidekiq_2.17.gemfile +0 -19
  135. data/gemfiles/sidekiq_3.0.gemfile +0 -19
  136. data/gemfiles/sidekiq_3.1.gemfile +0 -19
  137. data/gemfiles/sidekiq_3.2.gemfile +0 -19
  138. data/gemfiles/sidekiq_3.3.gemfile +0 -19
  139. data/gemfiles/sidekiq_4.0.gemfile +0 -19
  140. data/gemfiles/sidekiq_4.1.gemfile +0 -19
  141. data/gemfiles/sidekiq_develop.gemfile +0 -19
  142. data/lib/sidekiq/simulator.rb +0 -75
  143. data/lib/sidekiq_unique_jobs/client/middleware.rb +0 -41
  144. data/lib/sidekiq_unique_jobs/lock/until_timeout.rb +0 -15
  145. data/lib/sidekiq_unique_jobs/run_lock_failed.rb +0 -1
  146. data/lib/sidekiq_unique_jobs/script_mock.rb +0 -68
  147. data/lib/sidekiq_unique_jobs/scripts.rb +0 -49
  148. data/lib/sidekiq_unique_jobs/server/middleware.rb +0 -34
  149. data/lib/sidekiq_unique_jobs/testing/sidekiq_overrides.rb +0 -70
  150. data/lib/sidekiq_unique_jobs/timeout_calculator.rb +0 -65
  151. data/lib/sidekiq_unique_jobs/unique_args.rb +0 -134
  152. data/lib/sidekiq_unique_jobs/util.rb +0 -91
  153. data/rails_example/.env +0 -12
  154. data/rails_example/.gitignore +0 -13
  155. data/rails_example/.rspec +0 -2
  156. data/rails_example/Gemfile +0 -34
  157. data/rails_example/Procfile +0 -2
  158. data/rails_example/README.rdoc +0 -28
  159. data/rails_example/Rakefile +0 -6
  160. data/rails_example/app/assets/images/.keep +0 -0
  161. data/rails_example/app/assets/javascripts/application.js +0 -16
  162. data/rails_example/app/assets/stylesheets/application.css +0 -15
  163. data/rails_example/app/channels/appearance_channel.rb +0 -17
  164. data/rails_example/app/channels/application_cable/channel.rb +0 -4
  165. data/rails_example/app/channels/application_cable/connection.rb +0 -9
  166. data/rails_example/app/channels/post_channel.rb +0 -5
  167. data/rails_example/app/controllers/application_controller.rb +0 -5
  168. data/rails_example/app/controllers/concerns/.keep +0 -0
  169. data/rails_example/app/controllers/work_controller.rb +0 -13
  170. data/rails_example/app/helpers/application_helper.rb +0 -2
  171. data/rails_example/app/mailers/.keep +0 -0
  172. data/rails_example/app/models/.keep +0 -0
  173. data/rails_example/app/models/application_record.rb +0 -3
  174. data/rails_example/app/models/concerns/.keep +0 -0
  175. data/rails_example/app/models/guest.rb +0 -21
  176. data/rails_example/app/models/post.rb +0 -2
  177. data/rails_example/app/views/layouts/application.html.erb +0 -15
  178. data/rails_example/app/workers/simple_worker.rb +0 -12
  179. data/rails_example/app/workers/spawn_simple_worker.rb +0 -7
  180. data/rails_example/bin/bundle +0 -3
  181. data/rails_example/bin/check_or_setup_db +0 -57
  182. data/rails_example/bin/docker-setup +0 -20
  183. data/rails_example/bin/rails +0 -4
  184. data/rails_example/bin/rake +0 -4
  185. data/rails_example/bin/setup +0 -34
  186. data/rails_example/bin/update +0 -29
  187. data/rails_example/cable.ru +0 -6
  188. data/rails_example/common-services.yml +0 -50
  189. data/rails_example/config/application.rb +0 -27
  190. data/rails_example/config/boot.rb +0 -3
  191. data/rails_example/config/cable.yml +0 -9
  192. data/rails_example/config/database.docker.yml +0 -12
  193. data/rails_example/config/database.yml +0 -19
  194. data/rails_example/config/environment.rb +0 -5
  195. data/rails_example/config/environments/development.rb +0 -54
  196. data/rails_example/config/environments/production.rb +0 -86
  197. data/rails_example/config/environments/test.rb +0 -42
  198. data/rails_example/config/initializers/application_controller_renderer.rb +0 -6
  199. data/rails_example/config/initializers/assets.rb +0 -11
  200. data/rails_example/config/initializers/backtrace_silencers.rb +0 -9
  201. data/rails_example/config/initializers/cookies_serializer.rb +0 -5
  202. data/rails_example/config/initializers/filter_parameter_logging.rb +0 -4
  203. data/rails_example/config/initializers/inflections.rb +0 -16
  204. data/rails_example/config/initializers/mime_types.rb +0 -4
  205. data/rails_example/config/initializers/new_framework_defaults.rb +0 -23
  206. data/rails_example/config/initializers/session_store.rb +0 -3
  207. data/rails_example/config/initializers/sidekiq.rb +0 -13
  208. data/rails_example/config/initializers/wrap_parameters.rb +0 -14
  209. data/rails_example/config/locales/en.yml +0 -23
  210. data/rails_example/config/puma.rb +0 -38
  211. data/rails_example/config/routes.rb +0 -6
  212. data/rails_example/config/secrets.yml +0 -22
  213. data/rails_example/config/sidekiq.yml +0 -6
  214. data/rails_example/config/spring.rb +0 -6
  215. data/rails_example/config.ru +0 -4
  216. data/rails_example/db/migrate/20160724111322_create_posts.rb +0 -12
  217. data/rails_example/db/schema.rb +0 -25
  218. data/rails_example/db/seeds.rb +0 -7
  219. data/rails_example/dev-entrypoint.sh +0 -55
  220. data/rails_example/dev.env +0 -12
  221. data/rails_example/docker/rails.Dockerfile +0 -27
  222. data/rails_example/docker-compose.yml +0 -90
  223. data/rails_example/lib/assets/.keep +0 -0
  224. data/rails_example/lib/tasks/.keep +0 -0
  225. data/rails_example/log/.keep +0 -0
  226. data/rails_example/public/404.html +0 -67
  227. data/rails_example/public/422.html +0 -67
  228. data/rails_example/public/500.html +0 -66
  229. data/rails_example/public/favicon.ico +0 -0
  230. data/rails_example/public/robots.txt +0 -5
  231. data/rails_example/simple.ru +0 -12
  232. data/rails_example/spec/controllers/work_controller_spec.rb +0 -172
  233. data/rails_example/spec/factories/posts.rb +0 -8
  234. data/rails_example/spec/models/post_spec.rb +0 -4
  235. data/rails_example/spec/rails_helper.rb +0 -21
  236. data/rails_example/spec/spec_helper.rb +0 -20
  237. data/rails_example/spec/support/sidekiq_meta.rb +0 -12
  238. data/rails_example/spec/workers/simple_worker_spec.rb +0 -4
  239. data/rails_example/vendor/assets/javascripts/.keep +0 -0
  240. data/rails_example/vendor/assets/stylesheets/.keep +0 -0
  241. data/redis/acquire_lock.lua +0 -19
  242. data/redis/release_lock.lua +0 -16
  243. data/redis/synchronize.lua +0 -16
  244. data/sidekiq-unique-jobs.gemspec +0 -25
  245. data/spec/celluloid_with_fallback.rb +0 -18
  246. data/spec/jobs/another_unique_job.rb +0 -13
  247. data/spec/jobs/custom_queue_job.rb +0 -6
  248. data/spec/jobs/custom_queue_job_with_filter_method.rb +0 -7
  249. data/spec/jobs/custom_queue_job_with_filter_proc.rb +0 -10
  250. data/spec/jobs/expiring_job.rb +0 -4
  251. data/spec/jobs/inline_worker.rb +0 -8
  252. data/spec/jobs/just_a_worker.rb +0 -8
  253. data/spec/jobs/long_running_job.rb +0 -7
  254. data/spec/jobs/main_job.rb +0 -8
  255. data/spec/jobs/my_job.rb +0 -12
  256. data/spec/jobs/my_unique_job.rb +0 -12
  257. data/spec/jobs/my_unique_job_with_filter_method.rb +0 -17
  258. data/spec/jobs/my_unique_job_with_filter_proc.rb +0 -15
  259. data/spec/jobs/notify_worker.rb +0 -10
  260. data/spec/jobs/plain_class.rb +0 -4
  261. data/spec/jobs/simple_worker.rb +0 -11
  262. data/spec/jobs/spawn_simple_worker.rb +0 -8
  263. data/spec/jobs/test_class.rb +0 -4
  264. data/spec/jobs/unique_job_with_filter_method.rb +0 -18
  265. data/spec/jobs/unique_on_all_queues_job.rb +0 -13
  266. data/spec/jobs/until_and_while_executing_job.rb +0 -8
  267. data/spec/jobs/until_executed_job.rb +0 -17
  268. data/spec/jobs/until_executing_job.rb +0 -8
  269. data/spec/jobs/until_global_timeout_job.rb +0 -8
  270. data/spec/jobs/until_timeout_job.rb +0 -8
  271. data/spec/jobs/while_executing_job.rb +0 -12
  272. data/spec/lib/sidekiq_unique_jobs/client/middleware_spec.rb +0 -321
  273. data/spec/lib/sidekiq_unique_jobs/core_ext_spec.rb +0 -25
  274. data/spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb +0 -43
  275. data/spec/lib/sidekiq_unique_jobs/lock/until_executed_spec.rb +0 -37
  276. data/spec/lib/sidekiq_unique_jobs/lock/until_timeout_spec.rb +0 -26
  277. data/spec/lib/sidekiq_unique_jobs/lock/while_executing_spec.rb +0 -86
  278. data/spec/lib/sidekiq_unique_jobs/normalizer_spec.rb +0 -21
  279. data/spec/lib/sidekiq_unique_jobs/options_with_fallback_spec.rb +0 -113
  280. data/spec/lib/sidekiq_unique_jobs/queue_lock_timeout_calculator_spec.rb +0 -47
  281. data/spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb +0 -36
  282. data/spec/lib/sidekiq_unique_jobs/script_mock_spec.rb +0 -84
  283. data/spec/lib/sidekiq_unique_jobs/scripts_spec.rb +0 -77
  284. data/spec/lib/sidekiq_unique_jobs/server/middleware_spec.rb +0 -83
  285. data/spec/lib/sidekiq_unique_jobs/sidekiq_testing_enabled_spec.rb +0 -181
  286. data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_ext_spec.rb +0 -80
  287. data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb +0 -41
  288. data/spec/lib/sidekiq_unique_jobs/timeout_calculator_spec.rb +0 -70
  289. data/spec/lib/sidekiq_unique_jobs/unique_args_spec.rb +0 -131
  290. data/spec/lib/sidekiq_unique_jobs/unlockable_spec.rb +0 -4
  291. data/spec/lib/sidekiq_unique_jobs/util_spec.rb +0 -53
  292. data/spec/spec_helper.rb +0 -65
  293. data/spec/support/matchers/redis_matchers.rb +0 -19
  294. data/spec/support/ruby_meta.rb +0 -10
  295. data/spec/support/sidekiq_meta.rb +0 -31
  296. data/spec/support/unique_macros.rb +0 -71
@@ -1,21 +0,0 @@
1
- class Guest
2
- def name
3
- 'Guest Visitor'.freeze
4
- end
5
-
6
- def email
7
- 'unknown@domain.com'.freeze
8
- end
9
-
10
- def appear
11
- end
12
-
13
- def disappear
14
- end
15
-
16
- def appear
17
- end
18
-
19
- def away
20
- end
21
- end
@@ -1,2 +0,0 @@
1
- class Post < ApplicationRecord
2
- end
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>RailsExample</title>
5
- <%= stylesheet_link_tag 'application', media: 'all' %>
6
- <%= javascript_include_tag 'application' %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
- <%= link_to 'Duplicate', duplicate_work_path %>
11
-
12
- <%= yield %>
13
-
14
- </body>
15
- </html>
@@ -1,12 +0,0 @@
1
- class SimpleWorker
2
- include Sidekiq::Worker
3
- sidekiq_options unique: :until_executed,
4
- queue: :default,
5
- unique_args: (lambda do |args|
6
- [args.first]
7
- end)
8
-
9
- def perform(_some_args)
10
- sleep 1
11
- end
12
- end
@@ -1,7 +0,0 @@
1
- class SpawnSimpleWorker
2
- include Sidekiq::Worker
3
-
4
- def perform(spawn_arg)
5
- SimpleWorker.perform_async spawn_arg
6
- end
7
- end
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This script is used in the development environment with Docker to check if the
4
- # app database exists, and runs the database setup if it doesn't, as it is the
5
- # case when the project runs for the first time on the development machine.
6
- #
7
- # We are using this custom script instead of running the
8
- # `rake db:version || rake db:setup` commands, as that currently leaves a
9
- # couple of small ruby zombie processes running in the app container:
10
- require 'rubygems'
11
- require 'rake'
12
- require 'bundler'
13
-
14
- Bundler.setup(:default)
15
-
16
- require 'active_record'
17
- require 'pg'
18
-
19
- exit begin
20
- connection_tries ||= 3
21
- ActiveRecord::Base.establish_connection && ActiveRecord::Migrator.current_version
22
- 0
23
- rescue PG::ConnectionBad
24
- unless (connection_tries -= 1).zero?
25
- puts "Retrying DB connection #{connection_tries} more times..."
26
- sleep ENV.fetch('APP_SETUP_WAIT', '5').to_i
27
- retry
28
- end
29
- 1
30
- rescue ActiveRecord::NoDatabaseError, ActiveRecord::AdapterNotSpecified
31
-
32
- include ActiveRecord::Tasks
33
-
34
- DatabaseTasks.root = File.expand_path '../..', __FILE__
35
- DatabaseTasks.db_dir = File.join DatabaseTasks.root, 'db'
36
- DatabaseTasks.env = ENV.fetch 'ENV', ENV.fetch('RAILS_ENV', 'development')
37
-
38
- # The App database seeder:
39
- DatabaseTasks.seed_loader = (Class.new do
40
- def load_seed
41
- seed_file_path = File.join DatabaseTasks.db_dir, 'seeds.rb'
42
- raise "Seed file '#{seed_file_path}' does not exist" unless File.file?(seed_file_path)
43
- load seed_file_path
44
- end
45
- end).new
46
-
47
- # Add model dirs to the autoload_paths for the seeder to run smoothly:
48
- ActiveSupport::Dependencies.autoload_paths << File.join(DatabaseTasks.root, 'app', 'models', 'concerns')
49
- ActiveSupport::Dependencies.autoload_paths << File.join(DatabaseTasks.root, 'app', 'models')
50
-
51
- return 2 unless DatabaseTasks.create_current
52
- return 3 unless DatabaseTasks.load_schema_current
53
- return 4 unless DatabaseTasks.load_seed
54
- 0
55
- ensure
56
- ActiveRecord::Base.clear_all_connections!
57
- end
@@ -1,20 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- # ln -s ../ gems/sidekiq-unique-jobs
6
- cp -f config/database.docker.yml config/database.yml
7
- # cp -f config/application.docker.yml config/application.yml
8
-
9
- # build app image
10
- docker-compose build
11
-
12
- # start mysql and redis in background
13
- docker-compose start postgres
14
- docker-compose start redis
15
-
16
- # setup database
17
- docker-compose run web rake db:create db:migrate
18
-
19
- # ensure all containers are up and running
20
- docker-compose up
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../config/application', __dir__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
-
9
- def system!(*args)
10
- system(*args) || abort("\n== Command #{args} failed ==")
11
- end
12
-
13
- chdir APP_ROOT do
14
- # This script is a starting point to setup your application.
15
- # Add necessary setup steps to this file.
16
-
17
- puts '== Installing dependencies =='
18
- system! 'gem install bundler --conservative'
19
- system('bundle check') || system!('bundle install')
20
-
21
- # puts "\n== Copying sample files =="
22
- # unless File.exist?('config/database.yml')
23
- # cp 'config/database.yml.sample', 'config/database.yml'
24
- # end
25
-
26
- puts "\n== Preparing database =="
27
- system! 'bin/rails db:setup'
28
-
29
- puts "\n== Removing old logs and tempfiles =="
30
- system! 'bin/rails log:clear tmp:clear'
31
-
32
- puts "\n== Restarting application server =="
33
- system! 'bin/rails restart'
34
- end
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
-
9
- def system!(*args)
10
- system(*args) || abort("\n== Command #{args} failed ==")
11
- end
12
-
13
- chdir APP_ROOT do
14
- # This script is a way to update your development environment automatically.
15
- # Add necessary update steps to this file.
16
-
17
- puts '== Installing dependencies =='
18
- system! 'gem install bundler --conservative'
19
- system('bundle check') || system!('bundle install')
20
-
21
- puts "\n== Updating database =="
22
- system! 'bin/rails db:migrate'
23
-
24
- puts "\n== Removing old logs and tempfiles =="
25
- system! 'bin/rails log:clear tmp:clear'
26
-
27
- puts "\n== Restarting application server =="
28
- system! 'bin/rails restart'
29
- end
@@ -1,6 +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
- Rails.application.eager_load!
5
-
6
- run ActionCable.server
@@ -1,50 +0,0 @@
1
- version: '2'
2
- services:
3
- rails:
4
- image: ruby:2.3
5
- # build:
6
- # context: .
7
- # dockerfile: docker/rails.Dockerfile
8
- # We'll specify a dotenv file for docker-compose to load more environment
9
- # variables into our app containers. This dotenv file would normally contain
10
- # sensitive data (API keys & secrets, etc) which SHOULD NOT be committed into
11
- # Git.
12
- # Keep in mind that any changes in this file will require a container restart
13
- # in order to be available on the app containers:
14
- env_file:
15
- - dev.env
16
- # Specify environment variables available for our app containers. We'll leave
17
- # a YML anchor in case we need to override or add more variables if needed on
18
- # each app container:
19
- environment: &app_environment
20
- # We'll overwrite the PATH environment variable to include the 'bin/'
21
- # directory, for the entrypoint script to find the app's executables:
22
- PATH: /usr/src/app/bin:/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
23
-
24
- # We'll set the REDIS_URL environment variable for the app to connect
25
- # to our redis container:
26
- REDIS_URL: redis://redis:6379
27
-
28
- # We'll set the RAILS_ENV and RACK_ENV environment variables to
29
- # 'development', so our app containers will start in 'development' mode
30
- # on this compose project:
31
- RAILS_ENV: development
32
- RACK_ENV: development
33
- cpu_shares: 4
34
- # Specify the directory from where all commands sent to the container will be
35
- # issued to where the code is mounted:
36
- working_dir: /usr/src/app
37
-
38
- # Keep the stdin open, so we can attach to our app container's process
39
- # and do things such as byebug, etc:
40
- stdin_open: true
41
-
42
- # Enable sending signals (CTRL+C, CTRL+P + CTRL+Q) into the container:
43
- tty: true
44
- volumes:
45
- # Mount our app code directory (".") into our app containers at the
46
- # "/usr/src/app" folder:
47
- - .:/usr/src/app
48
-
49
- # Mount the 'gems' volume on the folder that stores bundled gems:
50
- - gems:/usr/local/bundle
@@ -1,27 +0,0 @@
1
- require_relative 'boot'
2
-
3
- require 'bigdecimal'
4
- require 'bigdecimal/util'
5
- require 'rails/all'
6
-
7
- # Require the gems listed in Gemfile, including any gems
8
- # you've limited to :test, :development, or :production.
9
- Bundler.require(*Rails.groups)
10
-
11
- module RailsExample
12
- class Application < Rails::Application
13
- # Settings in config/environments/* take precedence over those specified here.
14
- # Application configuration should go into files in config/initializers
15
- # -- all .rb files in that directory are automatically loaded.
16
-
17
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
18
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
19
- config.time_zone = 'CET'
20
-
21
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
22
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
23
- # config.i18n.default_locale = :de
24
-
25
- # config.active_record.schema_format = :sql
26
- end
27
- end
@@ -1,3 +0,0 @@
1
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
-
3
- require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -1,9 +0,0 @@
1
- development:
2
- adapter: async
3
-
4
- test:
5
- adapter: async
6
-
7
- production:
8
- adapter: redis
9
- url: redis://localhost:6379/1
@@ -1,12 +0,0 @@
1
- development:
2
- adapter: postgresql
3
- database: rails_example_dev
4
- pool: 5
5
- timeout: 5000
6
-
7
- test:
8
- adapter: postgresql
9
- database: rails_example_test
10
- pool: 5
11
- timeout: 5000
12
-
@@ -1,19 +0,0 @@
1
- defaults: &defaults
2
- encoding: unicode
3
- adapter: postgresql
4
- host: <%= ENV.fetch('DB_HOST') { 'localhost' } %>
5
- port: <%= ENV.fetch('DB_PORT') { 5432 } %>
6
- username: <%= ENV.fetch('DB_USERNAME') { 'postgres' } %>
7
- password: <%= ENV.fetch('DB_PASSWORD') { '' } %>
8
- pool: <%= ENV.fetch('DB_POOL') { 25 } %>
9
- timeout: <%= ENV.fetch('DB_TIMEOUT') { 5000 } %>
10
- reaping_frequency: <%= ENV.fetch('DB_REAPING_FREQUENCY') { 5000 } %>
11
-
12
- development:
13
- <<: *defaults
14
- database: rails_example_dev
15
-
16
- test:
17
- <<: *defaults
18
- database: rails_example_test
19
-
@@ -1,5 +0,0 @@
1
- # Load the Rails application.
2
- require_relative 'application'
3
-
4
- # Initialize the Rails application.
5
- Rails.application.initialize!
@@ -1,54 +0,0 @@
1
- Rails.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
- # Do not eager load code on boot.
10
- config.eager_load = false
11
-
12
- # Show full error reports.
13
- config.consider_all_requests_local = true
14
-
15
- # Enable/disable caching. By default caching is disabled.
16
- if Rails.root.join('tmp/caching-dev.txt').exist?
17
- config.action_controller.perform_caching = true
18
-
19
- config.cache_store = :memory_store
20
- config.public_file_server.headers = {
21
- 'Cache-Control' => 'public, max-age=172800'
22
- }
23
- else
24
- config.action_controller.perform_caching = false
25
-
26
- config.cache_store = :null_store
27
- end
28
-
29
- # Don't care if the mailer can't send.
30
- config.action_mailer.raise_delivery_errors = false
31
-
32
- config.action_mailer.perform_caching = false
33
-
34
- # Print deprecation notices to the Rails logger.
35
- config.active_support.deprecation = :log
36
-
37
- # Raise an error on page load if there are pending migrations.
38
- config.active_record.migration_error = :page_load
39
-
40
- # Debug mode disables concatenation and preprocessing of assets.
41
- # This option may cause significant delays in view rendering with a large
42
- # number of complex assets.
43
- config.assets.debug = true
44
-
45
- # Suppress logger output for asset requests.
46
- config.assets.quiet = true
47
-
48
- # Raises error for missing translations
49
- # config.action_view.raise_on_missing_translations = true
50
-
51
- # Use an evented file watcher to asynchronously detect changes in source code,
52
- # routes, locales, etc. This feature depends on the listen gem.
53
- # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54
- end
@@ -1,86 +0,0 @@
1
- Rails.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
- # Eager load code on boot. This eager loads most of Rails and
8
- # your application in memory, allowing both threaded web servers
9
- # and those relying on copy on write to perform better.
10
- # Rake tasks automatically ignore this option for performance.
11
- config.eager_load = true
12
-
13
- # Full error reports are disabled and caching is turned on.
14
- config.consider_all_requests_local = false
15
- config.action_controller.perform_caching = true
16
-
17
- # Disable serving static files from the `/public` folder by default since
18
- # Apache or NGINX already handles this.
19
- config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20
-
21
- # Compress JavaScripts and CSS.
22
- config.assets.js_compressor = :uglifier
23
- # config.assets.css_compressor = :sass
24
-
25
- # Do not fallback to assets pipeline if a precompiled asset is missed.
26
- config.assets.compile = false
27
-
28
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29
-
30
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
31
- # config.action_controller.asset_host = 'http://assets.example.com'
32
-
33
- # Specifies the header that your server uses for sending files.
34
- # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
35
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
36
-
37
- # Mount Action Cable outside main process or domain
38
- # config.action_cable.mount_path = nil
39
- # config.action_cable.url = 'wss://example.com/cable'
40
- # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
41
-
42
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
- # config.force_ssl = true
44
-
45
- # Use the lowest log level to ensure availability of diagnostic information
46
- # when problems arise.
47
- config.log_level = :debug
48
-
49
- # Prepend all log lines with the following tags.
50
- config.log_tags = [:request_id]
51
-
52
- # Use a different cache store in production.
53
- # config.cache_store = :mem_cache_store
54
-
55
- # Use a real queuing backend for Active Job (and separate queues per environment)
56
- # config.active_job.queue_adapter = :resque
57
- # config.active_job.queue_name_prefix = "rails_example_#{Rails.env}"
58
- config.action_mailer.perform_caching = false
59
-
60
- # Ignore bad email addresses and do not raise email delivery errors.
61
- # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62
- # config.action_mailer.raise_delivery_errors = false
63
-
64
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65
- # the I18n.default_locale when a translation cannot be found).
66
- config.i18n.fallbacks = true
67
-
68
- # Send deprecation notices to registered listeners.
69
- config.active_support.deprecation = :notify
70
-
71
- # Use default logging formatter so that PID and timestamp are not suppressed.
72
- config.log_formatter = ::Logger::Formatter.new
73
-
74
- # Use a different logger for distributed setups.
75
- # require 'syslog/logger'
76
- # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
77
-
78
- if ENV['RAILS_LOG_TO_STDOUT'].present?
79
- logger = ActiveSupport::Logger.new(STDOUT)
80
- logger.formatter = config.log_formatter
81
- config.logger = ActiveSupport::TaggedLogging.new(logger)
82
- end
83
-
84
- # Do not dump schema after migrations.
85
- config.active_record.dump_schema_after_migration = false
86
- end
@@ -1,42 +0,0 @@
1
- Rails.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
- # Do not eager load code on boot. This avoids loading your whole application
11
- # just for the purpose of running a single test. If you are using a tool that
12
- # preloads Rails for running tests, you may have to set it to true.
13
- config.eager_load = false
14
-
15
- # Configure public file server for tests with Cache-Control for performance.
16
- config.public_file_server.enabled = true
17
- config.public_file_server.headers = {
18
- 'Cache-Control' => 'public, max-age=3600'
19
- }
20
-
21
- # Show full error reports and disable caching.
22
- config.consider_all_requests_local = true
23
- config.action_controller.perform_caching = false
24
-
25
- # Raise exceptions instead of rendering exception templates.
26
- config.action_dispatch.show_exceptions = false
27
-
28
- # Disable request forgery protection in test environment.
29
- config.action_controller.allow_forgery_protection = false
30
- config.action_mailer.perform_caching = false
31
-
32
- # Tell Action Mailer not to deliver emails to the real world.
33
- # The :test delivery method accumulates sent emails in the
34
- # ActionMailer::Base.deliveries array.
35
- config.action_mailer.delivery_method = :test
36
-
37
- # Print deprecation notices to the stderr.
38
- config.active_support.deprecation = :stderr
39
-
40
- # Raises error for missing translations
41
- # config.action_view.raise_on_missing_translations = true
42
- end
@@ -1,6 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # ApplicationController.renderer.defaults.merge!(
4
- # http_host: 'example.org',
5
- # https: false
6
- # )
@@ -1,11 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Version of your assets, change this if you want to expire all your assets.
4
- Rails.application.config.assets.version = '1.0'
5
-
6
- # Add additional assets to the asset load path
7
- # Rails.application.config.assets.paths << Emoji.images_path
8
-
9
- # Precompile additional assets.
10
- # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11
- # Rails.application.config.assets.precompile += %w( search.js )
@@ -1,9 +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
7
- # if you're trying to debug a problem that might stem
8
- # from framework code.
9
- # Rails.backtrace_cleaner.remove_silencers!
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Specify a serializer for the signed and encrypted cookie jars.
4
- # Valid options are :json, :marshal, and :hybrid.
5
- Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,4 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]
@@ -1,16 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format. Inflections
4
- # are locale specific, and you may define rules for as many different
5
- # locales as you wish. All of these examples are active by default:
6
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
- # inflect.plural /^(ox)$/i, '\1en'
8
- # inflect.singular /^(ox)en/i, '\1'
9
- # inflect.irregular 'person', 'people'
10
- # inflect.uncountable %w( fish sheep )
11
- # end
12
-
13
- # These inflection rules are supported but not enabled by default:
14
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
- # inflect.acronym 'RESTful'
16
- # end
@@ -1,4 +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
@@ -1,23 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
- #
3
- # This file contains migration options to ease your Rails 5.0 upgrade.
4
- #
5
- # Once upgraded flip defaults one by one to migrate to the new default.
6
- #
7
- # Read the Rails 5.0 release notes for more info on each option.
8
-
9
- # Enable per-form CSRF tokens. Previous versions had false.
10
- Rails.application.config.action_controller.per_form_csrf_tokens = false
11
-
12
- # Enable origin-checking CSRF mitigation. Previous versions had false.
13
- Rails.application.config.action_controller.forgery_protection_origin_check = false
14
-
15
- # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
16
- # Previous versions had false.
17
- ActiveSupport.to_time_preserves_timezone = false
18
-
19
- # Require `belongs_to` associations by default. Previous versions had false.
20
- Rails.application.config.active_record.belongs_to_required_by_default = false
21
-
22
- # Do not halt callback chains when a callback returns false. Previous versions had true.
23
- ActiveSupport.halt_callback_chains_on_return_false = true
@@ -1,3 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- Rails.application.config.session_store :cookie_store, key: '_rails_example_session'