From 4ac987119b2ea51a879ac383075ed90343cde406 Mon Sep 17 00:00:00 2001 From: Matt Sanford Date: Thu, 20 Dec 2012 16:38:57 -0800 Subject: [PATCH] Allow setting the host and port on a Statsd::Batch object --- lib/statsd.rb | 6 +++++- spec/statsd_spec.rb | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/statsd.rb b/lib/statsd.rb index 9f4987c..7db2bd6 100644 --- a/lib/statsd.rb +++ b/lib/statsd.rb @@ -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 diff --git a/spec/statsd_spec.rb b/spec/statsd_spec.rb index e8bb7ab..b136308 100644 --- a/spec/statsd_spec.rb +++ b/spec/statsd_spec.rb @@ -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