buildr/internal/rpc/v1/task_output_writer.go
Peter 34c431790e
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing
refactor: use connect-go instead of regular Google gRPC
- support binary name for plugins
- register plugins for container jobs
2023-09-12 18:43:34 +02:00

39 lines
784 B
Go

package v1
import (
"io"
remotev1 "code.icb4dc0.de/buildr/api/generated/remote/v1"
)
var _ io.Writer = (*taskOutputWriter)(nil)
func newTaskOutputWriter(source remotev1.TaskOutputSource, sender StreamSender[*remotev1.ExecutionServerMessage]) taskOutputWriter {
return taskOutputWriter{
source: source,
sender: sender,
}
}
type taskOutputWriter struct {
sender StreamSender[*remotev1.ExecutionServerMessage]
source remotev1.TaskOutputSource
}
func (t taskOutputWriter) Write(p []byte) (n int, err error) {
err = t.sender.Send(&remotev1.ExecutionServerMessage{
Envelope: &remotev1.ExecutionServerMessage_TaskOutput{
TaskOutput: &remotev1.TaskOutput{
Source: t.source,
Payload: p,
},
},
})
if err != nil {
return 0, err
}
return len(p), nil
}