Skip to content

Commit

Permalink
Delay initialization until Rails is fully initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryTsepelev committed Feb 1, 2021
1 parent 83fe59c commit e3a1fbd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
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

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?
9 changes: 9 additions & 0 deletions lib/sidekiq/grouping/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Sidekiq
module Grouping
class Railtie < ::Rails::Railtie
config.after_initialize do
Sidekiq::Grouping.start! if Sidekiq.server?
end
end
end
end

0 comments on commit e3a1fbd

Please sign in to comment.