summaryrefslogtreecommitdiff
path: root/zuul/zk/change_cache.py
diff options
context:
space:
mode:
authorSimon Westphahl <simon.westphahl@bmw.de>2021-09-17 12:55:06 +0200
committerJames E. Blair <jim@acmegating.com>2021-09-17 15:52:54 -0700
commitdeb0b692600ea9c3f061055e6af3cffd26e05d70 (patch)
tree10c7aacfe245a884a6fffa5a5cec975f1ed3401c /zuul/zk/change_cache.py
parent5113fbceb063100d94b2453463c787afe030f869 (diff)
downloadzuul-deb0b692600ea9c3f061055e6af3cffd26e05d70.tar.gz
Simplify Zookeeper change cache API
Move common methods to AbstractChangeCache so that concrete implementations only need to defined the mapping from change type as string to the change class. Change-Id: I78c1bdfad1c0986aa6aef387424ea35b6c2aa71d
Diffstat (limited to 'zuul/zk/change_cache.py')
-rw-r--r--zuul/zk/change_cache.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/zuul/zk/change_cache.py b/zuul/zk/change_cache.py
index dea69013c..2f77ef395 100644
--- a/zuul/zk/change_cache.py
+++ b/zuul/zk/change_cache.py
@@ -286,12 +286,18 @@ class AbstractChangeCache(ZooKeeperSimpleBase, Iterable, abc.ABC):
def _updateChange(self, change, data):
change.deserialize(data["change_data"])
- @abc.abstractmethod
def _getChangeClass(self, change_type):
"""Return the change class for the given type."""
- pass
+ return self.CHANGE_TYPE_MAP[change_type]
- @abc.abstractmethod
def _getChangeType(self, change):
"""Return the change type as a string for the given type."""
+ return type(change).__name__
+
+ @abc.abstractproperty
+ def CHANGE_TYPE_MAP(self):
+ """Return a mapping of change type as string to change class.
+
+ This property cann also be defined as a class attribute.
+ """
pass