From 30e295ec28de7ba9af4d4794e50a92b303b107df Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 18 May 2022 12:02:08 -0400 Subject: [PATCH] move notifier_protocol.py --- hub/common.py | 6 ++++++ hub/elastic_sync/__init__.py | 2 -- hub/elastic_sync/search.py | 8 +------- hub/elastic_sync/service.py | 5 +++-- hub/herald/service.py | 2 +- hub/herald/session.py | 2 +- hub/{elastic_sync => }/notifier_protocol.py | 0 7 files changed, 12 insertions(+), 13 deletions(-) rename hub/{elastic_sync => }/notifier_protocol.py (100%) diff --git a/hub/common.py b/hub/common.py index be4cb4c..32df6dd 100644 --- a/hub/common.py +++ b/hub/common.py @@ -398,3 +398,9 @@ class TaskGroup: task.cancel() self.done.set() self.started.clear() + + +class IndexVersionMismatch(Exception): + def __init__(self, got_version, expected_version): + self.got_version = got_version + self.expected_version = expected_version diff --git a/hub/elastic_sync/__init__.py b/hub/elastic_sync/__init__.py index ca4352e..e69de29 100644 --- a/hub/elastic_sync/__init__.py +++ b/hub/elastic_sync/__init__.py @@ -1,2 +0,0 @@ -from hub.elastic_sync.search import SearchIndex -from hub.elastic_sync.notifier_protocol import ElasticNotifierClientProtocol \ No newline at end of file diff --git a/hub/elastic_sync/search.py b/hub/elastic_sync/search.py index 93ace26..1cbe06d 100644 --- a/hub/elastic_sync/search.py +++ b/hub/elastic_sync/search.py @@ -12,7 +12,7 @@ from hub.schema.result import Censor, Outputs from hub.schema.tags import clean_tags from hub.schema.url import normalize_name from hub.error import TooManyClaimSearchParametersError -from hub.common import LRUCache +from hub.common import LRUCache, IndexVersionMismatch from hub.db.common import CLAIM_TYPES, STREAM_TYPES from hub.elastic_sync.constants import INDEX_DEFAULT_SETTINGS, REPLACEMENTS, FIELDS, TEXT_FIELDS, RANGE_FIELDS from hub.db.common import ResolveResult @@ -32,12 +32,6 @@ class StreamResolution(str): return LookupError(f'Could not find claim at "{url}".') -class IndexVersionMismatch(Exception): - def __init__(self, got_version, expected_version): - self.got_version = got_version - self.expected_version = expected_version - - class SearchIndex: VERSION = 1 diff --git a/hub/elastic_sync/service.py b/hub/elastic_sync/service.py index ade8db3..b4063a8 100644 --- a/hub/elastic_sync/service.py +++ b/hub/elastic_sync/service.py @@ -7,10 +7,11 @@ from elasticsearch import AsyncElasticsearch, NotFoundError from elasticsearch.helpers import async_streaming_bulk from hub.schema.result import Censor from hub.service import BlockchainReaderService +from hub.common import IndexVersionMismatch from hub.db.revertable import RevertableOp from hub.db.common import TrendingNotification, DB_PREFIXES -from hub.elastic_sync.notifier_protocol import ElasticNotifierProtocol -from hub.elastic_sync.search import IndexVersionMismatch, expand_query +from hub.notifier_protocol import ElasticNotifierProtocol +from hub.elastic_sync.search import expand_query from hub.elastic_sync.constants import ALL_FIELDS, INDEX_DEFAULT_SETTINGS from hub.elastic_sync.fast_ar_trending import FAST_AR_TRENDING_SCRIPT if typing.TYPE_CHECKING: diff --git a/hub/herald/service.py b/hub/herald/service.py index f6015cf..64f9415 100644 --- a/hub/herald/service.py +++ b/hub/herald/service.py @@ -6,7 +6,7 @@ from hub.herald.session import SessionManager from hub.herald.mempool import HubMemPool from hub.herald.udp import StatusServer from hub.service import BlockchainReaderService -from hub.elastic_sync import ElasticNotifierClientProtocol +from hub.notifier_protocol import ElasticNotifierClientProtocol if typing.TYPE_CHECKING: from hub.herald.env import ServerEnv diff --git a/hub/herald/session.py b/hub/herald/session.py index 9e339b7..3078a7d 100644 --- a/hub/herald/session.py +++ b/hub/herald/session.py @@ -20,7 +20,7 @@ from hub.error import ResolveCensoredError, TooManyClaimSearchParametersError from hub import __version__, PROMETHEUS_NAMESPACE from hub.herald import PROTOCOL_MIN, PROTOCOL_MAX, HUB_PROTOCOL_VERSION from hub.build_info import BUILD, COMMIT_HASH, DOCKER_TAG -from hub.elastic_sync import SearchIndex +from hub.elastic_sync.search import SearchIndex from hub.common import sha256, hash_to_hex_str, hex_str_to_hash, HASHX_LEN, version_string, formatted_time from hub.common import protocol_version, RPCError, DaemonError, TaskGroup, HISTOGRAM_BUCKETS from hub.herald.jsonrpc import JSONRPCAutoDetect, JSONRPCConnection, JSONRPCv2, JSONRPC diff --git a/hub/elastic_sync/notifier_protocol.py b/hub/notifier_protocol.py similarity index 100% rename from hub/elastic_sync/notifier_protocol.py rename to hub/notifier_protocol.py