Exemple #1
0
func NewProcess(
	id string,
	containerPath string,
	iodaemonBin string,
	runner command_runner.CommandRunner,
) *Process {
	return &Process{
		id: id,

		iodaemonBin:   iodaemonBin,
		containerPath: containerPath,
		runner:        runner,

		runningLink: &sync.Once{},

		linked: make(chan struct{}),

		exited: make(chan struct{}),

		stdin:  writer.NewFanIn(),
		stdout: writer.NewFanOut(),
		stderr: writer.NewFanOut(),
	}
}
Exemple #2
0
import (
	"errors"

	"github.com/cloudfoundry-incubator/guardian/rundmc/process_tracker/writer"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("FanOut", func() {
	var fanOut writer.FanOut
	var fWriter *fakeWriter
	var testBytes []byte

	BeforeEach(func() {
		fanOut = writer.NewFanOut()
		fWriter = &fakeWriter{
			nWriteReturn: 10,
		}
		testBytes = []byte{12}
	})

	It("writes data to a sink", func() {
		fanOut.AddSink(fWriter)
		n, err := fanOut.Write(testBytes)

		Expect(err).ToNot(HaveOccurred())
		Expect(n).To(Equal(1))

		Expect(fWriter.writeArgument()).To(Equal(testBytes))
		Expect(fWriter.writeCalls()).To(Equal(1))