diff --git a/.ruby-version b/.ruby-version index 2c9b4ef..75a22a2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.3 +3.0.3 diff --git a/.travis.yml b/.travis.yml index 0cea3b9..fcc6439 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/Gemfile b/Gemfile index 08904a8..1ef9408 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/fastly_nsq.gemspec b/fastly_nsq.gemspec index 3a0727c..552cff2 100644 --- a/fastly_nsq.gemspec +++ b/fastly_nsq.gemspec @@ -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 diff --git a/lib/fastly_nsq/cli.rb b/lib/fastly_nsq/cli.rb index 9beaa82..3e24047 100644 --- a/lib/fastly_nsq/cli.rb +++ b/lib/fastly_nsq/cli.rb @@ -54,7 +54,7 @@ def run private def launcher - @launcher ||= FastlyNsq::Launcher.new(options) + @launcher ||= FastlyNsq::Launcher.new(**options) end def read_loop diff --git a/lib/fastly_nsq/launcher.rb b/lib/fastly_nsq/launcher.rb index e432c0f..3f82824 100644 --- a/lib/fastly_nsq/launcher.rb +++ b/lib/fastly_nsq/launcher.rb @@ -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 diff --git a/lib/fastly_nsq/manager.rb b/lib/fastly_nsq/manager.rb index a16aea1..6b3d893 100644 --- a/lib/fastly_nsq/manager.rb +++ b/lib/fastly_nsq/manager.rb @@ -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 diff --git a/lib/fastly_nsq/new_relic.rb b/lib/fastly_nsq/new_relic.rb index dc06ea0..fc6db95 100644 --- a/lib/fastly_nsq/new_relic.rb +++ b/lib/fastly_nsq/new_relic.rb @@ -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 diff --git a/spec/launcher_spec.rb b/spec/launcher_spec.rb index 84d8e86..c206f42 100644 --- a/spec/launcher_spec.rb +++ b/spec/launcher_spec.rb @@ -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 }