worker: Extract some common helper functions
worker: Extract some common helper functions

henrikhodne-abandoned/worker,henrikhodne-abandoned/worker,solarce/worker,henrikhodne-abandoned/worker,solarce/worker,travis-ci/worker,solarce/worker,Acidburn0zzz/worker,travis-ci/worker,travis-ci/worker,Acidburn0zzz/worker,Acidburn0zzz/worker