Skip to content

Commit 4799d92

Browse files
committed
Refactor for async support
1 parent 2dd7b99 commit 4799d92

23 files changed

+5474
-5262
lines changed

src/confluent_kafka/schema_registry/__init__.py

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
ServerConfig
3636
)
3737

38-
_MAGIC_BYTE = 0
38+
from .common import (
39+
_MAGIC_BYTE,
40+
topic_subject_name_strategy,
41+
topic_record_subject_name_strategy,
42+
record_subject_name_strategy,
43+
reference_subject_name_strategy
44+
)
3945

4046
__all__ = [
4147
"ConfigCompatibilityLevel",
@@ -57,59 +63,3 @@
5763
"topic_record_subject_name_strategy",
5864
"record_subject_name_strategy"
5965
]
60-
61-
62-
def topic_subject_name_strategy(ctx, record_name: Optional[str]) -> Optional[str]:
63-
"""
64-
Constructs a subject name in the form of {topic}-key|value.
65-
66-
Args:
67-
ctx (SerializationContext): Metadata pertaining to the serialization
68-
operation.
69-
70-
record_name (Optional[str]): Record name.
71-
72-
"""
73-
return ctx.topic + "-" + ctx.field
74-
75-
76-
def topic_record_subject_name_strategy(ctx, record_name: Optional[str]) -> Optional[str]:
77-
"""
78-
Constructs a subject name in the form of {topic}-{record_name}.
79-
80-
Args:
81-
ctx (SerializationContext): Metadata pertaining to the serialization
82-
operation.
83-
84-
record_name (Optional[str]): Record name.
85-
86-
"""
87-
return ctx.topic + "-" + record_name if record_name is not None else None
88-
89-
90-
def record_subject_name_strategy(ctx, record_name: Optional[str]) -> Optional[str]:
91-
"""
92-
Constructs a subject name in the form of {record_name}.
93-
94-
Args:
95-
ctx (SerializationContext): Metadata pertaining to the serialization
96-
operation.
97-
98-
record_name (Optional[str]): Record name.
99-
100-
"""
101-
return record_name if record_name is not None else None
102-
103-
104-
def reference_subject_name_strategy(ctx, schema_ref: SchemaReference) -> Optional[str]:
105-
"""
106-
Constructs a subject reference name in the form of {reference name}.
107-
108-
Args:
109-
ctx (SerializationContext): Metadata pertaining to the serialization
110-
operation.
111-
112-
schema_ref (SchemaReference): SchemaReference instance.
113-
114-
"""
115-
return schema_ref.name if schema_ref is not None else None
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright 2020 Confluent Inc.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#

src/confluent_kafka/schema_registry/_sync/avro.py

Lines changed: 577 additions & 0 deletions
Large diffs are not rendered by default.

src/confluent_kafka/schema_registry/_sync/json_schema.py

Lines changed: 643 additions & 0 deletions
Large diffs are not rendered by default.

src/confluent_kafka/schema_registry/_sync/protobuf.py

Lines changed: 801 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)