Skip to content
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
41 changes: 0 additions & 41 deletions .autotest

This file was deleted.

1 change: 0 additions & 1 deletion .gemtest

This file was deleted.

7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ doc/
coverage/
coverage.info
kestrel/
*.gemspec
Gemfile*
tags
*.swp
# artifact of testing with redis
*.rdb
Gemfile.lock
1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: ruby
rvm:
- "1.9.2"
- "1.9.3"
- "2.0.0"
- "2.1.0"
- jruby-18mode # JRuby in 1.8 mode
- "2.1.5"
- "2.2.0"
- jruby-19mode # JRuby in 1.9 mode
- rbx
install: rake develop
services:
- redis-server
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ easiest way to contribute.
* **Bug reports** please be as detailed as possible. Include:
* full ruby engine and version: `ruby -e 'puts RUBY_DESCRIPTION'`
* operating system and version
* version of fixme `ruby -rubygems -e "require 'fixme'; puts Fixme::VERSION"`
* version of qup `ruby -rubygems -e "require 'qup'; puts Qup::VERSION"`
* as much detail about the bug as possible so I can replicate it. Feel free
to link in a [gist][]
* **New Feature**
Expand All @@ -39,8 +39,8 @@ easiest way to contribute.
* [Kevin Barnes](https://github.com/vinbarnes)

[GitHub Account]: https://github.com/signup/free "GitHub Signup"
[GitHub Issues]: https://github.com/copiousfreetime/fixme/issues "Fixme Issues"
[new issue]: https://github.com/copiousfreetime/fixme/issues/new "New Fixme Issue"
[GitHub Issues]: https://github.com/copiousfreetime/qup/issues "Qup Issues"
[new issue]: https://github.com/copiousfreetime/qup/issues/new "New Qup Issue"
[gist]: https://gist.github.com/ "New Gist"
[repo]: https://github.com/copiousfreetime/fixme "Fixme Repo"
[repo]: https://github.com/copiousfreetime/qup "Qup Repo"
[pull request]: https://help.github.com/articles/using-pull-requests "Using Pull Requests"
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source "https://rubygems.org/"
gemspec
12 changes: 8 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ This.homepage = "http://github.com/copiousfreetime/#{ This.name }"

This.ruby_gemspec do |spec|
# The Runtime Dependencies
# FIXME: when jruby has a 2.0 mode update this to 2.2 In the meantime
# there is no real update to maildir other than a new requirement for ruby 2.0
spec.add_runtime_dependency( 'maildir', '~> 2.1.0' )

# Additional functionality if used
spec.add_development_dependency( 'kjess' , '~> 1.2' )
# FIXME: remove completely at some point
# spec.add_development_dependency( 'kjess' , '~> 1.2' )
spec.add_development_dependency( 'redis' , '~> 3.0' )

# The Development Dependencies
spec.add_development_dependency( 'rake' , '~> 10.1.0' )
spec.add_development_dependency( 'rspec' , '~> 2.14.0' )
spec.add_development_dependency( 'rdoc' , '~> 4.0' )
spec.add_development_dependency( 'simplecov' , '~> 0.9' )
spec.add_development_dependency( 'rake' , '~> 10.4')
spec.add_development_dependency( 'rspec' , '~> 3.2' )
spec.add_development_dependency( 'rdoc' , '~> 4.0' )

end

Expand Down
9 changes: 6 additions & 3 deletions lib/qup/adapter/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Redis < ::Qup::Adapter
def initialize( uri, options = {} )
@uri = uri
@options = options
@client = ::Redis.new host: @uri.host, port: @uri.port
@client.ping
@closed = false
end

Expand All @@ -24,7 +26,7 @@ def initialize( uri, options = {} )
#
# Returns a Qup::Queue
def queue( name )
Qup::Adapter::Redis::Queue.new( @uri, name )
Qup::Adapter::Redis::Queue.new( @client, name )
end

# Internal: Create a new Topic from this Adapter
Expand All @@ -33,21 +35,22 @@ def queue( name )
#
# Returns a Qup::Topic
def topic( name )
Qup::Adapter::Redis::Topic.new( @uri, name )
Qup::Adapter::Redis::Topic.new( @client, name )
end

# Internal: Close the Redis adapter
#
# Return nothing
def close
@client.disconnect!
@closed = true
end

# Internal: Is the Redis Adapter closed
#
# Returns true or false
def closed?
@closed
not @client.connected?
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Qup::Adapter::Redis
#
# Internal: The Common base class for Redis Topic and Queue
#
class Connection
class Destination

# Public: the name of the Queue or Topic
attr_reader :name
Expand All @@ -13,19 +13,18 @@ class Connection
# name - the String name of the Connection
#
# Returns a new Connection.
def initialize( uri, name )
@uri = uri
@client = Redis.new :host => @uri.host, :port => @uri.port
def initialize( client, name )
@client = client
@name = name
ping
end

# Public: destroy the connection
# Internal: Make sure the Topic or Queue exists
#
# Closes the redis client connection.
#
# Returns nothing.
def destroy
@client.client.disconnect
# Returns nothing
def ping
@client.ping
return true
end

end
Expand Down
10 changes: 5 additions & 5 deletions lib/qup/adapter/redis/queue.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
require 'qup/adapter/redis/connection'
require 'qup/adapter/redis/destination'

class Qup::Adapter::Redis
#
# Internal: The Qup implementation for a Redis Queue
#
class Queue < Connection
class Queue < Destination
include Qup::QueueAPI

# Internal: create a new Queue
#
# uri - the connection uri for the Redis Client
# client - the Redis client
# name - the String name of the Queue
# topic_name - (optional) the String name of a parent topic
#
# Returns a new Queue.
def initialize( uri, name, topic_name = nil )
super uri, name
def initialize( client, name, topic_name = nil )
super( client, name )
@topic_name = topic_name
@open_messages = {}
end
Expand Down
8 changes: 4 additions & 4 deletions lib/qup/adapter/redis/topic.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'qup/adapter/redis/connection'
require 'qup/adapter/redis/destination'

class Qup::Adapter::Redis
#
Expand All @@ -8,7 +8,7 @@ class Qup::Adapter::Redis
# rather it guarantees durability of all published messages by using
# sub-queues internally to deliver messages to subscribers.
#
class Topic < Connection
class Topic < Destination
include Qup::TopicAPI

# Internal: Creates a Publisher for the Topic
Expand All @@ -29,7 +29,7 @@ def publisher
def subscriber(name)
subscriber_name = "#{@name}.#{name}"
@client.sadd @name, subscriber_name
queue = ::Qup::Adapter::Redis::Queue.new(@uri, subscriber_name, @name)
queue = ::Qup::Adapter::Redis::Queue.new(@client, subscriber_name, @name)
::Qup::Subscriber.new( self, queue )
end

Expand Down Expand Up @@ -77,7 +77,7 @@ def subscriber_names
def subscribers
subs = {}
subscriber_names.each do |sname|
subs[sname] = ::Qup::Adapter::Redis::Queue.new(@uri, sname, @name)
subs[sname] = ::Qup::Adapter::Redis::Queue.new(@client, sname, @name)
end
return subs
end
Expand Down
52 changes: 52 additions & 0 deletions qup.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# DO NOT EDIT - This file is automatically generated
# Make changes to Manifest.txt and/or Rakefile and regenerate
# -*- encoding: utf-8 -*-
# stub: qup 1.4.2 ruby lib

Gem::Specification.new do |s|
s.name = "qup"
s.version = "1.4.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Jeremy Hinegardner"]
s.date = "2015-02-18"
s.description = "Qup is a generalized API for Message Queue and Publish/Subscribe messaging patterns with the ability to plug in an appropriate messaging infrastructure based upon your needs. Qup ships with support for (https://github.com/robey/kestrel), (http://redis.io), and a filesystem infrastructure based on (https://rubygems.org/gems/maildir). Additional Adapters will be developed as needs arise. (https://github.com/copiousfreetime/qup/issues) to have a new Adapter created. Pull requests gladly accepted."
s.email = "jeremy@copiousfreetime.org"
s.extra_rdoc_files = ["ADAPTER_API.md", "CONTRIBUTING.md", "HISTORY.md", "Manifest.txt", "README.md"]
s.files = [".autotest", ".gemtest", "ADAPTER_API.md", "CONTRIBUTING.md", "HISTORY.md", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "lib/qup.rb", "lib/qup/adapter.rb", "lib/qup/adapter/kestrel.rb", "lib/qup/adapter/kestrel/destination.rb", "lib/qup/adapter/kestrel/queue.rb", "lib/qup/adapter/kestrel/topic.rb", "lib/qup/adapter/maildir.rb", "lib/qup/adapter/maildir/queue.rb", "lib/qup/adapter/maildir/topic.rb", "lib/qup/adapter/redis.rb", "lib/qup/adapter/redis/connection.rb", "lib/qup/adapter/redis/queue.rb", "lib/qup/adapter/redis/topic.rb", "lib/qup/backoff_sleeper.rb", "lib/qup/batch_consumer.rb", "lib/qup/consumer.rb", "lib/qup/message.rb", "lib/qup/producer.rb", "lib/qup/publisher.rb", "lib/qup/queue_api.rb", "lib/qup/session.rb", "lib/qup/subscriber.rb", "lib/qup/topic_api.rb", "spec/qup/adapter/kestrel/queue_spec.rb", "spec/qup/adapter/kestrel/topic_spec.rb", "spec/qup/adapter/kestrel_context.rb", "spec/qup/adapter/kestrel_spec.rb", "spec/qup/adapter/maildir/queue_spec.rb", "spec/qup/adapter/maildir/topic_spec.rb", "spec/qup/adapter/maildir_context.rb", "spec/qup/adapter/maildir_spec.rb", "spec/qup/adapter/redis/queue_spec.rb", "spec/qup/adapter/redis/topic_spec.rb", "spec/qup/adapter/redis_context.rb", "spec/qup/adapter/redis_spec.rb", "spec/qup/adapter_spec.rb", "spec/qup/backoff_sleeper_sleeper_spec.rb", "spec/qup/batch_consumer_spec.rb", "spec/qup/consumer_spec.rb", "spec/qup/message_spec.rb", "spec/qup/producer_spec.rb", "spec/qup/queue_api_spec.rb", "spec/qup/session_spec.rb", "spec/qup/shared_adapter_examples.rb", "spec/qup/shared_queue_examples.rb", "spec/qup/shared_topic_examples.rb", "spec/qup/topic_api_spec.rb", "spec/qup_spec.rb", "spec/spec_helper.rb", "tasks/default.rake", "tasks/this.rb"]
s.homepage = "http://github.com/copiousfreetime/qup"
s.licenses = ["ISC"]
s.rdoc_options = ["--main", "README.md", "--markup", "tomdoc"]
s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
s.rubygems_version = "2.4.6"
s.summary = "Qup is a generalized API for Message Queue and Publish/Subscribe messaging patterns with the ability to plug in an appropriate messaging infrastructure based upon your needs."
s.test_files = ["spec/qup/adapter/kestrel/queue_spec.rb", "spec/qup/adapter/kestrel/topic_spec.rb", "spec/qup/adapter/kestrel_context.rb", "spec/qup/adapter/kestrel_spec.rb", "spec/qup/adapter/maildir/queue_spec.rb", "spec/qup/adapter/maildir/topic_spec.rb", "spec/qup/adapter/maildir_context.rb", "spec/qup/adapter/maildir_spec.rb", "spec/qup/adapter/redis/queue_spec.rb", "spec/qup/adapter/redis/topic_spec.rb", "spec/qup/adapter/redis_context.rb", "spec/qup/adapter/redis_spec.rb", "spec/qup/adapter_spec.rb", "spec/qup/backoff_sleeper_sleeper_spec.rb", "spec/qup/batch_consumer_spec.rb", "spec/qup/consumer_spec.rb", "spec/qup/message_spec.rb", "spec/qup/producer_spec.rb", "spec/qup/queue_api_spec.rb", "spec/qup/session_spec.rb", "spec/qup/shared_adapter_examples.rb", "spec/qup/shared_queue_examples.rb", "spec/qup/shared_topic_examples.rb", "spec/qup/topic_api_spec.rb", "spec/qup_spec.rb", "spec/spec_helper.rb"]

if s.respond_to? :specification_version then
s.specification_version = 4

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<maildir>, ["~> 2.1.0"])
s.add_development_dependency(%q<redis>, ["~> 3.0"])
s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
s.add_development_dependency(%q<rake>, ["~> 10.4"])
s.add_development_dependency(%q<rspec>, ["~> 3.2"])
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
else
s.add_dependency(%q<maildir>, ["~> 2.1.0"])
s.add_dependency(%q<redis>, ["~> 3.0"])
s.add_dependency(%q<simplecov>, ["~> 0.9"])
s.add_dependency(%q<rake>, ["~> 10.4"])
s.add_dependency(%q<rspec>, ["~> 3.2"])
s.add_dependency(%q<rdoc>, ["~> 4.0"])
end
else
s.add_dependency(%q<maildir>, ["~> 2.1.0"])
s.add_dependency(%q<redis>, ["~> 3.0"])
s.add_dependency(%q<simplecov>, ["~> 0.9"])
s.add_dependency(%q<rake>, ["~> 10.4"])
s.add_dependency(%q<rspec>, ["~> 3.2"])
s.add_dependency(%q<rdoc>, ["~> 4.0"])
end
end
6 changes: 3 additions & 3 deletions spec/qup/adapter/redis/queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

context "when initialized with a parent topic's name" do
let(:redis) { Redis.new :host => uri.host, :port => uri.port }
let(:queue) { Qup::Adapter::Redis::Queue.new(uri, "test", "parent") }
let(:queue) { Qup::Adapter::Redis::Queue.new(redis, "test", "parent") }

before do
redis.del "parent"
Expand All @@ -23,9 +23,9 @@

describe "#destroy" do
it "removes its name from the parent topic's subscriber set" do
redis.smembers("parent").should be == ["test"]
expect( redis.smembers("parent") ).to eq ["test"]
queue.destroy
redis.smembers("parent").should be == []
expect( redis.smembers("parent") ).to eq []
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/qup/adapter/redis/topic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
end

it "unregisters itself from the Topic when unsubscribed" do
lambda do
expect {
subscriber.unsubscribe
end.should change(topic, :subscriber_count).by(-1)
}.to change(topic, :subscriber_count).by(-1)
end
end
end
10 changes: 7 additions & 3 deletions spec/qup/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Qup::AdapterTest < Qup::Adapter

describe 'Adapter Registration' do
it 'registers an adapter' do
Qup::Adapters['quptest'].should eq Qup::AdapterTest
expect( Qup::Adapters['quptest'] ).to eq Qup::AdapterTest
end
end

Expand All @@ -15,13 +15,17 @@ class Qup::AdapterTest < Qup::Adapter

%w[ close closed? ].each do |method|
it "##{method} kaboom!" do
lambda { api.send( method ) }.should raise_error( NotImplementedError, "please implement '#{method}'" )
expect {
api.send( method )
}.to raise_error( NotImplementedError, "please implement '#{method}'" )
end
end

%w[ queue topic ].each do |method|
it "##{method} kaboom!" do
lambda { api.send( method, 'foo' ) }.should raise_error( NotImplementedError, "please implement '#{method}'" )
expect {
api.send( method, 'foo' )
}.to raise_error( NotImplementedError, "please implement '#{method}'" )
end
end

Expand Down
Loading