From 369e109d24c220fce8cc0b56d3ab7eb4db62edf9 Mon Sep 17 00:00:00 2001 From: AJ Date: Mon, 3 Jun 2024 13:29:59 -0400 Subject: [PATCH] update karapace schema registry message formatting --- .../internal/ApicurioEventContext.java | 12 ++++----- .../internal/ApicurioEventFormatter.java | 8 +++--- .../internal/KarapaceEventContext.java | 12 ++++----- .../internal/KarapaceEventFormatter.java | 27 +++++++++++++------ .../resources/META-INF/zilla/apicurio.idl | 8 +++--- .../artifact/global/id/retry/zilla.yaml | 4 +-- .../id/subject/version/retry/zilla.yaml | 4 +-- .../resources/META-INF/zilla/karapace.idl | 8 +++--- .../config/resolve/schema/id/retry/zilla.yaml | 6 ++--- .../resolve/subject/version/retry/zilla.yaml | 12 ++++----- .../config/unretrievable/schema/id/zilla.yaml | 2 +- .../schema/subject/version/zilla.yaml | 4 +-- 12 files changed, 59 insertions(+), 48 deletions(-) diff --git a/runtime/catalog-apicurio/src/main/java/io/aklivity/zilla/runtime/catalog/apicurio/internal/ApicurioEventContext.java b/runtime/catalog-apicurio/src/main/java/io/aklivity/zilla/runtime/catalog/apicurio/internal/ApicurioEventContext.java index 85553059b8..91f2f3be23 100644 --- a/runtime/catalog-apicurio/src/main/java/io/aklivity/zilla/runtime/catalog/apicurio/internal/ApicurioEventContext.java +++ b/runtime/catalog-apicurio/src/main/java/io/aklivity/zilla/runtime/catalog/apicurio/internal/ApicurioEventContext.java @@ -44,7 +44,7 @@ public class ApicurioEventContext private final int staleArtifactID; private final int unretrievableArtifactId; private final int retrievableArtifactSubjectVersionId; - private final int retrievableArtifactId; + private final int retrievedArtifactId; private final MessageConsumer eventWriter; private final Clock clock; @@ -57,8 +57,8 @@ public ApicurioEventContext( this.staleArtifactID = context.supplyEventId("catalog.apicurio.unretrievable.artifact.subject.version.stale.artifact"); this.unretrievableArtifactId = context.supplyEventId("catalog.apicurio.unretrievable.artifact.id"); this.retrievableArtifactSubjectVersionId = context.supplyEventId( - "catalog.apicurio.retrievable.artifact.subject.version"); - this.retrievableArtifactId = context.supplyEventId("catalog.apicurio.retrievable.artifact.id"); + "catalog.apicurio.retrieved.artifact.subject.version"); + this.retrievedArtifactId = context.supplyEventId("catalog.apicurio.retrieved.artifact.id"); this.eventWriter = context.supplyEventWriter(); this.clock = context.clock(); } @@ -142,7 +142,7 @@ public void onRetrievableArtifactSubjectVersion( { ApicurioEventExFW extension = apicurioEventExRW .wrap(extensionBuffer, 0, extensionBuffer.capacity()) - .retrievableArtifactSubjectVersion(e -> e + .retrievedArtifactSubjectVersion(e -> e .typeId(RETRIEVED_ARTIFACT_SUBJECT_VERSION.value()) .subject(subject) .version(version) @@ -165,14 +165,14 @@ public void onRetrievableArtifactId( { ApicurioEventExFW extension = apicurioEventExRW .wrap(extensionBuffer, 0, extensionBuffer.capacity()) - .retrievableArtifactId(e -> e + .retrievedArtifactId(e -> e .typeId(RETRIEVED_ARTIFACT_ID.value()) .artifactId(artifactId) ) .build(); EventFW event = eventRW .wrap(eventBuffer, 0, eventBuffer.capacity()) - .id(retrievableArtifactId) + .id(retrievedArtifactId) .timestamp(clock.millis()) .traceId(0L) .namespacedId(catalogId) diff --git a/runtime/catalog-apicurio/src/main/java/io/aklivity/zilla/runtime/catalog/apicurio/internal/ApicurioEventFormatter.java b/runtime/catalog-apicurio/src/main/java/io/aklivity/zilla/runtime/catalog/apicurio/internal/ApicurioEventFormatter.java index 06da0a0b01..319d9d1d95 100644 --- a/runtime/catalog-apicurio/src/main/java/io/aklivity/zilla/runtime/catalog/apicurio/internal/ApicurioEventFormatter.java +++ b/runtime/catalog-apicurio/src/main/java/io/aklivity/zilla/runtime/catalog/apicurio/internal/ApicurioEventFormatter.java @@ -18,8 +18,8 @@ import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.StringFW; import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.event.ApicurioEventExFW; -import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.event.ApicurioRetrievableArtifactIdExFW; -import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.event.ApicurioRetrievableArtifactSubjectVersionExFW; +import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.event.ApicurioRetrievedArtifactIdExFW; +import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.event.ApicurioRetrievedArtifactSubjectVersionExFW; import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.event.ApicurioUnretrievableArtifactIdExFW; import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.event.ApicurioUnretrievableArtifactSubjectVersionExFW; import io.aklivity.zilla.runtime.catalog.apicurio.internal.types.event.ApicurioUnretrievableArtifactSubjectVersionStaleArtifactExFW; @@ -78,7 +78,7 @@ public String format( } case RETRIEVED_ARTIFACT_SUBJECT_VERSION: { - ApicurioRetrievableArtifactSubjectVersionExFW ex = extension.retrievableArtifactSubjectVersion(); + ApicurioRetrievedArtifactSubjectVersionExFW ex = extension.retrievedArtifactSubjectVersion(); result = String.format("Successfully fetched artifact for subject %s with version %s.", asString(ex.subject()), asString(ex.version()) @@ -87,7 +87,7 @@ public String format( } case RETRIEVED_ARTIFACT_ID: { - ApicurioRetrievableArtifactIdExFW ex = extension.retrievableArtifactId(); + ApicurioRetrievedArtifactIdExFW ex = extension.retrievedArtifactId(); result = String.format("Successfully fetched artifact id %d.", ex.artifactId()); break; } diff --git a/runtime/catalog-karapace/src/main/java/io/aklivity/zilla/runtime/catalog/karapace/internal/KarapaceEventContext.java b/runtime/catalog-karapace/src/main/java/io/aklivity/zilla/runtime/catalog/karapace/internal/KarapaceEventContext.java index 74c78934b8..e6cee3bcd5 100644 --- a/runtime/catalog-karapace/src/main/java/io/aklivity/zilla/runtime/catalog/karapace/internal/KarapaceEventContext.java +++ b/runtime/catalog-karapace/src/main/java/io/aklivity/zilla/runtime/catalog/karapace/internal/KarapaceEventContext.java @@ -44,7 +44,7 @@ public class KarapaceEventContext private final int staleSchemaID; private final int unretrievableSchemaId; private final int retrievableSchemaSubjectVersionId; - private final int retrievableSchemaId; + private final int retrievedSchemaId; private final MessageConsumer eventWriter; private final Clock clock; @@ -55,8 +55,8 @@ public KarapaceEventContext( this.unretrievableSchemaSubjectVersionId = context.supplyEventId("catalog.karapace.unretrievable.schema.subject.version"); this.staleSchemaID = context.supplyEventId("catalog.karapace.unretrievable.schema.subject.version.stale.schema"); this.unretrievableSchemaId = context.supplyEventId("catalog.karapace.unretrievable.schema.id"); - this.retrievableSchemaSubjectVersionId = context.supplyEventId("catalog.karapace.retrievable.schema.subject.version"); - this.retrievableSchemaId = context.supplyEventId("catalog.karapace.retrievable.schema.id"); + this.retrievableSchemaSubjectVersionId = context.supplyEventId("catalog.karapace.retrieved.schema.subject.version"); + this.retrievedSchemaId = context.supplyEventId("catalog.karapace.retrieved.schema.id"); this.eventWriter = context.supplyEventWriter(); this.clock = context.clock(); } @@ -140,7 +140,7 @@ public void onRetrievableSchemaSubjectVersion( { KarapaceEventExFW extension = karapaceEventExRW .wrap(extensionBuffer, 0, extensionBuffer.capacity()) - .retrievableSchemaSubjectVersion(e -> e + .retrievedSchemaSubjectVersion(e -> e .typeId(RETRIEVED_SCHEMA_SUBJECT_VERSION.value()) .subject(subject) .version(version) @@ -163,14 +163,14 @@ public void onRetrievableSchemaId( { KarapaceEventExFW extension = karapaceEventExRW .wrap(extensionBuffer, 0, extensionBuffer.capacity()) - .retrievableSchemaId(e -> e + .retrievedSchemaId(e -> e .typeId(RETRIEVED_SCHEMA_ID.value()) .schemaId(schemaId) ) .build(); EventFW event = eventRW .wrap(eventBuffer, 0, eventBuffer.capacity()) - .id(retrievableSchemaId) + .id(retrievedSchemaId) .timestamp(clock.millis()) .traceId(0L) .namespacedId(catalogId) diff --git a/runtime/catalog-karapace/src/main/java/io/aklivity/zilla/runtime/catalog/karapace/internal/KarapaceEventFormatter.java b/runtime/catalog-karapace/src/main/java/io/aklivity/zilla/runtime/catalog/karapace/internal/KarapaceEventFormatter.java index d00d0d8780..1bc1961063 100644 --- a/runtime/catalog-karapace/src/main/java/io/aklivity/zilla/runtime/catalog/karapace/internal/KarapaceEventFormatter.java +++ b/runtime/catalog-karapace/src/main/java/io/aklivity/zilla/runtime/catalog/karapace/internal/KarapaceEventFormatter.java @@ -51,33 +51,44 @@ public String format( case UNRETRIEVABLE_SCHEMA_SUBJECT_VERSION: { KarapaceUnretrievableSchemaSubjectVersionExFW ex = extension.unretrievableSchemaSubjectVersion(); - result = String.format("%s %s", asString(ex.subject()), asString(ex.version())); + result = String.format( + "Unable to fetch schema for subject %s with version %s.", + asString(ex.subject()), + asString(ex.version()) + ); break; } case UNRETRIEVABLE_SCHEMA_SUBJECT_VERSION_STALE_SCHEMA: { KarapaceUnretrievableSchemaSubjectVersionStaleSchemaExFW ex = extension .unretrievableSchemaSubjectVersionStaleSchema(); - result = String.format("%s %s, using stale schema: %d", asString(ex.subject()), - asString(ex.version()), ex.schemaId()); + result = String.format( + "Unable to fetch schema for subject %s with version %s; using stale schema with id %d.", + asString(ex.subject()), + asString(ex.version()), + ex.schemaId() + ); break; } case UNRETRIEVABLE_SCHEMA_ID: { KarapaceUnretrievableSchemaIdExFW ex = extension.unretrievableSchemaId(); - result = String.format("%d", ex.schemaId()); + result = String.format("Unable to fetch schema id %d.", ex.schemaId()); break; } case RETRIEVED_SCHEMA_SUBJECT_VERSION: { - KarapaceRetrievableSchemaSubjectVersionExFW ex = extension.retrievableSchemaSubjectVersion(); - result = String.format("%s %s", asString(ex.subject()), asString(ex.version())); + KarapaceRetrievableSchemaSubjectVersionExFW ex = extension.retrievedSchemaSubjectVersion(); + result = String.format("Successfully fetched schema for subject %s with version %s.", + asString(ex.subject()), + asString(ex.version()) + ); break; } case RETRIEVED_SCHEMA_ID: { - KarapaceRetrievableSchemaIdExFW ex = extension.retrievableSchemaId(); - result = String.format("%d", ex.schemaId()); + KarapaceRetrievableSchemaIdExFW ex = extension.retrievedSchemaId(); + result = String.format("Successfully fetched schema id %d.", ex.schemaId()); break; } } diff --git a/specs/catalog-apicurio.spec/src/main/resources/META-INF/zilla/apicurio.idl b/specs/catalog-apicurio.spec/src/main/resources/META-INF/zilla/apicurio.idl index 2e19e88727..ca87587f99 100644 --- a/specs/catalog-apicurio.spec/src/main/resources/META-INF/zilla/apicurio.idl +++ b/specs/catalog-apicurio.spec/src/main/resources/META-INF/zilla/apicurio.idl @@ -43,13 +43,13 @@ scope apicurio int32 artifactId; } - struct ApicurioRetrievableArtifactSubjectVersionEx extends core::stream::Extension + struct ApicurioRetrievedArtifactSubjectVersionEx extends core::stream::Extension { string8 subject; string8 version; } - struct ApicurioRetrievableArtifactIdEx extends core::stream::Extension + struct ApicurioRetrievedArtifactIdEx extends core::stream::Extension { int32 artifactId; } @@ -59,8 +59,8 @@ scope apicurio case UNRETRIEVABLE_ARTIFACT_SUBJECT_VERSION: ApicurioUnretrievableArtifactSubjectVersionEx unretrievableArtifactSubjectVersion; case UNRETRIEVABLE_ARTIFACT_SUBJECT_VERSION_STALE_ARTIFACT: ApicurioUnretrievableArtifactSubjectVersionStaleArtifactEx unretrievableArtifactSubjectVersionStaleArtifact; case UNRETRIEVABLE_ARTIFACT_ID: ApicurioUnretrievableArtifactIdEx unretrievableArtifactId; - case RETRIEVED_ARTIFACT_SUBJECT_VERSION: ApicurioRetrievableArtifactSubjectVersionEx retrievableArtifactSubjectVersion; - case RETRIEVED_ARTIFACT_ID: ApicurioRetrievableArtifactIdEx retrievableArtifactId; + case RETRIEVED_ARTIFACT_SUBJECT_VERSION: ApicurioRetrievedArtifactSubjectVersionEx retrievedArtifactSubjectVersion; + case RETRIEVED_ARTIFACT_ID: ApicurioRetrievedArtifactIdEx retrievedArtifactId; } } } diff --git a/specs/catalog-apicurio.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/apicurio/config/resolve/artifact/global/id/retry/zilla.yaml b/specs/catalog-apicurio.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/apicurio/config/resolve/artifact/global/id/retry/zilla.yaml index 917f43b918..b4eaf2d073 100644 --- a/specs/catalog-apicurio.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/apicurio/config/resolve/artifact/global/id/retry/zilla.yaml +++ b/specs/catalog-apicurio.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/apicurio/config/resolve/artifact/global/id/retry/zilla.yaml @@ -26,8 +26,8 @@ telemetry: name: CATALOG_APICURIO_UNRETRIEVABLE_ARTIFACT_ID message: Unable to fetch artifact id 1. - qname: test.catalog0 - id: catalog.apicurio.retrievable.artifact.id - name: CATALOG_APICURIO_RETRIEVABLE_ARTIFACT_ID + id: catalog.apicurio.retrieved.artifact.id + name: CATALOG_APICURIO_RETRIEVED_ARTIFACT_ID message: Successfully fetched artifact id 1. catalogs: catalog0: diff --git a/specs/catalog-apicurio.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/apicurio/config/resolve/artifact/id/subject/version/retry/zilla.yaml b/specs/catalog-apicurio.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/apicurio/config/resolve/artifact/id/subject/version/retry/zilla.yaml index 386ad1f5d8..ca4cad8fae 100644 --- a/specs/catalog-apicurio.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/apicurio/config/resolve/artifact/id/subject/version/retry/zilla.yaml +++ b/specs/catalog-apicurio.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/apicurio/config/resolve/artifact/id/subject/version/retry/zilla.yaml @@ -30,8 +30,8 @@ telemetry: name: CATALOG_APICURIO_UNRETRIEVABLE_ARTIFACT_SUBJECT_VERSION_STALE_ARTIFACT message: Unable to fetch artifact for subject artifactId with version latest; using stale artifact with id 1. - qname: test.catalog0 - id: catalog.apicurio.retrievable.artifact.subject.version - name: CATALOG_APICURIO_RETRIEVABLE_ARTIFACT_SUBJECT_VERSION + id: catalog.apicurio.retrieved.artifact.subject.version + name: CATALOG_APICURIO_RETRIEVED_ARTIFACT_SUBJECT_VERSION message: Successfully fetched artifact for subject artifactId with version latest. catalogs: catalog0: diff --git a/specs/catalog-karapace.spec/src/main/resources/META-INF/zilla/karapace.idl b/specs/catalog-karapace.spec/src/main/resources/META-INF/zilla/karapace.idl index e277c81e52..2004aa856d 100644 --- a/specs/catalog-karapace.spec/src/main/resources/META-INF/zilla/karapace.idl +++ b/specs/catalog-karapace.spec/src/main/resources/META-INF/zilla/karapace.idl @@ -43,13 +43,13 @@ scope karapace int32 schemaId; } - struct KarapaceRetrievableSchemaSubjectVersionEx extends core::stream::Extension + struct KarapaceRetrievedSchemaSubjectVersionEx extends core::stream::Extension { string8 subject; string8 version; } - struct KarapaceRetrievableSchemaIdEx extends core::stream::Extension + struct KarapaceRetrievedSchemaIdEx extends core::stream::Extension { int32 schemaId; } @@ -59,8 +59,8 @@ scope karapace case UNRETRIEVABLE_SCHEMA_SUBJECT_VERSION: KarapaceUnretrievableSchemaSubjectVersionEx unretrievableSchemaSubjectVersion; case UNRETRIEVABLE_SCHEMA_SUBJECT_VERSION_STALE_SCHEMA: KarapaceUnretrievableSchemaSubjectVersionStaleSchemaEx unretrievableSchemaSubjectVersionStaleSchema; case UNRETRIEVABLE_SCHEMA_ID: KarapaceUnretrievableSchemaIdEx unretrievableSchemaId; - case RETRIEVED_SCHEMA_SUBJECT_VERSION: KarapaceRetrievableSchemaSubjectVersionEx retrievableSchemaSubjectVersion; - case RETRIEVED_SCHEMA_ID: KarapaceRetrievableSchemaIdEx retrievableSchemaId; + case RETRIEVED_SCHEMA_SUBJECT_VERSION: KarapaceRetrievedSchemaSubjectVersionEx retrievedSchemaSubjectVersion; + case RETRIEVED_SCHEMA_ID: KarapaceRetrievedSchemaIdEx retrievedSchemaId; } } } diff --git a/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/resolve/schema/id/retry/zilla.yaml b/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/resolve/schema/id/retry/zilla.yaml index 18c8b7317a..df433b2e95 100644 --- a/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/resolve/schema/id/retry/zilla.yaml +++ b/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/resolve/schema/id/retry/zilla.yaml @@ -24,11 +24,11 @@ telemetry: - qname: test.catalog0 id: catalog.karapace.unretrievable.schema.id name: CATALOG_KARAPACE_UNRETRIEVABLE_SCHEMA_ID - message: 9 + message: Unable to fetch schema id 9. - qname: test.catalog0 - id: catalog.karapace.retrievable.schema.id + id: catalog.karapace.retrieved.schema.id name: CATALOG_KARAPACE_RETRIEVED_SCHEMA_ID - message: 9 + message: Successfully fetched schema id 9. catalogs: catalog0: type: karapace diff --git a/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/resolve/subject/version/retry/zilla.yaml b/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/resolve/subject/version/retry/zilla.yaml index b425b918d1..f917cdae5a 100644 --- a/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/resolve/subject/version/retry/zilla.yaml +++ b/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/resolve/subject/version/retry/zilla.yaml @@ -23,16 +23,16 @@ telemetry: events: - qname: test.catalog0 id: catalog.karapace.unretrievable.schema.subject.version - name: CATALOG_KARAPACE_UNRETRIEVABLE_SCHEMA - message: items-snapshots-value latest + name: CATALOG_KARAPACE_UNRETRIEVABLE_SCHEMA_SUBJECT_VERSION + message: Unable to fetch schema for subject items-snapshots-value with version latest. - qname: test.catalog0 id: catalog.karapace.unretrievable.schema.subject.version.stale.schema - name: CATALOG_KARAPACE_UNRETRIEVABLE_SCHEMA - message: items-snapshots-value latest, USING_STALE_SCHEMA 9 + name: CATALOG_KARAPACE_UNRETRIEVABLE_SCHEMA_SUBJECT_VERSION_STALE_SCHEMA + message: Unable to fetch schema for subject items-snapshots-value with version latest; using stale schema with id 9. - qname: test.catalog0 - id: catalog.karapace.retrievable.schema.subject.version + id: catalog.karapace.retrieved.schema.subject.version name: CATALOG_KARAPACE_RETRIEVED_SCHEMA_SUBJECT_VERSION - message: items-snapshots-value latest + message: Successfully fetched schema for subject items-snapshots-value with version latest. catalogs: catalog0: type: karapace diff --git a/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/unretrievable/schema/id/zilla.yaml b/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/unretrievable/schema/id/zilla.yaml index c12bc168b9..88f28c49a2 100644 --- a/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/unretrievable/schema/id/zilla.yaml +++ b/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/unretrievable/schema/id/zilla.yaml @@ -24,7 +24,7 @@ telemetry: - qname: test.catalog0 id: catalog.karapace.unretrievable.schema.id name: CATALOG_KARAPACE_UNRETRIEVABLE_SCHEMA_ID - message: 1 + message: Unable to fetch schema id 1. catalogs: catalog0: type: karapace diff --git a/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/unretrievable/schema/subject/version/zilla.yaml b/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/unretrievable/schema/subject/version/zilla.yaml index 2adde1fdc7..28de1a1313 100644 --- a/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/unretrievable/schema/subject/version/zilla.yaml +++ b/specs/catalog-karapace.spec/src/main/scripts/io/aklivity/zilla/specs/catalog/karapace/config/unretrievable/schema/subject/version/zilla.yaml @@ -23,8 +23,8 @@ telemetry: events: - qname: test.catalog0 id: catalog.karapace.unretrievable.schema.subject.version - name: CATALOG_KARAPACE_UNRETRIEVABLE_SCHEMA - message: items-snapshots-value latest + name: CATALOG_KARAPACE_UNRETRIEVABLE_SCHEMA_SUBJECT_VERSION + message: Unable to fetch schema for subject items-snapshots-value with version latest. catalogs: catalog0: type: karapace