X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b3e5ea60bdecb41fbf954b67ab859dc4542d0c1a..8a27fe370239ecb8e50d53f46b45ed61203a35ca:/services/keepstore/pipe_adapters.go diff --git a/services/keepstore/pipe_adapters.go b/services/keepstore/pipe_adapters.go index 0b3999c196..6b555054b6 100644 --- a/services/keepstore/pipe_adapters.go +++ b/services/keepstore/pipe_adapters.go @@ -1,4 +1,8 @@ -package main +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +package keepstore import ( "bytes" @@ -10,10 +14,10 @@ import ( // getWithPipe invokes getter and copies the resulting data into // buf. If ctx is done before all data is copied, getWithPipe closes // the pipe with an error, and returns early with an error. -func getWithPipe(ctx context.Context, loc string, buf []byte, getter func(context.Context, string, io.Writer) error) (int, error) { +func getWithPipe(ctx context.Context, loc string, buf []byte, br BlockReader) (int, error) { piper, pipew := io.Pipe() go func() { - pipew.CloseWithError(getter(ctx, loc, pipew)) + pipew.CloseWithError(br.ReadBlock(ctx, loc, pipew)) }() done := make(chan struct{}) var size int @@ -35,11 +39,11 @@ func getWithPipe(ctx context.Context, loc string, buf []byte, getter func(contex } } -// putWithPipe invokes putter with a new pipe, and and copies data +// putWithPipe invokes putter with a new pipe, and copies data // from buf into the pipe. If ctx is done before all data is copied, // putWithPipe closes the pipe with an error, and returns early with // an error. -func putWithPipe(ctx context.Context, loc string, buf []byte, putter func(context.Context, string, io.Reader) error) error { +func putWithPipe(ctx context.Context, loc string, buf []byte, bw BlockWriter) error { piper, pipew := io.Pipe() copyErr := make(chan error) go func() { @@ -50,7 +54,7 @@ func putWithPipe(ctx context.Context, loc string, buf []byte, putter func(contex putErr := make(chan error, 1) go func() { - putErr <- putter(ctx, loc, piper) + putErr <- bw.WriteBlock(ctx, loc, piper) close(putErr) }()