Skip to content

Commit

Permalink
depend on beaneater 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjohns committed Apr 29, 2015
1 parent 6818bc4 commit 192a753
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 52 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ authenticate :admin_user do
end
```

Breaking changes since 2.0.0!
------------------------

As of version 2.0.0, beanstalkd_view no longer supports connection to multiple beanstalkd
servers due to a decision to drop connection pool support in the beaneater gem.

Troubleshooting
------------------------
1. CSS/JS assets not being served in Rails when running behind Apache or Nginx
Expand Down Expand Up @@ -130,10 +136,9 @@ from the command line after modifying any javascript or css files. The output f

Running the tests
------------------------
There are 3 variants of RSpec tests.
There are 2 variants of RSpec tests.
* Without beanstalkd running, just execute: rspec spec
* With 1 instance of beanstalkd running (default port), execute: rspec spec --tag requires_beanstalkd
* With 2 instances of beanstalkd running (ports 11300 and 11400), execute: rspec spec --tag requires_two_beanstalkd
* With beanstalkd running (default port), execute: rspec spec --tag requires_beanstalkd

Customization
------------------------
Expand Down
2 changes: 1 addition & 1 deletion beanstalkd_view.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |s|

s.add_dependency "sinatra", ">= 1.3.0"
s.add_dependency "sinatra-contrib", ">= 1.3.0"
s.add_dependency "beaneater", "~> 0.3.0"
s.add_dependency "beaneater", "~> 1.0.0"
s.add_dependency "vegas", "~> 0.1.2"
s.add_dependency "json"

Expand Down
6 changes: 3 additions & 3 deletions lib/beanstalkd_view/beanstalkd_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ module BeanstalkdUtils
class BadURL < RuntimeError; end

def beanstalk
@@beanstalk ||= Beaneater::Pool.new(beanstalk_addresses)
@@beanstalk ||= Beaneater.new(beanstalk_address)
end

def beanstalk_url
return @@url if defined?(@@url) and @@url
ENV['BEANSTALK_URL'] || 'beanstalk://127.0.0.1/'
end

def beanstalk_addresses
def beanstalk_address
uris = beanstalk_url.split(/[\s,]+/)
uris.map {|uri| beanstalk_host_and_port(uri)}
beanstalk_host_and_port(uris.first)
end

def beanstalk_host_and_port(uri_string)
Expand Down
2 changes: 1 addition & 1 deletion lib/beanstalkd_view/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Server < Sinatra::Base

get "/" do
begin
@connections = beanstalk.connections
@connection = beanstalk.connection
@tubes = beanstalk.tubes.all
@tubes = @tubes.sort_by{|obj| obj.name }
@stats = beanstalk.stats
Expand Down
10 changes: 4 additions & 6 deletions lib/beanstalkd_view/views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
<table class="table">
<thead>
<tr>
<th>Connections</th>
<th>Connection</th>
</tr>
</thead>
<tbody>
<% @connections.each do |connection| %>
<tr>
<td><%= connection.address %></td>
</tr>
<% end %>
<tr>
<td><%= @connection.address %></td>
</tr>
</tbody>
</table>

Expand Down
10 changes: 5 additions & 5 deletions spec/lib/beanstalkd_view/beanstalkd_util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
utils = Object.new.extend BeanstalkdView::BeanstalkdUtils

ENV['BEANSTALK_URL'] = "beanstalk://localhost:12300"
utils.beanstalk_addresses.should eq(["localhost:12300"])
utils.beanstalk_address.should eq("localhost:12300")

ENV['BEANSTALK_URL'] = "beanstalk://localhost:12300/, beanstalk://localhost:12301/"
utils.beanstalk_addresses.should eq(["localhost:12300","localhost:12301"])
utils.beanstalk_address.should eq("localhost:12300")

ENV['BEANSTALK_URL'] = "beanstalk://localhost:12300 beanstalk://localhost:12301"
utils.beanstalk_addresses.should eq(["localhost:12300","localhost:12301"])
utils.beanstalk_address.should eq("localhost:12300")

expect {
ENV['BEANSTALK_URL'] = "beanstalk://localhost:12300, http://localhost:12301"
utils.beanstalk_addresses
ENV['BEANSTALK_URL'] = "http://localhost:12301"
utils.beanstalk_address
}.should raise_error(BeanstalkdView::BeanstalkdUtils::BadURL)
end

Expand Down
16 changes: 4 additions & 12 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@

RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run_excluding :requires_beanstalkd, :requires_two_beanstalkd
config.filter_run_excluding :requires_beanstalkd

config.before(:each) do
requires_two_beanstalkd = example.options[:requires_two_beanstalkd]
if requires_two_beanstalkd
ENV['BEANSTALK_URL'] = 'beanstalk://localhost:11300,beanstalk://localhost:11400'
else
ENV['BEANSTALK_URL'] = 'beanstalk://localhost:11300'
end
end
config.before(:each) do
ENV['BEANSTALK_URL'] = 'beanstalk://localhost:11300'
end
end



21 changes: 0 additions & 21 deletions spec/support/integration_test_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,4 @@

end

describe "with two beanstalkd daemons running", :requires_two_beanstalkd => true do
before :all do
# Make sure beanstalkd is running
if `pgrep beanstalkd` == ""
raise "PRECONDITION NOT MET: beanstalkd not running"
end
end

it "should show the overview at: /", :requires_two_beanstalkd => true do
visit site_root
page.should have_content "Beanstalkd View"
page.should have_content "Statistics"
page.should have_content "Tubes"
end

it_behaves_like "queue_browser", :requires_two_beanstalkd => true do
let(:tube_name) { 'test.two' }
end

end

end

0 comments on commit 192a753

Please sign in to comment.