Merge "Use real abstract class"

This commit is contained in:
Zuul 2026-01-02 20:34:20 +00:00 committed by Gerrit Code Review
commit bedfb5ed4f
2 changed files with 14 additions and 10 deletions

View file

@ -13,6 +13,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import abc
import datetime
from oslo_log import log as logging
@ -30,7 +31,7 @@ CONF = designate.conf.CONF
LOG = logging.getLogger(__name__)
class PeriodicTask(plugin.ExtensionPlugin):
class PeriodicTask(plugin.ExtensionPlugin, metaclass=abc.ABCMeta):
"""Abstract Producer periodic task
"""
__plugin_ns__ = 'designate.producer_tasks'
@ -40,6 +41,15 @@ class PeriodicTask(plugin.ExtensionPlugin):
super().__init__()
self.my_partitions = None
@abc.abstractmethod
def __call__(self):
pass
@property
@abc.abstractmethod
def __plugin_name__(self):
pass
@property
def central_api(self):
return rpcapi.CentralAPI.get_instance()
@ -89,9 +99,6 @@ class DeletedZonePurgeTask(PeriodicTask):
"""
__plugin_name__ = 'zone_purge'
def __init__(self):
super().__init__()
def __call__(self):
"""Call the Central API to perform a purge of deleted zones based on
expiration time and sharding range.
@ -223,9 +230,6 @@ class PeriodicGenerateDelayedNotifyTask(PeriodicTask):
"""
__plugin_name__ = 'delayed_notify'
def __init__(self):
super().__init__()
def __call__(self):
"""Fetch a list of zones with the delayed_notify flag set up to
"batch_size"
@ -275,9 +279,6 @@ class PeriodicGenerateDelayedNotifyTask(PeriodicTask):
class PeriodicIncrementSerialTask(PeriodicTask):
__plugin_name__ = 'increment_serial'
def __init__(self):
super().__init__()
def __call__(self):
ctxt = context.DesignateContext.get_admin_context()
ctxt.all_tenants = True

View file

@ -56,6 +56,9 @@ class DummyTask(tasks.PeriodicTask):
"""Dummy task used to test helper functions"""
__plugin_name__ = 'dummy'
def __call__(self):
pass
class PeriodicTest(oslotest.base.BaseTestCase):
def setUp(self):