Skip to content
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

fix: update schema registry cache after deleting subject #1825

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/confluent_kafka/schema_registry/schema_registry_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,26 @@ def set(self, schema_id, schema, subject_name=None):
if subject_name is not None:
self.subject_schemas[subject_name].add(schema)

def remove_by_subject(self, subject_name):
"""
Remove a Schema from the cache.

Args:
subject_name (str): Subject name the schema is registered under.
"""


with self.lock:
if subject_name in self.subject_schemas:
for schema in self.subject_schemas[subject_name]:
schema_id = self.schema_index.get(schema, None)
if schema_id is not None:
self.schema_id_index.pop(schema_id, None)
self.schema_index.pop(Schema, None)

del self.subject_schemas[subject_name]


def get_schema(self, schema_id):
"""
Get the schema instance associated with schema_id from the cache.
Expand Down Expand Up @@ -546,7 +566,9 @@ def delete_subject(self, subject_name, permanent=False):
if permanent:
self._rest_client.delete('subjects/{}?permanent=true'
.format(_urlencode(subject_name)))


self._cache.remove_by_subject(subject_name)

return list

def get_latest_version(self, subject_name):
Expand Down