You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-52Lines changed: 17 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -491,23 +491,25 @@ the `NAMESPACE-LDAP-GROUP` will be able to access the resources within the `myNa
491
491
492
492
#### Schema Subject Name Strategies
493
493
494
-
Ns4Kafka supports multiple schema subject naming strategies that define how schema subjects are named in the Schema Registry. These strategies align with Confluent's Schema Registry naming conventions and can be configured per namespace to enforce consistent schema naming.
494
+
Ns4Kafka supports three subject naming strategies for schemas in the Schema Registry. These strategies are explained in the [Confluent documentation](https://developer.confluent.io/courses/schema-registry/schema-subjects).
495
495
496
496
##### Supported Strategies
497
497
498
-
Ns4Kafka supports three schema subject naming strategies:
498
+
Each strategy imposes patterns for naming schema subjects as follows:
499
499
500
-
| Strategy | Full Class Name | Format | Description |
| `TOPIC_NAME` | `io.confluent.kafka.serializers.subject.TopicNameStrategy` | `{topic}-{key\|value}` | Subject name follows the topic name with `-key` or `-value` suffix |
503
-
| `TOPIC_RECORD_NAME` | `io.confluent.kafka.serializers.subject.TopicRecordNameStrategy` | `{topic}-{recordName}` | Subject name combines topic name with the record name from the AVRO schema |
504
-
| `RECORD_NAME` | `io.confluent.kafka.serializers.subject.RecordNameStrategy` | `{recordName}` | Subject name uses only the record name from the AVRO schema |
**Note**: The `TOPIC_RECORD_NAME` and `RECORD_NAME` strategies currently only support AVRO schemas, as they require extracting the record name from the schema content.
506
+
507
+
**Note**: The TopicRecordName and RecordName strategies currently only support Avro schemas.
507
508
508
509
##### Configuration
509
510
510
511
Schema subject naming strategies are configured in the namespace's `topicValidator` section using the `confluent.value.subject.name.strategy` constraint. You can specify multiple valid strategies that will be accepted for schemas in that namespace.
512
+
If the subject name in a schema description does not match any of the allowed strategies, the schema deployment will be rejected.
511
513
512
514
```yaml
513
515
apiVersion: v1
@@ -529,72 +531,35 @@ spec:
529
531
530
532
##### Example Usage
531
533
532
-
Using the `TopicRecordNameStrategy` with a topic named `demoPrefix.topic_63` and AVRO schemas:
534
+
The following example uses the `TopicRecordNameStrategy` with a topic named `myPrefix.myTopic` and Avro schemas in a resource file:
533
535
534
536
```yaml
535
-
# Topic definition
537
+
--- # Topic
536
538
apiVersion: v1
537
539
kind: Topic
538
540
metadata:
539
-
name: demoPrefix.topic_63
541
+
name: myPrefix.myTopic
540
542
namespace: demo
541
543
spec:
542
544
replicationFactor: 1
543
545
partitions: 1
544
-
545
-
# Schema using TopicRecordNameStrategy
546
-
# Subject name: demoPrefix.topic_63-demo.User
546
+
--- # Schema using TopicRecordNameStrategy
547
547
apiVersion: v1
548
548
kind: Schema
549
549
metadata:
550
-
name: demoPrefix.topic_63-demo.User
550
+
name: myPrefix.myTopic-com.schema.avro.User
551
551
spec:
552
552
schema: |
553
553
{
554
554
"type": "record",
555
-
"name": "demo.User",
555
+
"name": "User",
556
+
"namespace": "com.schema.avro",
556
557
"fields": [
557
-
{"name": "userId", "type": "string"},
558
558
{"name": "name", "type": "string"},
559
559
{"name": "email", "type": "string"}
560
560
]
561
561
}
562
-
563
-
# Another schema for the same topic
564
-
# Subject name: demoPrefix.topic_63-demo.Car
565
-
apiVersion: v1
566
-
kind: Schema
567
-
metadata:
568
-
name: demoPrefix.topic_63-demo.Car
569
-
spec:
570
-
schema: |
571
-
{
572
-
"type": "record",
573
-
"name": "demo.Car",
574
-
"fields": [
575
-
{"name": "carId", "type": "string"},
576
-
{"name": "make", "type": "string"},
577
-
{"name": "model", "type": "string"}
578
-
]
579
-
}
580
562
```
581
-
582
-
In this example:
583
-
- The topic name is `demoPrefix.topic_63`
584
-
- The first schema has record name `demo.User`, so the subject is `demoPrefix.topic_63-demo.User`
585
-
- The second schema has record name `demo.Car`, so the subject is `demoPrefix.topic_63-demo.Car`
586
-
- Both schemas are valid under the `TopicRecordNameStrategy` because they follow the `{topic}-{recordName}` pattern
587
-
588
-
##### Validation
589
-
590
-
When a schema is deployed, Ns4Kafka validates that the subject name follows at least one of the configured naming strategies for the namespace. If the subject name doesn't match any of the allowed strategies, the schema deployment will be rejected.
591
-
592
-
The validation process:
593
-
1. Extracts the record name from AVRO schema content (if applicable)
594
-
2. Checks if the subject name matches any of the configured strategies
595
-
3. For `TOPIC_RECORD_NAME` and `RECORD_NAME` strategies, validates that the record name exists in the schema
596
-
4. Accepts the schema if it matches at least one valid strategy
0 commit comments