totoro 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/docker-compose.yml +1 -0
  3. data/lib/generators/totoro/init_generator.rb +1 -0
  4. data/lib/generators/totoro/templates/create_totoro_failed_messages.rb +11 -0
  5. data/lib/totoro.rb +3 -0
  6. data/lib/totoro/base_queue.rb +9 -0
  7. data/lib/totoro/message_resender.rb +21 -0
  8. data/lib/totoro/railtie.rb +15 -0
  9. data/lib/totoro/tasks/resend_message.rake +8 -0
  10. data/lib/totoro/totoro_failed_message.rb +8 -0
  11. data/lib/totoro/version.rb +1 -1
  12. data/test/totoro_test/Gemfile +6 -4
  13. data/test/totoro_test/Gemfile.lock +15 -3
  14. data/test/totoro_test/app/models/worker/example_queue.rb +2 -5
  15. data/test/totoro_test/bin/bundle +1 -1
  16. data/test/totoro_test/bin/delayed_job +5 -0
  17. data/test/totoro_test/bin/rails +1 -1
  18. data/test/totoro_test/bin/rake +1 -1
  19. data/test/totoro_test/bin/setup +1 -2
  20. data/test/totoro_test/bin/spring +1 -1
  21. data/test/totoro_test/bin/update +1 -1
  22. data/test/totoro_test/config/application.rb +10 -9
  23. data/test/totoro_test/config/database.yml +40 -10
  24. data/test/totoro_test/config/environments/production.rb +2 -3
  25. data/test/totoro_test/config/initializers/totoro.rb +1 -1
  26. data/test/totoro_test/config/puma.rb +3 -3
  27. data/test/totoro_test/config/spring.rb +2 -2
  28. data/test/totoro_test/config/totoro.yml +1 -1
  29. data/test/totoro_test/db/development.sqlite3 +0 -0
  30. data/test/totoro_test/db/migrate/20181019041208_create_delayed_jobs.rb +22 -0
  31. data/test/totoro_test/db/migrate/20181019070846_create_totoro_failed_messages.rb +11 -0
  32. data/test/totoro_test/db/schema.rb +39 -0
  33. data/test/totoro_test/db/test.sqlite3 +0 -0
  34. data/test/totoro_test/test/test_helper.rb +1 -1
  35. data/totoro.gemspec +2 -0
  36. metadata +41 -3
  37. data/pkg/totoro-0.4.1.gem +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 321d976fc93e094bb8c965380ee0b4e110d8581d3e9520e3c839546ad07084d0
4
- data.tar.gz: 1a847abeee7c07aa92383fb43d93dde2c104ec1fc65c730b28ccd5d15c200b07
3
+ metadata.gz: 0e835b3b9956681b140dde6f1a471349612cb863e2744e7a292d0505df22ed25
4
+ data.tar.gz: 10226f19be041d051c9c9a7ff091ac147508cc32a974cb7869bb7ffce0615cb0
5
5
  SHA512:
6
- metadata.gz: d0bb50a46bb9b9fe69eb4adb331b3fb62636591cc689f294dc825b54b3d8819690c8872e84b488963090fa4cebfbc7d9d2b53c64c229a75d93e3aa757cc0875f
7
- data.tar.gz: 0f79b42f76edcdfbfb486a9270c2b82862c683ae54ee30fccfc760444c0753afb1a827dbc62517dafe680748dd9724113aea32f48e43007706a97794671d7d97
6
+ metadata.gz: 563b7abfd127453918a2f56c40131415bdb14829463f92ffd41d78cef823985a43f32678991d6f0d9b8ab61d45c332037b05776157aa549313031234c28988cf
7
+ data.tar.gz: 3620dedf09672a6560c9b40415431a3b23b4e06bc574792b7cf7dc2f2088f47dd56a09e860d590f6d4a64b03920c2dac74e472857d80340d9904a2b303805dd0
data/docker-compose.yml CHANGED
@@ -29,6 +29,7 @@ services:
29
29
  - .:/totoro
30
30
  command: totoro example_queue
31
31
  environment:
32
+ POSTGRES_HOST: db
32
33
  POSTGRES_USER: root
33
34
  POSTGRES_PASSWORD: root
34
35
  RABBITMQ_HOST: rabbitmq
@@ -6,6 +6,7 @@ module Totoro
6
6
  desc 'Generate totoro config file'
7
7
 
8
8
  def copy_config_file
9
+ template 'create_totoro_failed_messages.rb', File.join('db/migrate', "#{Time.now.strftime('%Y%m%d%H%M%S')}_create_totoro_failed_messages.rb")
9
10
  template 'totoro.yml', File.join('config', 'totoro.yml')
10
11
  template 'initializer.rb', File.join('config/initializers', 'totoro.rb')
11
12
  end
@@ -0,0 +1,11 @@
1
+ class CreateTotoroFailedMessages < ActiveRecord::Migration[5.1]
2
+ def change
3
+ enable_extension "plpgsql"
4
+ create_table :totoro_failed_messages do |t|
5
+ t.string :class_name
6
+ t.string :queue_id
7
+ t.jsonb :payload
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
data/lib/totoro.rb CHANGED
@@ -5,6 +5,9 @@ require 'totoro/config'
5
5
  require 'totoro/base_queue'
6
6
  require 'totoro/base_worker'
7
7
  require 'totoro/initializer'
8
+ require 'totoro/message_resender'
9
+ require 'totoro/totoro_failed_message'
10
+ require 'totoro/railtie' if defined?(Rails)
8
11
 
9
12
  module Totoro
10
13
  # Your code goes here...
@@ -28,6 +28,15 @@ module Totoro
28
28
  exchange.publish(payload, routing_key: queue.name)
29
29
  Rails.logger.info "send message to #{queue.name}"
30
30
  STDOUT.flush
31
+ rescue Bunny::TCPConnectionFailedForAllHosts => error
32
+ Rails.logger.error error.message
33
+ Rails.logger.info 'Add failed message to resend list'
34
+ STDOUT.flush
35
+ Totoro::TotoroFailedMessage.create(
36
+ class_name: to_s,
37
+ queue_id: id,
38
+ payload: payload
39
+ )
31
40
  end
32
41
 
33
42
  def subscribe(id)
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'delayed_job_recurring'
4
+
5
+ module Totoro
6
+ class MessageResender
7
+ include Delayed::RecurringJob
8
+ run_every 10.second
9
+ queue 'totoro'
10
+ def perform
11
+ Totoro::Queue.connection
12
+ Totoro::TotoroFailedMessage.all.each do |m|
13
+ m.class_name.constantize.enqueue(m.queue_id, m.payload)
14
+ m.destroy
15
+ end
16
+ rescue Bunny::TCPConnectionFailedForAllHosts => error
17
+ Rails.logger.error error.message
18
+ STDOUT.flush
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'totoro'
4
+ require 'rails'
5
+
6
+ module Totoro
7
+ class Railtie < Rails::Railtie
8
+ railtie_name :totoro
9
+
10
+ rake_tasks do
11
+ path = File.expand_path(__dir__)
12
+ Dir.glob("#{path}/tasks/*.rake").each { |f| load f }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :totoro do
4
+ desc 'resend failed message'
5
+ task resend_msg: :environment do
6
+ Totoro::MessageResender.schedule!
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_record/railtie'
4
+ module Totoro
5
+ class TotoroFailedMessage < ActiveRecord::Base
6
+ end
7
+ end
8
+ # Totoro.constants.select {|c| Totoro.const_get(c).is_a? Class}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Totoro
4
- VERSION = '0.4.1'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -1,15 +1,17 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  git_source(:github) do |repo_name|
4
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
5
5
  "https://github.com/#{repo_name}.git"
6
6
  end
7
7
 
8
+ gem 'delayed_job_active_record'
9
+ gem 'delayed_job_recurring'
8
10
  gem 'totoro', path: '/totoro'
9
11
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
10
12
  gem 'rails', '~> 5.1.6'
11
13
  # Use sqlite3 as the database for Active Record
12
- gem 'sqlite3'
14
+ gem 'pg'
13
15
  # Use Puma as the app server
14
16
  gem 'puma', '~> 3.7'
15
17
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
@@ -27,7 +29,7 @@ gem 'puma', '~> 3.7'
27
29
 
28
30
  group :development, :test do
29
31
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
30
- gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
32
+ gem 'byebug', platforms: %i[mri mingw x64_mingw]
31
33
  end
32
34
 
33
35
  group :development do
@@ -38,4 +40,4 @@ group :development do
38
40
  end
39
41
 
40
42
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
41
- gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
43
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
@@ -1,8 +1,10 @@
1
1
  PATH
2
2
  remote: /totoro
3
3
  specs:
4
- totoro (0.2.9)
4
+ totoro (0.5.0)
5
5
  bunny (~> 2.10)
6
+ delayed_job_active_record (~> 4.1.3)
7
+ delayed_job_recurring (~> 0.3.7)
6
8
 
7
9
  GEM
8
10
  remote: https://rubygems.org/
@@ -52,6 +54,14 @@ GEM
52
54
  byebug (10.0.2)
53
55
  concurrent-ruby (1.0.5)
54
56
  crass (1.0.4)
57
+ delayed_job (4.1.5)
58
+ activesupport (>= 3.0, < 5.3)
59
+ delayed_job_active_record (4.1.3)
60
+ activerecord (>= 3.0, < 5.3)
61
+ delayed_job (>= 3.0, < 5)
62
+ delayed_job_recurring (0.3.7)
63
+ delayed_job (>= 3.0)
64
+ delayed_job_active_record
55
65
  erubi (1.7.1)
56
66
  ffi (1.9.25)
57
67
  globalid (0.4.1)
@@ -74,6 +84,7 @@ GEM
74
84
  nio4r (2.3.1)
75
85
  nokogiri (1.8.4)
76
86
  mini_portile2 (~> 2.3.0)
87
+ pg (1.1.3)
77
88
  puma (3.12.0)
78
89
  rack (2.0.5)
79
90
  rack-test (1.1.0)
@@ -118,7 +129,6 @@ GEM
118
129
  actionpack (>= 4.0)
119
130
  activesupport (>= 4.0)
120
131
  sprockets (>= 3.0.0)
121
- sqlite3 (1.3.13)
122
132
  thor (0.20.0)
123
133
  thread_safe (0.3.6)
124
134
  tzinfo (1.2.5)
@@ -132,12 +142,14 @@ PLATFORMS
132
142
 
133
143
  DEPENDENCIES
134
144
  byebug
145
+ delayed_job_active_record
146
+ delayed_job_recurring
135
147
  listen (>= 3.0.5, < 3.2)
148
+ pg
136
149
  puma (~> 3.7)
137
150
  rails (~> 5.1.6)
138
151
  spring
139
152
  spring-watcher-listen (~> 2.0.0)
140
- sqlite3
141
153
  totoro!
142
154
  tzinfo-data
143
155
 
@@ -3,11 +3,8 @@
3
3
  module Worker
4
4
  class ExampleQueue < Totoro::BaseWorker
5
5
  setup queue_name: 'example_queue'
6
- def process(payload, metadata, delivery_info)
7
- (1..10).each do |i|
8
- p i
9
- sleep 1
10
- end
6
+ def process(payload, _metadata, _delivery_info)
7
+ p payload
11
8
  end
12
9
  end
13
10
  end
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
3
  load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
4
+ require 'delayed/command'
5
+ Delayed::Command.new(ARGV).daemonize
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  begin
3
- load File.expand_path('../spring', __FILE__)
3
+ load File.expand_path('spring', __dir__)
4
4
  rescue LoadError => e
5
5
  raise unless e.message.include?('spring')
6
6
  end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  begin
3
- load File.expand_path('../spring', __FILE__)
3
+ load File.expand_path('spring', __dir__)
4
4
  rescue LoadError => e
5
5
  raise unless e.message.include?('spring')
6
6
  end
@@ -4,7 +4,7 @@ require 'fileutils'
4
4
  include FileUtils
5
5
 
6
6
  # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
7
+ APP_ROOT = Pathname.new File.expand_path('..', __dir__)
8
8
 
9
9
  def system!(*args)
10
10
  system(*args) || abort("\n== Command #{args} failed ==")
@@ -18,7 +18,6 @@ chdir APP_ROOT do
18
18
  system! 'gem install bundler --conservative'
19
19
  system('bundle check') || system!('bundle install')
20
20
 
21
-
22
21
  # puts "\n== Copying sample files =="
23
22
  # unless File.exist?('config/database.yml')
24
23
  # cp 'config/database.yml.sample', 'config/database.yml'
@@ -8,7 +8,7 @@ unless defined?(Spring)
8
8
  require 'bundler'
9
9
 
10
10
  lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11
- spring = lockfile.specs.detect { |spec| spec.name == "spring" }
11
+ spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
12
12
  if spring
13
13
  Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14
14
  gem 'spring', spring.version
@@ -4,7 +4,7 @@ require 'fileutils'
4
4
  include FileUtils
5
5
 
6
6
  # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
7
+ APP_ROOT = Pathname.new File.expand_path('..', __dir__)
8
8
 
9
9
  def system!(*args)
10
10
  system(*args) || abort("\n== Command #{args} failed ==")
@@ -1,16 +1,16 @@
1
1
  require_relative 'boot'
2
2
 
3
- require "rails"
3
+ require 'rails'
4
4
  # Pick the frameworks you want:
5
- require "active_model/railtie"
6
- require "active_job/railtie"
7
- require "active_record/railtie"
8
- require "action_controller/railtie"
9
- require "action_mailer/railtie"
10
- require "action_view/railtie"
11
- require "action_cable/engine"
5
+ require 'active_model/railtie'
6
+ require 'active_job/railtie'
7
+ require 'active_record/railtie'
8
+ require 'action_controller/railtie'
9
+ require 'action_mailer/railtie'
10
+ require 'action_view/railtie'
11
+ require 'action_cable/engine'
12
12
  # require "sprockets/railtie"
13
- require "rails/test_unit/railtie"
13
+ require 'rails/test_unit/railtie'
14
14
 
15
15
  # Require the gems listed in Gemfile, including any gems
16
16
  # you've limited to :test, :development, or :production.
@@ -29,5 +29,6 @@ module TotoroTest
29
29
  # Middleware like session, flash, cookies can be added back manually.
30
30
  # Skip views, helpers and assets when generating a new resource.
31
31
  config.api_only = true
32
+ config.active_job.queue_adapter = :delayed_job
32
33
  end
33
34
  end
@@ -1,25 +1,55 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
1
+ # MySQL. Versions 5.0 and up are supported.
3
2
  #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
3
+ # Install the MySQL driver
4
+ # gem install mysql2
5
+ #
6
+ # Ensure the MySQL gem is defined in your Gemfile
7
+ # gem 'mysql2'
8
+ #
9
+ # And be sure to use new-style password hashing:
10
+ # http://dev.mysql.com/doc/refman/5.7/en/old-client.html
6
11
  #
7
12
  default: &default
8
- adapter: sqlite3
9
- pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
- timeout: 5000
13
+ adapter: postgresql
14
+ encoding: unicode
15
+ pool: 5
16
+ username: <%= ENV['POSTGRES_USER'] %>
17
+ password: <%= ENV['POSTGRES_PASSWORD'] %>
18
+ host: <%= ENV['POSTGRES_HOST'] %>
11
19
 
12
20
  development:
13
21
  <<: *default
14
- database: db/development.sqlite3
22
+ database: totoro_development
15
23
 
16
24
  # Warning: The database defined as "test" will be erased and
17
25
  # re-generated from your development database when you run "rake".
18
26
  # Do not set this db to the same as development or production.
19
27
  test:
20
28
  <<: *default
21
- database: db/test.sqlite3
29
+ database: totoro_test
22
30
 
31
+ # As with config/secrets.yml, you never want to store sensitive information,
32
+ # like your database password, in your source code. If your source code is
33
+ # ever seen by anyone, they now have access to your database.
34
+ #
35
+ # Instead, provide the password as a unix environment variable when you boot
36
+ # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
37
+ # for a full rundown on how to provide these environment variables in a
38
+ # production deployment.
39
+ #
40
+ # On Heroku and other platform providers, you may have a full connection URL
41
+ # available as an environment variable. For example:
42
+ #
43
+ # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
44
+ #
45
+ # You can use this database configuration with:
46
+ #
47
+ # production:
48
+ # url: <%= ENV['DATABASE_URL'] %>
49
+ #
23
50
  production:
24
51
  <<: *default
25
- database: db/production.sqlite3
52
+ database: <%= ENV['DATABASE_NAME'] %>
53
+ host: <%= ENV['DATABASE_HOST'] %>
54
+ username: <%= ENV['DATABASE_USERNAME'] %>
55
+ password: <%= ENV['DATABASE_PASSWORD'] %>
@@ -23,7 +23,6 @@ Rails.application.configure do
23
23
  # Apache or NGINX already handles this.
24
24
  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
25
25
 
26
-
27
26
  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
28
27
  # config.action_controller.asset_host = 'http://assets.example.com'
29
28
 
@@ -45,7 +44,7 @@ Rails.application.configure do
45
44
  config.logger = Logger.new(STDOUT)
46
45
 
47
46
  # Prepend all log lines with the following tags.
48
- config.log_tags = [ :request_id ]
47
+ config.log_tags = [:request_id]
49
48
 
50
49
  # Use a different cache store in production.
51
50
  # config.cache_store = :mem_cache_store
@@ -72,7 +71,7 @@ Rails.application.configure do
72
71
  # Use a different logger for distributed setups.
73
72
  # require 'syslog/logger'
74
73
  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
75
- if ENV["RAILS_LOG_TO_STDOUT"].present?
74
+ if ENV['RAILS_LOG_TO_STDOUT'].present?
76
75
  logger = ActiveSupport::Logger.new(STDOUT)
77
76
  logger.formatter = config.log_formatter
78
77
  config.logger = ActiveSupport::TaggedLogging.new(logger)
@@ -1 +1 @@
1
- Totoro::Initializer.new.execute
1
+ Totoro::Initializer.new.execute
@@ -4,16 +4,16 @@
4
4
  # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
5
  # and maximum; this matches the default thread size of Active Record.
6
6
  #
7
- threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
7
+ threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
8
8
  threads threads_count, threads_count
9
9
 
10
10
  # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11
11
  #
12
- port ENV.fetch("PORT") { 3000 }
12
+ port ENV.fetch('PORT') { 3000 }
13
13
 
14
14
  # Specifies the `environment` that Puma will run in.
15
15
  #
16
- environment ENV.fetch("RAILS_ENV") { "development" }
16
+ environment ENV.fetch('RAILS_ENV') { 'development' }
17
17
 
18
18
  # Specifies the number of `workers` to boot in clustered mode.
19
19
  # Workers are forked webserver processes. If using threads and workers together
@@ -1,6 +1,6 @@
1
- %w(
1
+ %w[
2
2
  .ruby-version
3
3
  .rbenv-vars
4
4
  tmp/restart.txt
5
5
  tmp/caching-dev.txt
6
- ).each { |path| Spring.watch(path) }
6
+ ].each { |path| Spring.watch(path) }
@@ -28,4 +28,4 @@ test:
28
28
  <<: *default
29
29
 
30
30
  production:
31
- <<: *default
31
+ <<: *default
@@ -0,0 +1,22 @@
1
+ class CreateDelayedJobs < ActiveRecord::Migration[5.1]
2
+ def self.up
3
+ create_table :delayed_jobs, force: true do |table|
4
+ table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
5
+ table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
6
+ table.text :handler, null: false # YAML-encoded string of the object that will do work
7
+ table.text :last_error # reason for last failure (See Note below)
8
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
9
+ table.datetime :locked_at # Set when a client is working on this object
10
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
11
+ table.string :locked_by # Who is working on this object (if locked)
12
+ table.string :queue # The name of the queue this job is in
13
+ table.timestamps null: true
14
+ end
15
+
16
+ add_index :delayed_jobs, %i[priority run_at], name: 'delayed_jobs_priority'
17
+ end
18
+
19
+ def self.down
20
+ drop_table :delayed_jobs
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTotoroFailedMessages < ActiveRecord::Migration[5.1]
2
+ def change
3
+ enable_extension 'plpgsql'
4
+ create_table :totoro_failed_messages do |t|
5
+ t.string :class_name
6
+ t.string :queue_id
7
+ t.jsonb :payload
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,39 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 20_181_019_070_846) do
14
+ # These are extensions that must be enabled in order to support this database
15
+ enable_extension 'plpgsql'
16
+
17
+ create_table 'delayed_jobs', force: :cascade do |t|
18
+ t.integer 'priority', default: 0, null: false
19
+ t.integer 'attempts', default: 0, null: false
20
+ t.text 'handler', null: false
21
+ t.text 'last_error'
22
+ t.datetime 'run_at'
23
+ t.datetime 'locked_at'
24
+ t.datetime 'failed_at'
25
+ t.string 'locked_by'
26
+ t.string 'queue'
27
+ t.datetime 'created_at'
28
+ t.datetime 'updated_at'
29
+ t.index %w[priority run_at], name: 'delayed_jobs_priority'
30
+ end
31
+
32
+ create_table 'totoro_failed_messages', force: :cascade do |t|
33
+ t.string 'class_name'
34
+ t.string 'queue_id'
35
+ t.jsonb 'payload'
36
+ t.datetime 'created_at', null: false
37
+ t.datetime 'updated_at', null: false
38
+ end
39
+ end
File without changes
@@ -1,5 +1,5 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
- require File.expand_path('../../config/environment', __FILE__)
2
+ require File.expand_path('../config/environment', __dir__)
3
3
  require 'rails/test_help'
4
4
 
5
5
  class ActiveSupport::TestCase
data/totoro.gemspec CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ['lib']
22
22
 
23
23
  spec.add_dependency 'bunny', '~> 2.10'
24
+ spec.add_dependency 'delayed_job_active_record', '~> 4.1.3'
25
+ spec.add_dependency 'delayed_job_recurring', '~> 0.3.7'
24
26
 
25
27
  spec.add_development_dependency 'bundler', '~> 1.16'
26
28
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totoro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShuHui18
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-16 00:00:00.000000000 Z
11
+ date: 2018-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: delayed_job_active_record
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 4.1.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 4.1.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: delayed_job_recurring
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.3.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.7
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: bundler
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +116,7 @@ files:
88
116
  - docker-compose.yml
89
117
  - lib/generators/totoro/config_generator.rb
90
118
  - lib/generators/totoro/init_generator.rb
119
+ - lib/generators/totoro/templates/create_totoro_failed_messages.rb
91
120
  - lib/generators/totoro/templates/initializer.rb
92
121
  - lib/generators/totoro/templates/totoro.yml
93
122
  - lib/generators/totoro/templates/worker.rb.erb
@@ -97,8 +126,11 @@ files:
97
126
  - lib/totoro/base_worker.rb
98
127
  - lib/totoro/config.rb
99
128
  - lib/totoro/initializer.rb
129
+ - lib/totoro/message_resender.rb
130
+ - lib/totoro/railtie.rb
131
+ - lib/totoro/tasks/resend_message.rake
132
+ - lib/totoro/totoro_failed_message.rb
100
133
  - lib/totoro/version.rb
101
- - pkg/totoro-0.4.1.gem
102
134
  - spec/spec_helper.rb
103
135
  - spec/totoro_spec.rb
104
136
  - test/totoro_test/Gemfile
@@ -115,6 +147,7 @@ files:
115
147
  - test/totoro_test/app/views/layouts/mailer.html.erb
116
148
  - test/totoro_test/app/views/layouts/mailer.text.erb
117
149
  - test/totoro_test/bin/bundle
150
+ - test/totoro_test/bin/delayed_job
118
151
  - test/totoro_test/bin/rails
119
152
  - test/totoro_test/bin/rake
120
153
  - test/totoro_test/bin/setup
@@ -143,7 +176,12 @@ files:
143
176
  - test/totoro_test/config/secrets.yml
144
177
  - test/totoro_test/config/spring.rb
145
178
  - test/totoro_test/config/totoro.yml
179
+ - test/totoro_test/db/development.sqlite3
180
+ - test/totoro_test/db/migrate/20181019041208_create_delayed_jobs.rb
181
+ - test/totoro_test/db/migrate/20181019070846_create_totoro_failed_messages.rb
182
+ - test/totoro_test/db/schema.rb
146
183
  - test/totoro_test/db/seeds.rb
184
+ - test/totoro_test/db/test.sqlite3
147
185
  - test/totoro_test/public/robots.txt
148
186
  - test/totoro_test/test/test_helper.rb
149
187
  - totoro.gemspec
data/pkg/totoro-0.4.1.gem DELETED
Binary file