Commit 644638b8 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

Merge pull request #121 from bulletproofnetworks/configure-worker

Configure worker
parents ee868462 9a8beeb8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
class FnordMetric::Worker

  def initialize
  def initialize(opts = {})
    @namespaces = FnordMetric.namespaces
    @opts = FnordMetric.options
    @opts = FnordMetric.options(opts)

    FnordMetric.register(self)
  end
+18 −12
Original line number Diff line number Diff line
@@ -2,24 +2,30 @@ require ::File.expand_path('../spec_helper.rb', __FILE__)

describe FnordMetric::Worker do

  before(:each) do
    @worker = FnordMetric::Worker.new()
  end
  let(:worker) { FnordMetric::Worker.new() }

  it "should generate the correct pubsub-key" do
    @worker.pubsub_key.should == "fnordmetric-announce"
    worker.pubsub_key.should == "fnordmetric-announce"
  end

  it "should generate the correct queue-key" do
    @worker.queue_key.should == "fnordmetric-queue"
    worker.queue_key.should == "fnordmetric-queue"
  end

  it "should generate the correct event-key" do
    @worker.event_key("myevent").should == "fnordmetric-event-myevent"
    worker.event_key("myevent").should == "fnordmetric-event-myevent"
  end

  it "should generate the correct stats-key" do
    @worker.stats_key.should == "fnordmetric-stats"
    worker.stats_key.should == "fnordmetric-stats"
  end

  context "configurable options" do
    let(:worker) { FnordMetric::Worker.new(:redis_prefix => "fnordmetric-special") }

    it "should include redis prefix" do
      worker.pubsub_key.should == "fnordmetric-special-announce"
    end
  end

  it "should add a namespace"