Change buildlogsarchiver to use a data interface

This commit is contained in:
Joseph Schorr 2017-07-11 15:33:28 +03:00
parent b7a2a4390b
commit 8ba71f7a45
4 changed files with 76 additions and 12 deletions

View file

@ -0,0 +1,37 @@
from abc import ABCMeta, abstractmethod
from collections import namedtuple
from six import add_metaclass
class Build(namedtuple('Build', ['uuid', 'logs_archived'])):
"""
Build represents a single build in the build system.
"""
@add_metaclass(ABCMeta)
class BuildLogsArchiverWorkerDataInterface(object):
"""
Interface that represents all data store interactions required by the build logs archiver worker.
"""
@abstractmethod
def get_archivable_build(self):
""" Returns a build whose logs are available for archiving. If none, returns None. """
pass
@abstractmethod
def get_build(self, build_uuid):
""" Returns the build with the matching UUID or None if none. """
pass
@abstractmethod
def mark_build_archived(self, build_uuid):
""" Marks the build with the given UUID as having its logs archived. Returns False if
the build was already marked as archived.
"""
pass
@abstractmethod
def create_build_for_testing(self):
""" Creates an unarchived build for testing of archiving. """
pass