Skip to content

Commit

Permalink
fix: update schema registry cache after deleting subject (#1825)
Browse files Browse the repository at this point in the history
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
  • Loading branch information
0xn4utilus authored Oct 2, 2024
1 parent c8a8b47 commit c83d3da
Showing 1 changed file with 23 additions and 1 deletion.
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

0 comments on commit c83d3da

Please sign in to comment.