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

Replace StopSignal with TrackBallast::StopSignal #70

Open
wants to merge 4 commits into
base: vs-deprecate-stop_signal
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
7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
PATH
remote: .
specs:
super_spreader (0.2.1)
super_spreader (1.0.0.beta)
activejob (>= 6.1, < 8.0)
activemodel (>= 6.1, < 8.0)
activerecord (>= 6.1, < 8.0)
activesupport (>= 6.1, < 8.0)
redis (>= 4.8, < 6.0)
track_ballast (>= 0.2.0.beta1)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -179,6 +180,10 @@ GEM
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.1)
thor (1.3.0)
track_ballast (0.2.0.beta1)
activerecord (>= 6.1, < 8.0)
activesupport (>= 6.1, < 8.0)
redis (>= 4.8, < 6.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
Expand Down
17 changes: 16 additions & 1 deletion lib/super_spreader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,27 @@
require "super_spreader/scheduler_job"
require "super_spreader/spread_tracker"
require "super_spreader/spreader"
require "super_spreader/stop_signal"
require "track_ballast/stop_signal"

module SuperSpreader
class Error < StandardError; end

class << self
attr_accessor :logger, :redis

def redis=(redis_instance)
@redis = redis_instance
TrackBallast.redis = redis_instance
@redis
end

# @!visibility private
def const_missing(const_name)
super unless const_name == :StopSignal

warn "DEPRECATION WARNING: the class SuperSpreader::StopSignal is deprecated. " \
"Use TrackBallast::StopSignal instead."
TrackBallast::StopSignal
end
end
end
4 changes: 2 additions & 2 deletions lib/super_spreader/scheduler_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
require "json"
require "super_spreader/scheduler_config"
require "super_spreader/spreader"
require "super_spreader/stop_signal"
require "track_ballast/stop_signal"

module SuperSpreader
class SchedulerJob < ActiveJob::Base
extend StopSignal
extend TrackBallast::StopSignal

def perform
return if self.class.stopped?
Expand Down
35 changes: 0 additions & 35 deletions lib/super_spreader/stop_signal.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/super_spreader/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SuperSpreader
VERSION = "0.2.1"
VERSION = "1.0.0.beta"
end
32 changes: 0 additions & 32 deletions spec/stop_signal_spec.rb

This file was deleted.

4 changes: 4 additions & 0 deletions spec/super_spreader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
it "has a version number" do
expect(SuperSpreader::VERSION).not_to be nil
end

it "allows referencing StopSignal while transitioning to TrackBallast::StopSignal" do
expect(SuperSpreader::StopSignal).to be TrackBallast::StopSignal
end
end
4 changes: 3 additions & 1 deletion spec/support/example_backfill_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "track_ballast/stop_signal"

# This class is an example job that uses the interface that SuperSpreader
# expects. While this job is for backfilling as an example, any problem
# that can be subdivided into small batches can be implemented.
Expand All @@ -9,7 +11,7 @@
class ExampleBackfillJob < ActiveJob::Base
# This provides support for stopping the job in an emergency. Optional, but
# highly recommended.
extend SuperSpreader::StopSignal
extend TrackBallast::StopSignal

# This is the model class that will be used when tracking the spread of jobs.
# It is expected to be an ActiveRecord class.
Expand Down
1 change: 1 addition & 0 deletions super_spreader.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "activerecord", ">= 6.1", "< 8.0"
spec.add_dependency "activesupport", ">= 6.1", "< 8.0"
spec.add_dependency "redis", ">= 4.8", "< 6.0"
spec.add_dependency "track_ballast", ">= 0.2.0.beta1"
spec.add_development_dependency "bundler"
spec.add_development_dependency "factory_bot"
spec.add_development_dependency "guard"
Expand Down