Skip to content

Commit

Permalink
use current rubies and fix some keyword arguments
Browse files Browse the repository at this point in the history
Ruby 3.0 keyword arg fixes

remove direct dependency on fastly/nsq-ruby

use nsq-ruby-fastly
  • Loading branch information
leklund committed Feb 23, 2022
1 parent ca9a1aa commit 568af94
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.3
3.0.3
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ language: ruby
cache: bundler
sudo: false
rvm:
- 2.5.1
- 2.7.3
- 2.6.9
- 2.7.5
- 3.0.3
script:
- bundle exec rake
services:
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ gem "rake"
gem "rdoc"
gem "standard"
gem "rubygems-tasks", "~> 0.2"
gem "nsq-ruby", github: "fastly/nsq-ruby", tag: "v2.4.0"
2 changes: 1 addition & 1 deletion fastly_nsq.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "yard"

gem.add_dependency "concurrent-ruby", "~> 1.0"
gem.add_dependency "nsq-ruby", "~> 2.3"
gem.add_dependency "nsq-ruby-fastly", "~> 2.4"
gem.add_dependency "priority_queue_cxx", "~> 0.3"
end
2 changes: 1 addition & 1 deletion lib/fastly_nsq/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def run
private

def launcher
@launcher ||= FastlyNsq::Launcher.new(options)
@launcher ||= FastlyNsq::Launcher.new(**options)
end

def read_loop
Expand Down
10 changes: 5 additions & 5 deletions lib/fastly_nsq/launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def manager
FastlyNsq.manager
end

def initialize(timeout: 5, pulse: 5, logger: FastlyNsq.logger, **options)
def initialize(**options)
@done = false
@timeout = timeout
@pulse = pulse
@logger = logger
@timeout = options[:timeout] || 5
@pulse = options[:pulse] || 5
@logger = options[:logger] || FastlyNsq.logger

FastlyNsq.manager = FastlyNsq::Manager.new(options)
FastlyNsq.manager = FastlyNsq::Manager.new(**options)
FastlyNsq.fire_event :startup
end

Expand Down
13 changes: 7 additions & 6 deletions lib/fastly_nsq/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ class FastlyNsq::Manager
##
# Create a FastlyNsq::Manager
#
# @param logger [Logger]
# @param max_threads [Integer] Maxiumum number of threads to be used by {FastlyNsq::PriorityThreadPool}
# @param pool_options [Hash] Options forwarded to {FastlyNsq::PriorityThreadPool} constructor.
def initialize(logger: FastlyNsq.logger, max_threads: FastlyNsq.max_processing_pool_threads, **pool_options)
# @param opts [Hash] Set of options passed to FastlyNsqw::PriorityThreadPool. valid options include:
# * max_threads [Integer] Maxiumum number of threads to be used by {FastlyNsq::PriorityThreadPool}
# * logger [Logger]
def initialize(**opts) # logger: FastlyNsq.logger, max_threads: FastlyNsq.max_processing_pool_threads)
@done = false
@logger = logger
@logger = opts[:logger] || FastlyNsq.logger
max_threads = opts[:max_threads] || FastlyNsq.max_processing_pool_threads
@pool = FastlyNsq::PriorityThreadPool.new(
{fallback_policy: :caller_runs, max_threads: max_threads}.merge(pool_options)
{fallback_policy: :caller_runs, max_threads: max_threads}.merge(opts)
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/fastly_nsq/new_relic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def notice_error(exception)
# @see {https://www.rubydoc.info/github/newrelic/rpm/NewRelic%2FAgent%2FInstrumentation%2FControllerInstrumentation:perform_action_with_newrelic_trace}
def trace_with_newrelic(**args)
if enabled?
perform_action_with_newrelic_trace(trace_args(args)) do
perform_action_with_newrelic_trace(trace_args(**args)) do
yield
end
else
Expand Down
2 changes: 1 addition & 1 deletion spec/launcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let!(:options) { {max_threads: 3, timeout: 9} }
let!(:topic) { "fnsq" }

let(:launcher) { FastlyNsq::Launcher.new options }
let(:launcher) { FastlyNsq::Launcher.new(**options) }
let(:listener) { FastlyNsq::Listener.new(topic: topic, channel: channel, processor: ->(*) {}) }
let(:manager) { launcher.manager }

Expand Down

0 comments on commit 568af94

Please sign in to comment.