DirectWriteSession executes the provided callback in a DirectRepositoryWriter created for the purpose and flushes writes.
(ctx context.Context, r DirectRepository, opt WriteSessionOptions, cb func(ctx context.Context, dw DirectRepositoryWriter) error)
| 422 | |
| 423 | // DirectWriteSession executes the provided callback in a DirectRepositoryWriter created for the purpose and flushes writes. |
| 424 | func DirectWriteSession(ctx context.Context, r DirectRepository, opt WriteSessionOptions, cb func(ctx context.Context, dw DirectRepositoryWriter) error) error { |
| 425 | ctx, span := tracer.Start(ctx, "DirectWriteSession:"+opt.Purpose) |
| 426 | defer span.End() |
| 427 | |
| 428 | ctx, w, err := r.NewDirectWriter(ctx, opt) |
| 429 | if err != nil { |
| 430 | return errors.Wrap(err, "unable to create direct writer") |
| 431 | } |
| 432 | |
| 433 | return handleWriteSessionResult(ctx, w, opt, cb(ctx, w)) |
| 434 | } |
| 435 | |
| 436 | // replaceManifestsHelper is a helper that deletes all manifests matching provided labels and replaces them with the provided one. |
| 437 | func replaceManifestsHelper(ctx context.Context, rep RepositoryWriter, labels map[string]string, payload any) (manifest.ID, error) { |