Merge "Adding get messages behavior"
This commit is contained in:
commit
b17f892cdf
|
@ -57,6 +57,18 @@ class MeniscusConfig(ConfigSectionInterface):
|
|||
return self.get("db_password")
|
||||
|
||||
|
||||
class StorageConfig(ConfigSectionInterface):
|
||||
SECTION_NAME = 'meniscus-storage'
|
||||
|
||||
@property
|
||||
def address(self):
|
||||
return self.get('address')
|
||||
|
||||
@property
|
||||
def index(self):
|
||||
return self.get('index')
|
||||
|
||||
|
||||
class TenantConfig(ConfigSectionInterface):
|
||||
SECTION_NAME = 'meniscus-tenant'
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@ limitations under the License.
|
|||
|
||||
class PublishingBehaviors(object):
|
||||
|
||||
def __init__(self, publish_client, correlation_config, tenant_id=None,
|
||||
tenant_token=None):
|
||||
def __init__(self, publish_client, correlation_config,
|
||||
storage_client, tenant_id=None, tenant_token=None):
|
||||
self.publish_client = publish_client
|
||||
self.correlation_config = correlation_config
|
||||
self.storage_client = storage_client
|
||||
self.tenant_id = tenant_id
|
||||
self.tenant_token = tenant_token
|
||||
|
||||
|
@ -50,3 +51,19 @@ class PublishingBehaviors(object):
|
|||
time=time or self.correlation_config.time,
|
||||
native=native)
|
||||
return resp
|
||||
|
||||
def _create_term_name(self, tenant_id, object_path):
|
||||
return 'tenant/{tenant_id}.{obj_path}'.format(tenant_id=tenant_id,
|
||||
obj_path=object_path)
|
||||
|
||||
def get_messages_by_timestamp(self, timestamp, num_messages=10,
|
||||
tenant_id=None):
|
||||
if tenant_id is None:
|
||||
tenant_id = self.tenant_id
|
||||
|
||||
name = self._create_term_name(tenant_id=tenant_id, object_path='time')
|
||||
resp = self.storage_client.find_term(name=name, value=timestamp,
|
||||
size=num_messages)
|
||||
|
||||
# Copying all of the models into a fresh list
|
||||
return [model for model in resp]
|
||||
|
|
|
@ -10,6 +10,10 @@ db_name=<db_name>
|
|||
db_username=<db_username>
|
||||
db_password=<db_password>
|
||||
|
||||
[meniscus-storage]
|
||||
address=<storage_address>
|
||||
index=<storage_index>
|
||||
|
||||
[meniscus-tenant]
|
||||
hostname=testhost
|
||||
ip_address_v4=127.0.0.1
|
||||
|
@ -44,4 +48,4 @@ native={"my_field":"my_value","my_value":12345,"extended":{"customer":"54789"}}
|
|||
|
||||
[GITHUB]
|
||||
token=<github_token>
|
||||
repo=ProjectMeniscus/meniscus
|
||||
repo=ProjectMeniscus/meniscus
|
||||
|
|
Loading…
Reference in New Issue