-
Notifications
You must be signed in to change notification settings - Fork 15
Add support for schema subject naming strategies #581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Athosone
wants to merge
50
commits into
michelin:master
Choose a base branch
from
Athosone:feature/schema-naming-strategies
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
2950ddf
wip: validate subject based on the namespace configuration
Athosone cd5608d
Polish code and rename classes (Schema>Subject)
5e68e44
Add constants + spotlessApply
6ad20d5
Remove methods that hamper introspection + do not test if strategy is…
f351874
Fix type of strategy config (ValidList -> ValidString)
7a8e352
Add comments and TODO
df8f01c
wip: fixing todos
Athosone e1cc21e
Fix SchemasServiceTest with new subject strategy handling
4096101
Fix enum error for SubjectNameStrategy
9c0c62e
change name of field 'name' in Enum (Enum has a default method name).
ad06e47
Simplify error message when subject name strategy is not respected
faadad2
Polish code + add test for topic record name strategy
64296e0
Update a method comment and apply spotlessApply
1f80892
Fix tests by adding topicValidator to all namespace specs
monitorpattern b787bbe
Remove deprecated method for invalid schema-resource name
monitorpattern 6733c46
wip
Athosone e77edb3
Factorize code and homogeneize variable names
monitorpattern 1d8fbc9
Polish the code + spotlessApply
monitorpattern 6a2fe61
Compare subject name including namespace
Athosone 93dee40
Polish the Readme
monitorpattern ad25d8c
Add an integration test for subject name strategy other than topic name
monitorpattern 4bd6350
Apply spotlessApply task
Athosone 49b4f2b
Fix comments
monitorpattern f2d1910
Fix topicvalidator comments
Athosone e93f2e5
Move SchemasSubjectNameValidator into SchemaService
monitorpattern 1ea5eae
Apply spotlessApply
monitorpattern d437ee3
Refactor signatures of methods that involve schemas
monitorpattern 1ad4d4c
fix: AllArgsConstructor
Athosone cd22bcf
fix: replace substring by replace :p
Athosone 8d22cd6
fix: add description
Athosone 0c25fc9
fix: refactor validate subject name strategy
Athosone 53d7cb2
fix: remove extractRecordName
Athosone bcbc9a7
fix: handle key subject name strategies
Athosone df6747e
fix: fix javadoc
Athosone fee6a01
Rename tests wIcône xlsx MBO Team Mood.xlsx.r.t naming conventions
monitorpattern 264df67
Rename tests wrt naming conventions WIP
monitorpattern 469126e
fix: extract name, also renamed tests
Athosone 1963921
fix: test from comment review
Athosone cee4ba8
fix: test with wrong input data
Athosone e501e71
fix: rolled back extract topic record name to handle union of reference
Athosone 1521080
Some updates
loicgreffier fa857f3
Fixes before unit tests
loicgreffier 8eaea88
update
loicgreffier 13c0e32
update
loicgreffier 8e58bb4
Run test on CCloud cluster
loicgreffier 5cb1284
Update format
loicgreffier d3aa8b5
Add server validation for reference fields
loicgreffier 1be2baf
spotless
loicgreffier b3a3b0f
Do not use the topic property anymore but namespace config instead
loicgreffier 62160c0
Fix unit tests
loicgreffier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/com/michelin/ns4kafka/model/schema/SubjectNameStrategy.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package com.michelin.ns4kafka.model.schema; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonValue; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import lombok.AllArgsConstructor; | ||
|
|
||
| /** Schema subject naming strategies supported by Schema Registry. */ | ||
| @AllArgsConstructor | ||
| public enum SubjectNameStrategy { | ||
| TOPIC_NAME("TopicNameStrategy"), | ||
| TOPIC_RECORD_NAME("TopicRecordNameStrategy"), | ||
| RECORD_NAME("RecordNameStrategy"); | ||
|
|
||
| private final String value; | ||
|
|
||
| /** | ||
| * Convert the SubjectNameStrategy to its string representation. | ||
| * | ||
| * @return The string representation of the SubjectNameStrategy | ||
| */ | ||
| @JsonValue | ||
| @Override | ||
| public String toString() { | ||
| return value; | ||
| } | ||
|
|
||
| /** | ||
| * Get the default SubjectNameStrategy. | ||
| * | ||
| * @return The default SubjectNameStrategy | ||
| */ | ||
| public static List<SubjectNameStrategy> defaultStrategy() { | ||
| return List.of(TOPIC_NAME); | ||
| } | ||
|
|
||
| /** | ||
| * Get SubjectNameStrategy from its string representation. | ||
| * | ||
| * @param stringValue The string representation of the SubjectNameStrategy | ||
| * @return The SubjectNameStrategy | ||
| */ | ||
| public static SubjectNameStrategy from(final String stringValue) { | ||
| return Arrays.stream(values()) | ||
| .filter(s -> s.value.equals(stringValue)) | ||
| .findFirst() | ||
| .orElseThrow(() -> new IllegalArgumentException("Unknown strategy: " + stringValue)); | ||
| } | ||
|
|
||
| /** | ||
| * Get the expected format for the subject name based on the strategy. | ||
| * | ||
| * @return The expected format for the subject name | ||
| */ | ||
| public String toExpectedFormat() { | ||
| return switch (this) { | ||
| case TOPIC_NAME -> "{topic}-{key|value}"; | ||
| case TOPIC_RECORD_NAME -> "{topic}-{recordName}"; | ||
| case RECORD_NAME -> "{recordName}"; | ||
| }; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
defaultStrategiesbe a better name?