Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename rails_example to my_app #385

Merged
merged 3 commits into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ exclude_patterns:
- "*.gemspec"
- "Appraisals"
- "gemfiles/"
- "rails_example/"
- "my_app/"
- "redis/"
- "tmp/"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
coverage/
Gemfile.lock
gemfiles/*.lock
rails_example/spec/examples.txt
my_app/spec/examples.txt
tmp/
2 changes: 1 addition & 1 deletion .reek.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
exclude_paths:
- rails_example
- my_app
- redis
- spec
- tmp
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Style/Documentation:
Enabled: true
Exclude:
- "examples/**/*.rb"
- "rails_example/**/*.rb"
- "my_app/**/*.rb"
- "bin/**/*.rb"
- "lib/sidekiq_unique_jobs/testing.rb"
- "lib/sidekiq_unique_jobs/core_ext.rb"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ With this lock type it is possible to put any number of these jobs on the queue,
sidekiq_options lock: :while_executing, lock_timeout: nil
```

There is an example of this to try it out in the `rails_example` application. Run `foreman start` in the root of the directory and open the url: `localhost:5000/work/duplicate_while_executing`.
There is an example of this to try it out in the `my_app` application. Run `foreman start` in the root of the directory and open the url: `localhost:5000/work/duplicate_while_executing`.

In the console you should see something like:

Expand Down
7 changes: 4 additions & 3 deletions rails_example/.env → my_app/.env
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
SECRET_KEY_BASE=10167c7f7654ed02b3557b05b88ece1866a9748a2e8e064016f76cb74ddae38264f7403ba65f301d63c21d770e0ee2ac6906f245e904b3b140d12297f67e0db1
APP_DOMAIN=localhost
APP_WEB_URL=http://localhost:3000
APP_CABLE_URL=ws://localhost:28080
WEB_CONSOLE_WHITELISTED_IPS=127.0.0.1 ::1 127.0.0.0/8 ::1
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=mhenrixon
DB_USERNAME=mikaelhenriksson
DB_PASSWORD=
DB_POOL=25
DB_TIMEOUT=5000
DB_REAPING_FREQUENCY=10
REDIS_URL=redis://localhost:6379/7
SECRET_KEY_BASE=10167c7f7654ed02b3557b05b88ece1866a9748a2e8e064016f76cb74ddae38264f7403ba65f301d63c21d770e0ee2ac6906f245e904b3b140d12297f67e0db1
WEB_CONSOLE_WHITELISTED_IPS=127.0.0.1 ::1 127.0.0.0/8 ::1
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions my_app/app/controllers/issues_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

class IssuesController < ApplicationController
def index
render :index
end

def show
number_to_perform.times do
if worker_args.present?
worker_class.perform_async(worker_args)
else
worker_class.perform_async
end
end

redirect_to '/sidekiq'
end

private

def worker_class
@worker_class ||= "Issue#{params.permit(:id)}".constantize
end

def worker_args
params.permit(:args) || nil
end

def number_to_perform
params.permit(:times) || 4
end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions my_app/app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
doctype html
html
head
title MyApp
/ = stylesheet_link_tag 'application', media: 'all'
/ = javascript_include_tag 'application'
= csrf_meta_tags
body
ul#top-menu
li.menu-item
= link_to 'Issue 384', issue_384_path

= yield
13 changes: 13 additions & 0 deletions my_app/app/workers/issue_384_worker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Issue384Worker
include Sidekiq::Worker

sidekiq_options lock: :while_executing,
lock_timeout: nil,
on_conflict: :reschedule

def perform
puts 'hello'
sleep 1
puts 'bye'
end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module RailsExample
module MyApp
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# Applicationconfiguration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
Expand All @@ -25,5 +25,6 @@ class Application < Rails::Application
# config.i18n.default_locale = :de

# config.active_record.schema_format = :sql
config.autoload_paths += %w[app/workers]
end
end
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ defaults: &defaults
adapter: postgresql
host: <%= ENV.fetch('DB_HOST') { 'localhost' } %>
port: <%= ENV.fetch('DB_PORT') { 5432 } %>
username: <%= ENV.fetch('DB_USERNAME') { `whoami` } %>
username: <%= ENV.fetch('DB_USERNAME') { system("whoami") } %>
password: <%= ENV.fetch('DB_PASSWORD') { nil } %>

development:
<<: *defaults
database: rails_example_dev
database: my_app_dev

test:
<<: *defaults
database: rails_example_test
database: my_app_test

production:
<<: *defaults
database: rails_example_prod
database: my_app_prod

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "rails_example_#{Rails.env}"
# config.active_job.queue_name_prefix = "my_app_#{Rails.env}"
config.action_mailer.perform_caching = false

# Ignore bad email addresses and do not raise email delivery errors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_rails_example_session'
Rails.application.config.session_store :cookie_store, key: '_my_app_session'
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@
end

Sidekiq.log_format = :json if Sidekiq.respond_to?(:log_format)
SidekiqUniqueJobs.logger.level = Object.const_get("Logger::#{ENV.fetch('LOGLEVEL') { 'debug' }.upcase}")
SidekiqUniqueJobs.logger.level = Logger::DEBUG

Dir[Rails.root.join("app", "workers", "**", "*.rb")].each { |worker| require worker }
File renamed without changes.
14 changes: 7 additions & 7 deletions rails_example/config/puma.rb → my_app/config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

# Store the pid of the server in the file at "path".
#
# pidfile '/u/apps/lolcat/tmp/pids/puma.pid'
pidfile 'tmp/pids/puma.pid'

# Use "path" as the file to store the server info state. This is
# used by "pumactl" to query and control the server.
#
# state_path '/u/apps/lolcat/tmp/pids/puma.state'
state_path 'tmp/pids/puma.state'

# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
Expand All @@ -22,8 +22,8 @@
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# preload_app!
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
preload_app!

# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
Expand All @@ -32,9 +32,9 @@
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end

# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
9 changes: 9 additions & 0 deletions my_app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

Rails.application.routes.draw do
require 'sidekiq_unique_jobs/web'
require 'sidekiq-status/web'
mount Sidekiq::Web, at: '/sidekiq'

get 'issues/:id' => 'issues#show'
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

my_first_job:
cron: "*/2 * * * *"
class: "HardWorker"
class: "Issue384Worker"
queue: default
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 0 additions & 17 deletions rails_example/app/channels/appearance_channel.rb

This file was deleted.

6 changes: 0 additions & 6 deletions rails_example/app/channels/application_cable/channel.rb

This file was deleted.

11 changes: 0 additions & 11 deletions rails_example/app/channels/application_cable/connection.rb

This file was deleted.

7 changes: 0 additions & 7 deletions rails_example/app/channels/post_channel.rb

This file was deleted.

59 changes: 0 additions & 59 deletions rails_example/app/controllers/work_controller.rb

This file was deleted.

25 changes: 0 additions & 25 deletions rails_example/app/views/layouts/application.html.slim

This file was deleted.

15 changes: 0 additions & 15 deletions rails_example/app/workers/hard_worker.rb

This file was deleted.

Loading