This repository has been archived on 2025-02-22. You can view files and clone it, but cannot push or open issues or pull requests.

74 lines
1.8 KiB
Python
Raw Normal View History

2019-09-26 14:12:15 +05:30
"""
2019-12-24 18:23:48 +05:30
Storing inventory items
2019-09-26 14:12:15 +05:30
"""
import collections
2019-12-24 18:23:48 +05:30
InventoryItem = collections.namedtuple(
'InventoryItem', 'type stream payload expires tag')
2019-09-25 16:39:15 +05:30
2019-12-24 18:23:48 +05:30
class Storage(object): # pylint: disable=too-few-public-methods
"""Base class for storing inventory
(extendable for other items to store)"""
pass
2019-09-25 16:39:15 +05:30
class InventoryStorage(Storage, collections.MutableMapping):
2019-09-26 14:12:15 +05:30
"""Module used for inventory storage"""
2019-12-24 18:23:48 +05:30
def __init__(self): # pylint: disable=super-init-not-called
self.numberOfInventoryLookupsPerformed = 0
2019-09-26 14:12:15 +05:30
def __contains__(self, _):
raise NotImplementedError
2019-09-26 14:12:15 +05:30
def __getitem__(self, _):
raise NotImplementedError
2019-09-26 14:12:15 +05:30
def __setitem__(self, _, value):
raise NotImplementedError
2019-09-26 14:12:15 +05:30
def __delitem__(self, _):
raise NotImplementedError
def __iter__(self):
raise NotImplementedError
def __len__(self):
raise NotImplementedError
2017-06-24 12:13:35 +02:00
def by_type_and_tag(self, objectType, tag):
2019-09-24 14:50:20 +05:30
"""Return objects filtered by object type and tag"""
raise NotImplementedError
def unexpired_hashes_by_stream(self, stream):
2019-09-24 14:50:20 +05:30
"""Return unexpired inventory vectors filtered by stream"""
raise NotImplementedError
def flush(self):
2019-09-24 14:50:20 +05:30
"""Flush cache"""
raise NotImplementedError
def clean(self):
2019-09-24 14:50:20 +05:30
"""Free memory / perform garbage collection"""
raise NotImplementedError
2019-09-25 16:39:15 +05:30
2019-12-24 18:23:48 +05:30
class MailboxStorage(Storage, collections.MutableMapping):
2019-09-26 14:12:15 +05:30
"""Method for storing mails"""
2019-12-24 18:23:48 +05:30
def __delitem__(self, key):
raise NotImplementedError
def __getitem__(self, key):
raise NotImplementedError
def __iter__(self):
raise NotImplementedError
def __len__(self):
raise NotImplementedError
def __setitem__(self, key, value):
raise NotImplementedError