First few changes for the image diffs feature.

This commit is contained in:
yackob03 2013-10-17 18:25:19 -04:00
parent b22a4aa24c
commit 93b856bdb3
9 changed files with 189 additions and 2 deletions

0
workers/__init__.py Normal file
View file

36
workers/image_diffs.py Normal file
View file

@ -0,0 +1,36 @@
import logging
import json
from apscheduler.scheduler import Scheduler
from data.queue import WorkQueue
from endpoints.registry import process_image_changes
logger = logging.getLogger(__name__)
image_diff_queue = WorkQueue('imagediff')
def process_work_items():
logger.debug('Getting work item from queue.')
item = imagediff.get()
if item:
logger.debug('Queue gave us some work: %s' % item.body)
request = json.loads(item.body)
process_image_changes(request['namepspace'], request['repository'],
request['image_id'])
else:
logger.debug('No work today.')
FORMAT = '%(asctime)-15s - %(levelname)s - %(pathname)s - %(funcName)s - %(message)s'
logging.basicConfig(format=FORMAT, level=logging.DEBUG)
sched = Scheduler()
sched.start()
sched.add_interval_job(process_work_items, seconds=10)