MCPcopy
hub / github.com/redpanda-data/console / GetFileDescriptorSet

Method GetFileDescriptorSet

backend/pkg/bsr/client.go:142–166  ·  view source on GitHub ↗

GetFileDescriptorSet fetches the complete file descriptor set from BSR. This is used for the protojson resolver when marshaling to JSON. Returns linker.Files which has an AsResolver() method for protojson.

(ctx context.Context, messageName, commit string)

Source from the content-addressed store, hash-verified

140// This is used for the protojson resolver when marshaling to JSON.
141// Returns linker.Files which has an AsResolver() method for protojson.
142func (c *Client) GetFileDescriptorSet(ctx context.Context, messageName, commit string) (linker.Files, error) {
143 if messageName == "" {
144 return nil, errors.New("message name is empty")
145 }
146 if commit == "" {
147 return nil, errors.New("commit is empty")
148 }
149
150 key := cacheKey{messageName: messageName, commit: commit}
151
152 // Use cache.Get which handles cache lookup and only calls the function on cache miss
153 entry, err, _ := c.cache.Get(key.String(), func() (*bsrCacheEntry, error) {
154 // This function is only called on cache miss
155 files, desc, fetchErr := c.fetchFromBSR(ctx, messageName, commit)
156 if fetchErr != nil {
157 return nil, fetchErr
158 }
159 return &bsrCacheEntry{files: files, messageDesc: desc}, nil
160 })
161
162 if err != nil {
163 return nil, err
164 }
165 return entry.files, nil
166}
167
168// fetchFromBSR fetches the file descriptor set from BSR via the Connect API.
169func (c *Client) fetchFromBSR(ctx context.Context, messageName, commit string) (linker.Files, protoreflect.MessageDescriptor, error) {

Callers

nothing calls this directly

Implementers 1

CachedClientbackend/pkg/schema/client.go

Calls 2

StringMethod · 0.95
fetchFromBSRMethod · 0.95

Tested by

no test coverage detected