diff --git a/src/ook/domain/kafka.py b/src/ook/domain/kafka.py index a06a88b..f70efce 100644 --- a/src/ook/domain/kafka.py +++ b/src/ook/domain/kafka.py @@ -13,7 +13,7 @@ "UrlIngestKeyV1", "LtdEditionV1", "LtdProjectV1", - "LtdUrlIngestV1", + "LtdUrlIngestV2", ] @@ -61,7 +61,7 @@ class LtdProjectV1(AvroBaseModel): slug: str = Field(..., description="The slug of the project.") -class LtdUrlIngestV1(AvroBaseModel): +class LtdUrlIngestV2(AvroBaseModel): """Kafka message value model for a request to ingest a URL hosted on LSST the Docs. @@ -91,4 +91,4 @@ class Meta: """Metadata for the model.""" namespace = "lsst.square-events.ook" - schema_name = "ltd_url_ingest_v1" + schema_name = "ltd_url_ingest_v2" diff --git a/src/ook/factory.py b/src/ook/factory.py index bd47486..c5ca216 100644 --- a/src/ook/factory.py +++ b/src/ook/factory.py @@ -22,7 +22,7 @@ from .config import config from .dependencies.algoliasearch import algolia_client_dependency -from .domain.kafka import LtdUrlIngestV1, UrlIngestKeyV1 +from .domain.kafka import LtdUrlIngestV2, UrlIngestKeyV1 from .services.algoliaaudit import AlgoliaAuditService from .services.algoliadocindex import AlgoliaDocIndexService from .services.classification import ClassificationService @@ -67,7 +67,7 @@ async def create(cls) -> ProcessContext: registry_url=config.registry_url, models=[ UrlIngestKeyV1, - LtdUrlIngestV1, + LtdUrlIngestV2, ], suffix=config.subject_suffix, compatibility=config.subject_compatibility, diff --git a/src/ook/handlers/kafka/handlers.py b/src/ook/handlers/kafka/handlers.py index 537e08d..730ff58 100644 --- a/src/ook/handlers/kafka/handlers.py +++ b/src/ook/handlers/kafka/handlers.py @@ -13,7 +13,7 @@ from structlog.stdlib import BoundLogger from ook.domain.algoliarecord import DocumentSourceType -from ook.domain.kafka import LtdUrlIngestV1, UrlIngestKeyV1 +from ook.domain.kafka import LtdUrlIngestV2, UrlIngestKeyV1 from ook.factory import Factory if TYPE_CHECKING: @@ -46,7 +46,7 @@ async def handle_ltd_document_ingest( *, message_metadata: MessageMetadata, key: UrlIngestKeyV1, - value: LtdUrlIngestV1, + value: LtdUrlIngestV2, **kwargs: Any, ) -> None: """Handle a message requesting an ingest for an LTD document.""" diff --git a/src/ook/handlers/kafka/router.py b/src/ook/handlers/kafka/router.py index 6287114..a9bd84e 100644 --- a/src/ook/handlers/kafka/router.py +++ b/src/ook/handlers/kafka/router.py @@ -15,7 +15,7 @@ from ook.config import config from ook.dependencies.context import context_dependency -from ook.domain.kafka import LtdUrlIngestV1, UrlIngestKeyV1 +from ook.domain.kafka import LtdUrlIngestV2, UrlIngestKeyV1 from ook.handlers.kafka.handlers import handle_ltd_document_ingest @@ -261,6 +261,6 @@ async def consume_kafka_messages() -> None: cast(HandlerProtocol, handle_ltd_document_ingest), [config.ingest_kafka_topic], [UrlIngestKeyV1], - [LtdUrlIngestV1], + [LtdUrlIngestV2], ) await consumer.start() diff --git a/src/ook/services/classification.py b/src/ook/services/classification.py index c3c2cc8..afcbf38 100644 --- a/src/ook/services/classification.py +++ b/src/ook/services/classification.py @@ -16,7 +16,7 @@ from ook.domain.kafka import ( LtdEditionV1, LtdProjectV1, - LtdUrlIngestV1, + LtdUrlIngestV2, UrlIngestKeyV1, ) from ook.services.kafkaproducer import PydanticKafkaProducer @@ -116,7 +116,7 @@ async def queue_ingest_for_ltd_product_slug( try: kafka_key = UrlIngestKeyV1(url=published_url) - kafka_value = LtdUrlIngestV1( + kafka_value = LtdUrlIngestV2( url=published_url, content_type=content_type, request_timestamp=datetime.now(tz=UTC), diff --git a/tests/domain/test_kafka.py b/tests/domain/test_kafka.py index 54b6ee0..942ed6c 100644 --- a/tests/domain/test_kafka.py +++ b/tests/domain/test_kafka.py @@ -4,7 +4,7 @@ import json -from ook.domain.kafka import LtdUrlIngestV1, UrlIngestKeyV1 +from ook.domain.kafka import LtdUrlIngestV2, UrlIngestKeyV1 def test_url_ingest_key_v1() -> None: @@ -14,8 +14,8 @@ def test_url_ingest_key_v1() -> None: assert schema["namespace"] == "lsst.square-events.ook" -def test_ltd_url_ingest_v1() -> None: - """Test the ``LtdUrlIngestV1`` model.""" - schema = json.loads(LtdUrlIngestV1.avro_schema()) - assert schema["name"] == "ltd_url_ingest_v1" +def test_ltd_url_ingest_v2() -> None: + """Test the ``LtdUrlIngestV2`` model.""" + schema = json.loads(LtdUrlIngestV2.avro_schema()) + assert schema["name"] == "ltd_url_ingest_v2" assert schema["namespace"] == "lsst.square-events.ook"