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

Delay initialization until Rails is fully initialized #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ Useful for:
*NOTE:* As of 1.0.6 works with Sidekiq 4.
*NOTE:* As of 1.0.8 Locking is atomic (set nx/ex) and will no longer lead to batches that are permalocked and stuck

## Installation
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this section to the top because non-Rails users will have to perform an extra setup


Add this line to your application's Gemfile:

gem 'sidekiq-grouping'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sidekiq-grouping

If you're using the gem outside of Rails, run Grouping when application is initialized:

```ruby
Sidekiq::Grouping.start! if Sidekiq.server?
```

## Usage

Create a worker:
Expand Down Expand Up @@ -195,20 +215,6 @@ end

```

## Installation

Add this line to your application's Gemfile:

gem 'sidekiq-grouping'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sidekiq-grouping

## Contributing

1. Fork it ( http://github.com/gzigzigzeo/sidekiq-grouping/fork )
Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq/grouping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "active_support/core_ext/numeric/time"
require "sidekiq/grouping/version"
require "concurrent"
require "sidekiq/grouping/railtie" if defined?(Rails)

module Sidekiq::Grouping
autoload :Config, "sidekiq/grouping/config"
Expand Down Expand Up @@ -50,4 +51,3 @@ def start!
end
end

Sidekiq::Grouping.start! if Sidekiq.server?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change, so I guess we'll need a major release

11 changes: 11 additions & 0 deletions lib/sidekiq/grouping/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module Sidekiq
DmitryTsepelev marked this conversation as resolved.
Show resolved Hide resolved
module Grouping
class Railtie < ::Rails::Railtie
config.after_initialize do
Sidekiq::Grouping.start! if Sidekiq.server?
end
end
end
end