CachedClient provides schema management with caching for efficient reuse. It retrieves and parses Avro, Protobuf, and JSON schemas from a Schema Registry, utilizing in-memory caches to minimize redundant fetches and compilations.
| 44 | // It retrieves and parses Avro, Protobuf, and JSON schemas from a Schema Registry, |
| 45 | // utilizing in-memory caches to minimize redundant fetches and compilations. |
| 46 | type CachedClient struct { |
| 47 | schemaClientFactory schema.ClientFactory |
| 48 | // cacheNamespace returns a unique tenant identifier for resource cache isolation. |
| 49 | // Used to generate cache keys like "{namespace}/avro-parsed-schemas/ids/{id}" for |
| 50 | // multi-tenant environments where compiled schemas must be isolated per tenant. |
| 51 | cacheNamespace func(context.Context) (string, error) |
| 52 | |
| 53 | standardImportsResolver func(protocompile.Resolver) protocompile.Resolver |
| 54 | |
| 55 | schemaCache *cache.Cache[string, sr.Schema] |
| 56 | subjectSchemaCache *cache.Cache[string, sr.SubjectSchema] |
| 57 | |
| 58 | avroSchemaCache *cache.Cache[string, *avro.Schema] |
| 59 | protoSchemaCache *cache.Cache[string, linker.Files] |
| 60 | jsonSchemaCache *cache.Cache[string, *jsonschema.Schema] |
| 61 | } |
| 62 | |
| 63 | // Client defines the interface for a schema client implementation. |
| 64 | type Client interface { |
nothing calls this directly
no outgoing calls
no test coverage detected