mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-07 16:55:15 -04:00
debugd: implement upload of multiple binaries
This commit is contained in:
parent
e6ac8e2a91
commit
6f56ed69f8
21 changed files with 2040 additions and 661 deletions
47
debugd/internal/filetransfer/chunkstream.go
Normal file
47
debugd/internal/filetransfer/chunkstream.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright (c) Edgeless Systems GmbH
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package filetransfer
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
pb "github.com/edgelesssys/constellation/v2/debugd/service"
|
||||
)
|
||||
|
||||
// recvChunkStream is a wrapper around a RecvFilesStream that only returns chunks.
|
||||
type recvChunkStream struct {
|
||||
stream RecvFilesStream
|
||||
}
|
||||
|
||||
// Recv receives a FileTransferMessage and returns the chunk.
|
||||
func (s *recvChunkStream) Recv() (*pb.Chunk, error) {
|
||||
msg, err := s.stream.Recv()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chunk := msg.GetChunk()
|
||||
if chunk == nil {
|
||||
return nil, errors.New("expected chunk")
|
||||
}
|
||||
return chunk, nil
|
||||
}
|
||||
|
||||
// sendChunkStream is a wrapper around a SendFilesStream that wraps chunks for every message.
|
||||
type sendChunkStream struct {
|
||||
stream SendFilesStream
|
||||
}
|
||||
|
||||
// Send wraps the given chunk in a FileTransferMessage and sends it.
|
||||
func (s *sendChunkStream) Send(chunk *pb.Chunk) error {
|
||||
chunkMessage := &pb.FileTransferMessage_Chunk{
|
||||
Chunk: chunk,
|
||||
}
|
||||
message := &pb.FileTransferMessage{
|
||||
Kind: chunkMessage,
|
||||
}
|
||||
return s.stream.Send(message)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue