avlizer icon indicating copy to clipboard operation
avlizer copied to clipboard

Fetch already published schemas by Subject and Version (or latest)

Open tak30 opened this issue 6 years ago • 4 comments

Sometimes there is a need to download an already published schema by Subject and Version. I didn't add the schemas to the local cache as, as far as I understand, in this use case the user of the library should be the one taking care of how to use the schema.

tak30 avatar Sep 11 '19 16:09 tak30

Hello,

Thanks for the PR, looks like this feature is missing. But perhaps it should be implemented as part of maybe_download/1 function.

Hello, thanks for reviewing! As far as I understand maybe_download/1 retrieves a decoded schema by either SchemaId or SubjectName and Fingerprint.

In my use case, as I didn't register the schema, I don't know the schemaId or the Fingerprint. I do believe that this use case is out of the main flow supported by this library so it should be an independent function, as it's just an extra. What do you think?

tak30 avatar Sep 12 '19 10:09 tak30

Why not cache it, if the caller of this new API can benefit from having it cached. e.g. so it can crash then restart without having to re-download.

The cache key is currently either regid() or {Subject, FP}. We can expand the cache key to support {Subject, Version} however, the current patterns are

-define(IS_REGID(Id), is_integer(Id)).
-define(IS_NAME_FP(NF), (is_tuple(Ref) andalso size(Ref) =:= 2)).
-define(IS_REF(Ref), (?IS_REGID(Ref) orelse ?IS_NAME_FP(Ref))).

I guess we'll have to add a tuple of size 3 for this new cache.

If you guys believe this flow should be part of the app then yes, let's make the proposed changes. I'll take care of it.

tak30 avatar Sep 12 '19 11:09 tak30

Sorry for late reply. zmstone is right about caching. Other interfaces of this library imply that caching is present, so it's good to keep everything consistent.

k32 avatar Sep 17 '19 18:09 k32

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Pablo López Viqueira seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Jan 21 '21 10:01 CLAassistant