Skip to content

Commit e3d601f

Browse files
author
javier.pardo
committed
Added get_schema_by_version method to the cached schema registry client
1 parent 5d13d5b commit e3d601f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

confluent_kafka/avro/cached_schema_registry_client.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ def get_by_id(self, schema_id):
276276
# bad schema - should not happen
277277
raise ClientError("Received bad schema (id %s) from registry: %s" % (schema_id, e))
278278

279-
def get_latest_schema(self, subject):
279+
280+
281+
282+
def get_schema_by_version(self, subject, version):
280283
"""
281284
GET /subjects/(string: subject)/versions/(versionId: version)
282285
@@ -291,7 +294,7 @@ def get_latest_schema(self, subject):
291294
:returns: (schema_id, schema, version)
292295
:rtype: (string, schema, int)
293296
"""
294-
url = '/'.join([self.url, 'subjects', subject, 'versions', 'latest'])
297+
url = '/'.join([self.url, 'subjects', subject, 'versions', version])
295298

296299
result, code = self._send_request(url)
297300
if code == 404:
@@ -315,6 +318,25 @@ def get_latest_schema(self, subject):
315318

316319
self._cache_schema(schema, schema_id, subject, version)
317320
return (schema_id, schema, version)
321+
322+
323+
def get_latest_schema(self, subject):
324+
"""
325+
GET /subjects/(string: subject)/versions/(versionId: version)
326+
327+
Return the latest 3-tuple of:
328+
(the schema id, the parsed avro schema, the schema version)
329+
for a particular subject.
330+
331+
This call always contacts the registry.
332+
333+
If the subject is not found, (None,None,None) is returned.
334+
:param str subject: subject name
335+
:returns: (schema_id, schema, version)
336+
:rtype: (string, schema, int)
337+
"""
338+
return self.get_schema_by_version(subject, 'latest')
339+
318340

319341
def get_version(self, subject, avro_schema):
320342
"""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy