riferrei / srclient

Golang Client for Schema Registry
Apache License 2.0
235 stars 70 forks source link

Allow caching codec #41

Closed shiyao-afterpay closed 3 years ago

shiyao-afterpay commented 3 years ago

It seems schema can be cached, but not the corresponding codec.

AtakanColak commented 3 years ago

Hiya, by default codec caching is false, you can set it to enabled, please elaborate if this does not solve your issue.

shiyao-afterpay commented 3 years ago

Did you mean enabled at goavro or at ?

I can see new codec are created every time: https://github.com/riferrei/srclient/blob/master/schemaRegistryClient.go#L159

AtakanColak commented 3 years ago

If schema is already cached and schema caching is enabled, result will be returned at https://github.com/riferrei/srclient/blob/7be54965ba084e38873753d4faac0d4c1aad4540/schemaRegistryClient.go#L144

If schema is not cached, and schema caching is enabled, it will be cached at https://github.com/riferrei/srclient/blob/7be54965ba084e38873753d4faac0d4c1aad4540/schemaRegistryClient.go#L173

Before schema is cached, if codec creation is enabled, it will be created at https://github.com/riferrei/srclient/blob/7be54965ba084e38873753d4faac0d4c1aad4540/schemaRegistryClient.go#L160 and then added to the schema at https://github.com/riferrei/srclient/blob/7be54965ba084e38873753d4faac0d4c1aad4540/schemaRegistryClient.go#L168 which will ensure codec pointer is part of the schema before it is cached, so the codec is also created once. I'm closing this issue unless there is something else.

shiyao-afterpay commented 3 years ago

You are right. Missed that Schema has a Codec field. So Codec is also cached.