Erik's Engineering

something alliterative

You can configure guard to remember relationships between test files, so you never forget to run all the relevant tests after a change.

Published on 08/08/2013 at 13h07 under , . Tags , , ,

0 comments

A while back during a standup, I had an interaction about like the following: Me: Yesterday I spent a bunch of time banging my head against the wall on X. Person Zed: Oh, that's easy. I can't believe you're having trouble with it. You just have to frobble the Y and then snizzle the Z. Me: Well thanks for making me feel stupid.

Published on 07/08/2013 at 22h33 under .

0 comments

The other day I found myself typing the following into IRB. I wanted a quick and dirty way to get some time series data about a job queue and this is what I came up with.

@queue_stats_list = []
Thread.new do
  queue_name = 'worq.test'
  while true do
    @queue_stats_list << QueueStats.new(queue_name)
    sleep 30
  end

  puts "Sampler thread exiting"
end

Thread.new will run whatever block you give it in a separate thread. It's in the same process, so you have access to shared variables. I'm just using @queue_stats_list to accumulate some data in memory. I can always call @queue_stats_list.last to get the most recent or compare different readings to see how things changed over time. It'll keep going as long as your console is running.

Eventually this grew into a much more full-featured class that knows how to calculate rates of change between measurements and all sorts of other goodies, but the first cut took no more than 5 minutes (including that QueueStats class I'm not showing you) and got me enough data to say "This job queue won't complete for a week or more. I'm going to have to figure out what's slowing it down and fix it."

With ruby, threads don't have to be reserved for fancy infrastructure projects. Any time you're in a console you've got concurrency at your fingertips.

Published on 28/05/2012 at 17h24 .

0 comments

Powered by Typo – Thème Frédéric de Villamil | Photo Glenn