MCPcopy
hub / github.com/grafana/tempo / readSeedFile

Method readSeedFile

pkg/usagestats/reporter.go:217–236  ·  view source on GitHub ↗

readSeedFile reads the cluster seed file from the object store.

(ctx context.Context)

Source from the content-addressed store, hash-verified

215
216// readSeedFile reads the cluster seed file from the object store.
217func (rep *Reporter) readSeedFile(ctx context.Context) (*ClusterSeed, error) {
218 reader, _, err := rep.reader.Read(ctx, backend.ClusterSeedFileName, backend.KeyPath{}, nil)
219 if err != nil {
220 return nil, err
221 }
222 defer func() {
223 if closeErr := reader.Close(); err != nil {
224 level.Error(rep.logger).Log("msg", "failed to close reader", "err", closeErr)
225 }
226 }()
227 data, err := io.ReadAll(reader)
228 if err != nil {
229 return nil, err
230 }
231 seed, err := JSONCodec.Decode(data)
232 if err != nil {
233 return nil, backend.ErrBadSeedFile
234 }
235 return seed.(*ClusterSeed), nil
236}
237
238// writeSeedFile writes the cluster seed to the object store.
239func (rep *Reporter) writeSeedFile(ctx context.Context, seed ClusterSeed) error {

Callers 1

fetchSeedMethod · 0.95

Calls 6

ReadMethod · 0.65
CloseMethod · 0.65
LogMethod · 0.65
ErrorMethod · 0.65
ReadAllMethod · 0.65
DecodeMethod · 0.65

Tested by

no test coverage detected