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

Compatibility with que 1.0.0.beta3 config feature #1

Open
wants to merge 2 commits into
base: master
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ publishing using [Que](https://github.com/chanks/que) actors.
gem 'wisper-que'
```

## Configuration

Custom Queue Name

`config/initializers/wisper_que.rb`
```
WisperQue.configure do |c|
c.queue_name = 'wisper' # or 'default'
end
```

## Usage

```ruby
Expand All @@ -32,6 +43,12 @@ joe.subscribe(SomeJob, async: true)
joe.call
```

Run Que with custom queue name:
```bash
que -q wisper
```


## Contributing

Yes please, either submit a PR or open an issue first to discuss your thoughts.
6 changes: 4 additions & 2 deletions lib/wisper/que.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
require "wisper/que/version"
require "wisper/que/wisper_que"
require "que"
require "wisper"

module Wisper
class Que
def broadcast(subscriber, publisher, event, args)
Wrapper.enqueue(subscriber.name, event, args)

def broadcast(subscriber, _publisher, event, args)
Wrapper.enqueue(subscriber.name, event, args, queue: WisperQue.instance.queue_name)
end

class Wrapper < ::Que::Job
Expand Down
2 changes: 1 addition & 1 deletion lib/wisper/que/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Wisper
class Que
VERSION = "0.1.0"
VERSION = "0.2.0"
end
end
15 changes: 15 additions & 0 deletions lib/wisper/que/wisper_que.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'singleton'

class WisperQue
include Singleton

attr_accessor :queue_name

def initialize
@queue_name = Que.default_queue
end

def self.configure
yield self.instance
end
end
15 changes: 13 additions & 2 deletions spec/wisper/que_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
require 'spec_helper'
require 'uri'
require 'pg'
require 'connection_pool'

Que.connection = PG::Connection.open(ENV['DATABASE_URL'] || "postgres://localhost/wisper-que-test")
Que.mode = :sync
uri = URI.parse(ENV['DATABASE_URL'] || "postgres://localhost/wisper-que-test")

Que.connection = ConnectionPool.new(size: 1) do
PG::Connection.open(
host: uri.host,
user: uri.user,
password: uri.password,
port: uri.port || 5432,
dbname: uri.path[1..-1]
)
end

describe Wisper::Que do
it 'has a version number' do
Expand Down
5 changes: 3 additions & 2 deletions wisper-que.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "que", "~> 0.11"
spec.add_dependency "wisper", "~> 1.0"
spec.add_dependency "que", "~> 1.0.0.beta"
spec.add_dependency "wisper", "~> 2.0"

spec.add_development_dependency "bundler", "~> 1.8"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "pg", ">= 0"
spec.add_development_dependency "connection_pool", ">= 0"
end