// Consume consumes the reader into the data parameter
322557
func (fn ConsumerFunc) Consume(reader io.Reader, data interface{}) error {
	return fn(reader, data)
}
355637
func (s *Reader) Read(p []byte) (int, error) {
	if s.limiter == nil {
		return s.r.Read(p)
	}
	n, err := s.r.Read(p)
	if err != nil {
		return n, err
	}
	if err := s.limiter.WaitN(s.ctx, n); err != nil {
		return n, err
	}
	return n, nil
}
953435
func (c *Client) Consume(arg crossmodel.ConsumeApplicationArgs) (string, error) {
	var consumeRes params.ErrorResults
	args := params.ConsumeApplicationArgs{
		Args: []params.ConsumeApplicationArg{{
			ApplicationOfferDetails: arg.Offer,
			ApplicationAlias:        arg.ApplicationAlias,
			Macaroon:                arg.Macaroon,
		}},
	}
	if arg.ControllerInfo != nil {
		args.Args[0].ControllerInfo = &params.ExternalControllerInfo{
			ControllerTag: arg.ControllerInfo.ControllerTag.String(),
			Alias:         arg.ControllerInfo.Alias,
			Addrs:         arg.ControllerInfo.Addrs,
			CACert:        arg.ControllerInfo.CACert,
		}
	}
	err := c.facade.FacadeCall("Consume", args, &consumeRes)
	if err != nil {
		return "", errors.Trace(err)
	}
	if resultLen := len(consumeRes.Results); resultLen != 1 {
		return "", errors.Errorf("expected 1 result, got %d", resultLen)
	}
	if err := consumeRes.Results[0].Error; err != nil {
		return "", errors.Trace(err)
	}
	localName := arg.Offer.OfferName
	if arg.ApplicationAlias != "" {
		localName = arg.ApplicationAlias
	}
	return localName, nil
}
637730
func (r *Reader) Read() (map[string]string, error) {
	rec := mapRecorder{records: make(map[string]string)}
	err := r.readRecord(&rec)
	if err != nil {
		return nil, err
	}
	return rec.records, nil
}
930685
func (cons *Profiler) Consume(workers *sync.WaitGroup) {
	cons.AddMainWorker(workers)

	go tgo.WithRecoverShutdown(cons.profile)
	cons.ControlLoop()
}
1184276
func (b *LookAheadBuffer) Consume(numBytes int) error {
	if numBytes == 0 {
		return nil
	}
	if numBytes < 0 {
		return errors.New("Cannot drop negative numBytes")
	}
	if b.bytesBuffered < numBytes {
		return errors.New("Consuming more bytes than bytes in buffer.")
	}

	copy(b.buffer, b.buffer[numBytes:b.bytesBuffered])
	b.bytesBuffered -= numBytes
	return nil
}
745461
func (ba *BlockAccumulator) Consume(ev *StreamEvent) *BlockExecution {
	switch {
	case ev.BeginBlock != nil:
		ba.block = &BlockExecution{
			Height: ev.BeginBlock.Height,
			Header: ev.BeginBlock.Header,
		}
	case ev.BeginTx != nil, ev.Envelope != nil, ev.Event != nil, ev.EndTx != nil:
		txe := ba.stack.Consume(ev)
		if txe != nil {
			ba.block.TxExecutions = append(ba.block.TxExecutions, txe)
		}
	case ev.EndBlock != nil:
		return ba.block
	}
	return nil
}
125827
func (c *component) Consume(path []string, isDir bool) ([]string, bool) {
	if len(path) == 0 {
		return path, false
	}

	head := path[0]
	for _, fn := range c.fns {
		var ok bool

		// Apply successively the component functions to make progress
		// matching the head.
		if head, ok = fn.Apply(head); !ok {
			// If any of the functions failed to match, there are
			// no other paths to match success, so return a failure
			// immediately.
			return path, false
		}
	}

	if len(head) > 0 {
		return append([]string{head}, path[1:]...), false
	}

	if len(path) == 1 {
		// Components can not match directories. If we were matching the
		// last path in a tree structure, we can only match if it
		// _wasn't_ a directory.
		return path[1:], true
	}

	return path[1:], true
}
166819
func (d *Decoder) read(p []byte) (n int, err error) {
	n, err = d.r.Read(p)
	if d.raw {
		d.buf = append(d.buf, p[:n]...)
	}
	d.n += n
	return
}
871216
func (b *Buffer) Consume(c int64) {
	if c == 0 {
		return
	}

	if c > b.size {
		panic(errors.New("consuming more data than available"))
	}
	b.size -= c

	for c > 0 {
		// Do we consume the entire chunk?
		if int64(b.first.length()-b.fidx) > c {
			// No. Advance our chunk index and terminate.
			b.fidx += int(c)
			break
		}

		n := b.first
		c -= int64(n.length() - b.fidx)
		b.first = n.next
		b.fidx = 0
		if b.first == nil {
			b.last = nil
		}

		// Release our node. We must not reference it after this.
		n.release()
	}
}
167007
func (t *timeoutReader) Read(p []byte) (int, error) {
	// FIXME limit the amount of data read in one chunk so as to not exceed the timeout?
	// Do the read in the background
	type result struct {
		n   int
		err error
	}
	done := make(chan result, 1)
	go func() {
		n, err := t.reader.Read(p)
		done <- result{n, err}
	}()
	// Wait for the read or the timeout
	timer := time.NewTimer(t.timeout)
	defer timer.Stop()
	select {
	case r := <-done:
		return r.n, r.err
	case <-timer.C:
		t.cancel()
		return 0, TimeoutError
	}
	panic("unreachable") // for Go 1.0
}
180148
func (p *Parser) consume(llk *LLk, st *semantic.Statement, s semantic.Symbol) (bool, error) {
	for _, clause := range (*p.grammar)[s] {
		if len(clause.Elements) == 0 {
			return true, nil
		}
		elem := clause.Elements[0]
		if elem.isSymbol {
			return false, fmt.Errorf("Parser.consume: not left factored grammar in %v", clause)
		}
		if llk.CanAccept(elem.Token()) {
			return p.expect(llk, st, s, clause)
		}
	}
	return false, fmt.Errorf("Parser.consume: could not consume token %s in production %s", llk.Current(), s)
}
748964
func (ar *Reader) Read(b []byte) (n int, err error) {
	if ar.nb == 0 {
		// file consumed
		return 0, io.EOF
	}

	if int64(len(b)) > ar.nb {
		b = b[0:ar.nb]
	}
	n, err = ar.r.Read(b)
	ar.nb -= int64(n)

	if err == io.EOF && ar.nb > 0 {
		err = io.ErrUnexpectedEOF
	}
	ar.err = err
	return
}
1084802
func (cons *Syslogd) Consume(workers *sync.WaitGroup) {
	server := syslog.NewServer()
	server.SetFormat(cons.format)
	server.SetHandler(cons)

	switch cons.protocol {
	case "unix":
		if err := server.ListenUnixgram(cons.address); err != nil {
			if errRemove := os.Remove(cons.address); errRemove != nil {
				cons.Logger.WithError(errRemove).Error("Failed to remove exisiting socket")
			} else {
				cons.Logger.Warning("Found existing socket ", cons.address, ". Removing.")
				err = server.ListenUnixgram(cons.address)
			}

			if err != nil {
				cons.Logger.WithError(err).Error("Failed to open unix://", cons.address)
			}
		}
	case "udp":
		if err := server.ListenUDP(cons.address); err != nil {
			cons.Logger.Error("Failed to open udp://", cons.address)
		}
	case "tcp":
		if err := server.ListenTCP(cons.address); err != nil {
			cons.Logger.Error("Failed to open tcp://", cons.address)
		}
	}

	server.Boot()
	defer server.Kill()

	cons.ControlLoop()
	server.Wait()
}
987917
func (u *udpTransport) consume() error {
	var b []byte
	for {
		select {
		case <-u.t.Dying():
			return nil
		case b = <-u.oldChan:
		case b = <-u.newChan:
		}

		u.send(b)
	}
}
846623
func (res *Response) Reader() (io.Reader, error) {
	enc, err := res.Encoding()
	if err != nil {
		return nil, err
	}
	return transform.NewReader(bytes.NewReader(res.Body), enc.NewDecoder()), nil
}
592078
func (r *multiReaderSeeker) Read(buf []byte) (int, error) {
	if r.index >= len(r.readers) {
		return 0, io.EOF
	}
	n, err := r.readers[r.index].Read(buf)
	if err == io.EOF {
		r.index++
		err = nil
	}
	return n, err
}