From 259269482c9d98e800f44b9124cf33a9d43333db Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 3 Oct 2023 14:37:15 +0300 Subject: docs(tvix/nar-bridge): add more comments for DirectoriesUploader. Change-Id: I6684186f3120ea42036239baa82e0ca37d3e0e6c Reviewed-on: https://cl.tvl.fyi/c/depot/+/9531 Reviewed-by: Connor Brewster Autosubmit: flokli Tested-by: BuildkiteCI --- tvix/nar-bridge/pkg/server/directory_upload.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tvix') diff --git a/tvix/nar-bridge/pkg/server/directory_upload.go b/tvix/nar-bridge/pkg/server/directory_upload.go index e4a98f9075..ad04d2e389 100644 --- a/tvix/nar-bridge/pkg/server/directory_upload.go +++ b/tvix/nar-bridge/pkg/server/directory_upload.go @@ -9,6 +9,10 @@ import ( log "github.com/sirupsen/logrus" ) +// DirectoriesUploader opens a Put stream when it receives the first Put() call, +// and then uses the opened stream for subsequent Put() calls. +// When the uploading is finished, a call to Done() will close the stream and +// return the root digest returned from the directoryServiceClient. type DirectoriesUploader struct { ctx context.Context directoryServiceClient castorev1pb.DirectoryServiceClient @@ -49,7 +53,7 @@ func (du *DirectoriesUploader) Put(directory *castorev1pb.Directory) ([]byte, er return directoryDigest, nil } -// Done is called whenever we're +// Done closes the stream and returns the response. func (du *DirectoriesUploader) Done() (*castorev1pb.PutDirectoryResponse, error) { // only close once, and only if we opened. if du.directoryServicePutStream == nil { -- cgit 1.4.1