Skip to content

Commit cd95e33

Browse files
committed
refactor in prep for adding async
1 parent 2dd7b99 commit cd95e33

25 files changed

+5715
-5262
lines changed

src/confluent_kafka/schema_registry/__init__.py

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@
3131
Schema,
3232
SchemaRegistryClient,
3333
SchemaRegistryError,
34+
AsyncSchemaRegistryClient,
3435
SchemaReference,
3536
ServerConfig
3637
)
3738

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

4047
__all__ = [
4148
"ConfigCompatibilityLevel",
@@ -50,66 +57,11 @@
5057
"RuleSet",
5158
"Schema",
5259
"SchemaRegistryClient",
60+
"AsyncSchemaRegistryClient"
5361
"SchemaRegistryError",
5462
"SchemaReference",
5563
"ServerConfig",
5664
"topic_subject_name_strategy",
5765
"topic_record_subject_name_strategy",
5866
"record_subject_name_strategy"
5967
]
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+
#

0 commit comments

Comments
 (0)