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

Method WriteVersioned

tempodb/backend/gcs/gcs.go:397–424  ·  view source on GitHub ↗
(ctx context.Context, name string, keypath backend.KeyPath, data io.Reader, _ int64, version backend.Version)

Source from the content-addressed store, hash-verified

395}
396
397func (rw *readerWriter) WriteVersioned(ctx context.Context, name string, keypath backend.KeyPath, data io.Reader, _ int64, version backend.Version) (backend.Version, error) {
398 keypath = backend.KeyPathWithPrefix(keypath, rw.cfg.Prefix)
399 derivedCtx, span := tracer.Start(ctx, "gcs.WriteVersioned", trace.WithAttributes(
400 attribute.String("object", name),
401 ))
402 defer span.End()
403
404 preconditions, err := createPreconditions(version)
405 if err != nil {
406 return "", err
407 }
408
409 w := rw.writer(derivedCtx, backend.ObjectFileName(keypath, name), &preconditions)
410
411 _, err = io.Copy(w, data)
412 if err != nil {
413 w.Close()
414 span.SetStatus(codes.Error, "failed to write")
415 return "", fmt.Errorf("failed to write: %w", err)
416 }
417
418 err = w.Close()
419 if err != nil {
420 return "", err
421 }
422
423 return toVersion(w.Attrs().Generation), nil
424}
425
426func (rw *readerWriter) DeleteVersioned(ctx context.Context, name string, keypath backend.KeyPath, version backend.Version) error {
427 keypath = backend.KeyPathWithPrefix(keypath, rw.cfg.Prefix)

Callers

nothing calls this directly

Calls 8

writerMethod · 0.95
KeyPathWithPrefixFunction · 0.92
ObjectFileNameFunction · 0.92
createPreconditionsFunction · 0.85
toVersionFunction · 0.85
StartMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected