Skip to content
Closed
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
30 changes: 30 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Tests
on: push

jobs:
test:
strategy:
matrix:
ruby_version: ['3.2', '3.3', '3.4', '4.0']
runs-on: ubuntu-24.04
steps:
- name: Install NSQ
shell: bash
run: |
wget https://github.com/nsqio/nsq/releases/download/v1.3.0/nsq-1.3.0.linux-amd64.go1.21.5.tar.gz
tar xvzf nsq-1.3.0.linux-amd64.go1.21.5.tar.gz
mv nsq-1.3.0.linux-amd64.go1.21.5/bin/* /usr/local/bin

- name: Check out Git repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- uses: ruby/setup-ruby@0cb964fd540e0a24c900370abf38a33466142735 # v1.305.0
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Run tests
shell: bash
run: |
echo "path: $PATH"
bundle exec rspec spec
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 2.7.6
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 2.4.1

* Client version connection string should also read from the VERSION file

## 2.4.0

* Remove jeweler gem in favor of using a dynamic gemspec [#66](https://github.com/wistia/nsq-ruby/pull/66)
* Use `URI.encode_www_form_component` instead of `URI.escape` to ensure compatibility with Ruby 3.0+ and fix deprecation warnings in Ruby 2.7. [#65](https://github.com/wistia/nsq-ruby/pull/65)
* Update version of `nsq-cluster` used for tests [#66](https://github.com/wistia/nsq-ruby/pull/66)
* Update TLS certificates used for tests [#66](https://github.com/wistia/nsq-ruby/pull/66)
* GitHub Actions workflow for testing the gem against a matrix of Ruby versions (2.7, 3.0, 3.1, 3.2) introduced [#66](https://github.com/wistia/nsq-ruby/pull/66)
* Support specifying multiple nsqd's when creating a consumer. [#54](https://github.com/wistia/nsq-ruby/pull/54)

## 2.3.1

* Fix `max_attempts` bug (#46)
Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'http://rubygems.org'

gem 'logger', '~> 1.6'

group :development do
gem 'bundler', '~> 1.0'
gem 'jeweler', '~> 2.0'
gem 'nsq-cluster', '~> 2.1'
gem 'rspec', '~> 3.0'
gem 'nsq-cluster', '~> 2.2'
gem 'rspec', '~> 3.10'
end
93 changes: 22 additions & 71 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,83 +1,34 @@
GEM
remote: http://rubygems.org/
specs:
addressable (2.4.0)
builder (3.2.3)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.3)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.11.1)
git (1.3.0)
github_api (0.16.0)
addressable (~> 2.4.0)
descendants_tracker (~> 0.0.4)
faraday (~> 0.8, < 0.10)
hashie (>= 3.4)
mime-types (>= 1.16, < 3.0)
oauth2 (~> 1.0)
hashie (3.5.7)
highline (1.7.10)
jeweler (2.3.9)
builder
bundler
git (>= 1.2.5)
github_api (~> 0.16.0)
highline (>= 1.6.15)
nokogiri (>= 1.5.10)
psych
rake
rdoc
semver2
jwt (1.5.6)
mime-types (2.99.3)
mini_portile2 (2.4.0)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
nsq-cluster (2.1.0)
sys-proctable
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
psych (3.0.2)
rack (2.0.7)
rake (12.3.0)
rdoc (6.0.1)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
diff-lcs (1.6.2)
ffi (1.17.4)
logger (1.7.0)
nsq-cluster (2.2.0)
sys-proctable (~> 1.3)
rspec (3.13.2)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.6)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.8)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
semver2 (3.4.2)
sys-proctable (1.1.3-universal-darwin)
ffi
thread_safe (0.3.6)
rspec-support (~> 3.13.0)
rspec-support (3.13.7)
sys-proctable (1.3.0)
ffi (~> 1.1)

PLATFORMS
ruby
x86_64-darwin-16
x86_64-darwin-17

DEPENDENCIES
bundler (~> 1.0)
jeweler (~> 2.0)
nsq-cluster (~> 2.1)
rspec (~> 3.0)
logger (~> 1.6)
nsq-cluster (~> 2.2)
rspec (~> 3.10)

BUNDLED WITH
1.16.1
2.6.3
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ nsq-ruby is a simple NSQ client library written in Ruby.
```Ruby
require 'nsq'
producer = Nsq::Producer.new(
nsqd: '127.0.0.1:4150',
nsqd: '127.0.0.1:4150', # or ['127.0.0.1:4150']
topic: 'some-topic'
)

Expand Down Expand Up @@ -77,7 +77,7 @@ For example, if you'd like to publish messages to a single nsqd.

```Ruby
producer = Nsq::Producer.new(
nsqd: '6.7.8.9:4150',
nsqd: '6.7.8.9:4150', # or ['6.7.8.9:4150']
topic: 'topic-of-great-esteem'
)
```
Expand Down Expand Up @@ -418,4 +418,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

20 changes: 0 additions & 20 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@ end

require 'rake'

###########
# Jeweler #
###########
require 'jeweler'
require_relative 'lib/version'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
gem.name = "nsq-ruby"
gem.version = Nsq::Version::STRING
gem.homepage = "http://github.com/wistia/nsq-ruby"
gem.license = "MIT"
gem.summary = %Q{Ruby client library for NSQ}
gem.description = %Q{}
gem.email = "dev@wistia.com"
gem.authors = ["Wistia"]
gem.files = Dir.glob('lib/**/*.rb') + ['README.md']
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new

#########
# Rspec #
#########
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.5.0
18 changes: 18 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# this is a catalog entity descriptor file for our Backstage instance (https://backstage.wistia.cloud)

apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: nsq-ruby
description: A worker framework for processing messages from an NSQ topic and channel.
annotations:
github.com/project-slug: wistia/nsq-ruby
backstage.io/techdocs-ref: dir:.
tags:
- lang#ruby
- pkg#rubygem
spec:
type: library
owner: infrastructure
lifecycle: production
system: VMA
10 changes: 7 additions & 3 deletions lib/nsq/consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ def initialize(opts = {})
topic: @topic,
interval: @discovery_interval
)

elsif opts[:nsqd]
nsqds = [opts[:nsqd]].flatten
max_per_conn = max_in_flight_per_connection(nsqds.size)
nsqds.each{|d| add_connection(d, max_in_flight: max_per_conn)}

else
# normally, we find nsqd instances to connect to via nsqlookupd(s)
# in this case let's connect to an nsqd instance directly
add_connection(opts[:nsqd] || '127.0.0.1:4150', max_in_flight: @max_in_flight)
add_connection('127.0.0.1:4150', max_in_flight: @max_in_flight)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nsq/discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_nsqds(lookupd, topic = nil)
uri.query = "ts=#{Time.now.to_i}"
if topic
uri.path = '/lookup'
uri.query += "&topic=#{URI.escape(topic)}"
uri.query += "&topic=#{URI.encode_www_form_component(topic)}"
else
uri.path = '/nodes'
end
Expand Down
6 changes: 1 addition & 5 deletions lib/version.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module Nsq
module Version
MAJOR = 2
MINOR = 3
PATCH = 1
BUILD = nil
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
STRING = File.read(File.expand_path('../../VERSION', __FILE__)).strip
end
end
10 changes: 10 additions & 0 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# this file exists to generate techdocs for Backstage (https://backstage.wistia.cloud)

site_name: nsq-ruby
docs_dir: .
plugins:
- techdocs-core
- same-dir
- exclude:
glob:
- node_modules/*
48 changes: 5 additions & 43 deletions nsq-ruby.gemspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: nsq-ruby 2.3.1 ruby lib

Gem::Specification.new do |s|
s.name = "nsq-ruby".freeze
s.version = "2.3.1"
s.version = File.read('VERSION')

s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
Expand All @@ -18,46 +12,14 @@ Gem::Specification.new do |s|
"LICENSE.txt",
"README.md"
]
s.files = [
"README.md",
"lib/nsq.rb",
"lib/nsq/client_base.rb",
"lib/nsq/connection.rb",
"lib/nsq/consumer.rb",
"lib/nsq/discovery.rb",
"lib/nsq/exceptions.rb",
"lib/nsq/frames/error.rb",
"lib/nsq/frames/frame.rb",
"lib/nsq/frames/message.rb",
"lib/nsq/frames/response.rb",
"lib/nsq/logger.rb",
"lib/nsq/producer.rb",
"lib/version.rb"
]
s.files = Dir.glob('lib/**/*.rb') + ['README.md', 'VERSION']
s.homepage = "http://github.com/wistia/nsq-ruby".freeze
s.licenses = ["MIT".freeze]
s.rubygems_version = "2.6.8".freeze
s.summary = "Ruby client library for NSQ".freeze

if s.respond_to? :specification_version then
s.specification_version = 4
s.add_dependency(%q<logger>.freeze)

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.0"])
s.add_development_dependency(%q<nsq-cluster>.freeze, ["~> 2.1"])
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
else
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
s.add_dependency(%q<jeweler>.freeze, ["~> 2.0"])
s.add_dependency(%q<nsq-cluster>.freeze, ["~> 2.1"])
s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
end
else
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
s.add_dependency(%q<jeweler>.freeze, ["~> 2.0"])
s.add_dependency(%q<nsq-cluster>.freeze, ["~> 2.1"])
s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
end
s.add_development_dependency(%q<nsq-cluster>.freeze, ["~> 2.1"])
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
end

2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def new_consumer(opts = {})
def new_producer(nsqd, opts = {})
Nsq::Producer.new({
topic: TOPIC,
nsqd: "#{nsqd.host}:#{nsqd.tcp_port}",
nsqd: ["#{nsqd.host}:#{nsqd.tcp_port}"],
discovery_interval: 1
}.merge(opts))
end
Expand Down
Loading