Skip to content

Commit

Permalink
Allow setting the host and port on a Statsd::Batch object
Browse files Browse the repository at this point in the history
  • Loading branch information
mzsanford committed Dec 21, 2012
1 parent 24fc9d0 commit 4ac9871
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/statsd.rb
Expand Up @@ -43,7 +43,11 @@ class Batch < Statsd

extend Forwardable
def_delegators :@statsd,
:namespace, :namespace=, :host, :port, :prefix, :postfix
:namespace, :namespace=,
:host, :host=,
:port, :port=,
:prefix,
:postfix

attr_accessor :batch_size

Expand Down
18 changes: 18 additions & 0 deletions spec/statsd_spec.rb
Expand Up @@ -321,6 +321,24 @@ class Statsd::SomeClass; end
@socket.recv.must_equal %w[foobar:1|c]
end

it "should support setting namespace for the underlying instance" do
batch = Statsd::Batch.new(@statsd)
batch.namespace = 'ns'
@statsd.namespace.must_equal 'ns'
end

it "should support setting host for the underlying instance" do
batch = Statsd::Batch.new(@statsd)
batch.host = '1.2.3.4'
@statsd.host.must_equal '1.2.3.4'
end

it "should support setting port for the underlying instance" do
batch = Statsd::Batch.new(@statsd)
batch.port = 42
@statsd.port.must_equal 42
end

end

describe "thread safety" do
Expand Down

0 comments on commit 4ac9871

Please sign in to comment.