// WithInputStream sets a cli input stream.
494808
func WithInputStream(in io.ReadCloser) DockerCliOption {
	return func(cli *DockerCli) error {
		cli.in = streams.NewIn(in)
		return nil
	}
}
339377
func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) {
	return cc.NewStream(ctx, desc, method, opts...)
}
489570
func (d *kubeDockerClient) redirectResponseToOutputStream(tty bool, outputStream, errorStream io.Writer, resp io.Reader) error {
	if outputStream == nil {
		outputStream = ioutil.Discard
	}
	if errorStream == nil {
		errorStream = ioutil.Discard
	}
	var err error
	if tty {
		_, err = io.Copy(outputStream, resp)
	} else {
		_, err = dockerstdcopy.StdCopy(outputStream, errorStream, resp)
	}
	return err
}
1030011
func (c *Container) initStreams() error {
	if c.streams != nil {
		return nil
	}
	if !c.p.IsAlive() {
		c.Log(ERROR, "can not init stream to a non-existing sandbox")
		return errors.ErrPodNotAlive.WithArgs(c.p.Id())
	}
	c.Log(TRACE, "init io streams")
	c.streams = NewStreamConfig()
	c.streams.NewInputPipes()
	tty := &hypervisor.TtyIO{
		Stdin:  c.streams.Stdin(),
		Stdout: c.streams.Stdout(),
		Stderr: c.streams.Stderr(),
	}
	if err := c.p.sandbox.Attach(tty, c.Id()); err != nil {
		c.Log(ERROR, err)
		return err
	}
	return nil
}
1216597
func SetOutput(file *os.File) {
	writer := NewStandardOutput(file)
	runtime.Writers[0] = writer
}
811944
func idStream(stream string) string {
	idstream := ""
	if stream != "" && stream != ReleasedStream {
		idstream = "." + stream
	}
	return idstream
}
943679
func (wu *WaitUntil) WithInputPath(inputPath string) TransitionState {
	wu.inputPath = inputPath
	return wu
}
29136
func CompressStream(dest io.Writer, compression Compression) (io.WriteCloser, error) {
	switch compression {
	case Uncompressed:
		return &writeCloserWrapper{dest, nil}, nil
	case Gzip:
		return gzip.NewWriter(dest), nil
	default:
		return nil, fmt.Errorf("unsupported compression format %s", (&compression).Extension())
	}
}
1161327
func (builder *SecondaryIndexQueryCommandBuilder) WithStreaming(streaming bool) *SecondaryIndexQueryCommandBuilder {
	builder.protobuf.Stream = &streaming
	return builder
}
449796
func (this *engine) DirectHttpStream(w http.ResponseWriter, r *http.Request) (chan<- interface{}, error) {

	// Make sure that the writer supports flushing.
	f, ok := w.(http.Flusher)
	if !ok {
		return nil, errors.New("streaming-unsupported")
	}

	// Create a new channel, over which the broker can
	// send this client messages.
	messageChan := make(chan interface{})

	// Set the headers related to event streaming.
	w.Header().Set("Content-Type", "text/event-stream")
	w.Header().Set("Cache-Control", "no-cache")
	w.Header().Set("Connection", "keep-alive")

	go func() {
		for {
			// Read from our messageChan.
			msg, open := <-messageChan

			if !open || msg == nil {
				// If our messageChan was closed, this means that the client has
				// disconnected.
				glog.V(100).Infoln("Messages stopped.. Closing http connection")
				break
			}

			// by type switch
			switch t := msg.(type) {
			default:
				fmt.Fprintf(w, "event: %s\n", t)
				fmt.Fprint(w, "data: ")
				json_marshaler("application/json", w, &msg, no_header)
				fmt.Fprint(w, "\n\n")
			case string:
				fmt.Fprintf(w, "%s\n", msg.(string))
			case []byte:
				fmt.Fprintf(w, "%s\n", string(msg.([]byte)))
			}

			// Flush the response.  This is only possible if
			// the repsonse supports streaming.
			f.Flush()
		}
		// Done.
		glog.V(100).Infoln("Finished HTTP request at ", r.URL.Path)
	}()

	return messageChan, nil
}
1051843
func ParseGpgIndexStream(g *GlobalContext, stream io.Reader) (ki *GpgKeyIndex, w Warnings, err error) {
	eng := NewGpgIndexParser(g)
	ki, err = eng.Parse(stream)
	w = eng.warnings
	return
}
723670
func (q *Query) WithInput(input *ast.Term) *Query {
	q.input = input
	return q
}
368487
func (stream *Stream) WriteInt32(nval int32) {
	var val uint32
	if nval < 0 {
		val = uint32(-nval)
		stream.buf = append(stream.buf, '-')
	} else {
		val = uint32(nval)
	}
	stream.WriteUint32(val)
}
326763
func SetOutput(w io.Writer) {
	std.mu.Lock()
	defer std.mu.Unlock()
	std.SetOutput(w)
}
1290565
func (s *Session) incomingStream(id uint32) error {
	// Reject immediately if we are doing a go away
	if atomic.LoadInt32(&s.localGoAway) == 1 {
		hdr := header(make([]byte, headerSize))
		hdr.encode(typeWindowUpdate, flagRST, id, 0)
		return s.sendNoWait(hdr)
	}

	// Allocate a new stream
	stream := newStream(s, id, streamSYNReceived)

	s.streamLock.Lock()
	defer s.streamLock.Unlock()

	// Check if stream already exists
	if _, ok := s.streams[id]; ok {
		s.logger.Printf("[ERR] yamux: duplicate stream declared")
		if sendErr := s.sendNoWait(s.goAway(goAwayProtoErr)); sendErr != nil {
			s.logger.Printf("[WARN] yamux: failed to send go away: %v", sendErr)
		}
		return ErrDuplicateStream
	}

	// Register the stream
	s.streams[id] = stream

	// Check if we've exceeded the backlog
	select {
	case s.acceptCh <- stream:
		return nil
	default:
		// Backlog exceeded! RST the stream
		s.logger.Printf("[WARN] yamux: backlog exceeded, forcing connection reset")
		delete(s.streams, id)
		stream.sendHdr.encode(typeWindowUpdate, flagRST, id, 0)
		return s.sendNoWait(stream.sendHdr)
	}
}
309395
func (e *loginProvision) ppStream(m libkb.MetaContext) (ret *libkb.PassphraseStream, err error) {
	defer m.Trace("loginProvision#ppStream", func() error { return err })()
	if ret = m.PassphraseStream(); ret != nil {
		return ret, nil
	}
	if err = e.passphraseLogin(m); err != nil {
		return nil, err
	}
	if ret = m.PassphraseStream(); ret != nil {
		return ret, nil
	}
	return nil, errors.New("no passphrase available")
}
663888
func (c *Client) CreateStream(request CreateStream) error {
	err := c.kinesisReqNoResponse("CreateStream", request)
	return err
}