Skip to content

Commit

Permalink
(refactor) do not instantiate SchemaVersionManager in `KarapaceSche…
Browse files Browse the repository at this point in the history
…maRegistry`
  • Loading branch information
nosahama committed May 29, 2024
1 parent f83cd9d commit 702f142
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions karapace/schema_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def __init__(self, config: Config) -> None:
master_coordinator=self.mc,
database=self.database,
)
self.schema_version_manager = SchemaVersionManager()

self.schema_lock = asyncio.Lock()
self._master_lock = asyncio.Lock()
Expand Down Expand Up @@ -204,7 +203,7 @@ async def subject_version_delete_local(self, subject: Subject, version: Version,
for version_id, schema_version in schema_versions.items()
if schema_version.deleted is False
}
resolved_version = self.schema_version_manager.resolve_version(schema_versions=schema_versions, version=version)
resolved_version = SchemaVersionManager.resolve_version(schema_versions=schema_versions, version=version)
schema_version = schema_versions.get(resolved_version, None)

if not schema_version:
Expand Down Expand Up @@ -243,11 +242,11 @@ def subject_get(self, subject: Subject, include_deleted: bool = False) -> dict[R
return schemas

def subject_version_get(self, subject: Subject, version: Version, *, include_deleted: bool = False) -> JsonObject:
self.schema_version_manager.validate_version(version)
SchemaVersionManager.validate_version(version)
schema_versions = self.subject_get(subject, include_deleted=include_deleted)
if not schema_versions:
raise SubjectNotFoundException()
resolved_version = self.schema_version_manager.resolve_version(schema_versions=schema_versions, version=version)
resolved_version = SchemaVersionManager.resolve_version(schema_versions=schema_versions, version=version)
schema_data: SchemaVersion | None = schema_versions.get(resolved_version, None)

if not schema_data:
Expand Down Expand Up @@ -275,11 +274,11 @@ def subject_version_get(self, subject: Subject, version: Version, *, include_del
async def subject_version_referencedby_get(
self, subject: Subject, version: Version, *, include_deleted: bool = False
) -> list:
self.schema_version_manager.validate_version(version)
SchemaVersionManager.validate_version(version)
schema_versions = self.subject_get(subject, include_deleted=include_deleted)
if not schema_versions:
raise SubjectNotFoundException()
resolved_version = self.schema_version_manager.resolve_version(schema_versions=schema_versions, version=version)
resolved_version = SchemaVersionManager.resolve_version(schema_versions=schema_versions, version=version)
schema_data: SchemaVersion | None = schema_versions.get(resolved_version, None)
if not schema_data:
raise VersionNotFoundException()
Expand Down

0 comments on commit 702f142

Please sign in to comment.