// Process implements imageserver/image.Processor.
19807
func (prc *Processor) Process(nim image.Image, params imageserver.Params) (image.Image, error) {
	if !params.Has(param) {
		return nim, nil
	}
	params, err := params.GetParams(param)
	if err != nil {
		return nil, err
	}
	if params.Empty() {
		return nim, nil
	}
	nim, err = prc.process(nim, params)
	if err != nil {
		if err, ok := err.(*imageserver.ParamError); ok {
			err.Param = fmt.Sprintf("%s.%s", param, err.Param)
		}
		return nil, err
	}
	return nim, nil
}
1217518
func (f ProcessorFunc) Process(nim image.Image, params imageserver.Params) (image.Image, error) {
	return f(nim, params)
}
194677
func (f ProcessorFunc) Process(g *gif.GIF, params imageserver.Params) (*gif.GIF, error) {
	return f(g, params)
}
1161314
func (f *Fragmentation) Process(id uint32, first, last uint16, more bool, vv buffer.VectorisedView) (buffer.VectorisedView, bool) {
	f.mu.Lock()
	r, ok := f.reassemblers[id]
	if ok && r.tooOld(f.timeout) {
		// This is very likely to be an id-collision or someone performing a slow-rate attack.
		f.release(r)
		ok = false
	}
	if !ok {
		r = newReassembler(id)
		f.reassemblers[id] = r
		f.rList.PushFront(r)
	}
	f.mu.Unlock()

	res, done, consumed := r.process(first, last, more, vv)

	f.mu.Lock()
	f.size += consumed
	if done {
		f.release(r)
	}
	// Evict reassemblers if we are consuming more memory than highLimit until
	// we reach lowLimit.
	if f.size > f.highLimit {
		tail := f.rList.Back()
		for f.size > f.lowLimit && tail != nil {
			f.release(tail)
			tail = tail.Prev()
		}
	}
	f.mu.Unlock()
	return res, done
}
89791
func (g *Generator) Process(out io.Writer, validators ...*JSVal) error {
	ctx := genctx{
		pkgname:  "jsval",
		refnames: make(map[string]string),
		vname:    "V",
	}

	buf := bytes.Buffer{}

	// First get all of the references so we can refer to it later
	refs := map[string]Constraint{}
	refnames := []string{}
	valnames := []string{}
	for i, v := range validators {
		for rname, rc := range v.refs {
			if _, ok := refs[rname]; ok {
				continue
			}
			refs[rname] = rc
			refnames = append(refnames, rname)
		}

		if v.Name == "" {
			v.Name = fmt.Sprintf("V%d", i)
		}
		valnames = append(valnames, v.Name)
	}

	sort.Strings(valnames)
	for _, vname := range valnames {
		fmt.Fprintf(&buf, "\nvar %s *%s.JSVal", vname, ctx.pkgname)
	}

	ctx.refs = refs
	if len(refs) > 0 { // have refs
		ctx.cmname = "M"
		// sort them by reference name
		sort.Strings(refnames)
		fmt.Fprintf(&buf, "\nvar %s *%s.ConstraintMap", ctx.cmname, ctx.pkgname)

		// Generate reference constraint names
		for i, rname := range refnames {
			vname := fmt.Sprintf("R%d", i)
			ctx.refnames[rname] = vname
			fmt.Fprintf(&buf, "\nvar %s %s.Constraint", vname, ctx.pkgname)
		}
	}

	fmt.Fprintf(&buf, "\nfunc init() {")
	if len(refs) > 0 {
		fmt.Fprintf(&buf, "\n%s = &%s.ConstraintMap{}", ctx.cmname, ctx.pkgname)
		// Now generate code for references
		for _, rname := range refnames {
			fmt.Fprintf(&buf, "\n%s = ", ctx.refnames[rname])
			rbuf := bytes.Buffer{}
			if err := generateCode(&ctx, &rbuf, ctx.refs[rname]); err != nil {
				return err
			}
			// Remove indentation here
			rs := rbuf.String()
			for i, r := range rs {
				if !unicode.IsSpace(r) {
					rs = rs[i:]
					break
				}
			}
			fmt.Fprint(&buf, rs)
		}

		for _, rname := range refnames {
			fmt.Fprintf(&buf, "\n%s.SetReference(%s, %s)", ctx.cmname, strconv.Quote(rname), ctx.refnames[rname])
		}
	}

	// Now dump the validators
	sort.Sort(JSValSlice(validators))
	for _, v := range validators {
		fmt.Fprintf(&buf, "\n%s = ", v.Name)
		if err := generateCode(&ctx, &buf, v); err != nil {
			return err
		}
	}
	fmt.Fprintf(&buf, "\n}")

	fsrc, err := format.Source(buf.Bytes())
	if err != nil {
		os.Stderr.Write(buf.Bytes())
		return err
	}
	out.Write(fsrc)
	return nil
}
830830
func (hdr *Handler) Handle(im *imageserver.Image, params imageserver.Params) (*imageserver.Image, error) {
	if im.Format != "gif" {
		return nil, &imageserver.ImageError{Message: fmt.Sprintf("image format is not gif: %s", im.Format)}
	}
	if !hdr.Processor.Change(params) {
		return im, nil
	}
	g, err := gif.DecodeAll(bytes.NewReader(im.Data))
	if err != nil {
		return nil, &imageserver.ImageError{Message: err.Error()}
	}
	g, err = hdr.Processor.Process(g, params)
	if err != nil {
		return nil, err
	}
	buf := new(bytes.Buffer)
	err = gif.EncodeAll(buf, g)
	if err != nil {
		return nil, &imageserver.ImageError{Message: err.Error()}
	}
	im = &imageserver.Image{
		Format: "gif",
		Data:   buf.Bytes(),
	}
	return im, nil
}
213175
func (a *AMQPConsumer) process(ctx context.Context, msgs <-chan amqp.Delivery, ac telegraf.Accumulator) {
	a.deliveries = make(map[telegraf.TrackingID]amqp.Delivery)

	acc := ac.WithTracking(a.MaxUndeliveredMessages)
	sem := make(semaphore, a.MaxUndeliveredMessages)

	for {
		select {
		case <-ctx.Done():
			return
		case track := <-acc.Delivered():
			if a.onDelivery(track) {
				<-sem
			}
		case sem <- empty{}:
			select {
			case <-ctx.Done():
				return
			case track := <-acc.Delivered():
				if a.onDelivery(track) {
					<-sem
					<-sem
				}
			case d, ok := <-msgs:
				if !ok {
					return
				}
				err := a.onMessage(acc, d)
				if err != nil {
					acc.AddError(err)
					<-sem
				}
			}
		}
	}
}
1083962
func process1(c net.Conn, handler Function, timeout int) {

	defer c.Close()

	for {
		// Set a time out (maximum time until next message)
		c.SetReadDeadline(time.Now().Add(time.Second * time.Duration(timeout)))

		// Read the incoming object
		g := ogdl.FromBinaryReader(c)

		if g == nil {
			break
		}

		r := handler(c, g)

		// Write result in binary format
		b := r.Binary()
		i, err := c.Write(b)

		if err != nil {
			log.Println("ogdlrf.Serve, error writing body,", err)
			break
		}
		if i != len(b) {
			log.Println("ogdlrf.Serve, error writing body, LEN is", i, "should be", len(b))
		}
	}

	log.Println("ending Server.process and closing connection")
}
1309248
func (cniApp *cniAppInfo) processCmd() int {
	urlDict := map[string]string{cniapi.CniCmdAdd: cniApp.serverURL + cniapi.MesosNwIntfAdd,
		cniapi.CniCmdDel: cniApp.serverURL + cniapi.MesosNwIntfDel}

	jsonReq, err := json.Marshal(cniApp.cniMesosAttr)
	if err != nil {
		return cniApp.sendCniErrorResp("failed to convert Mesos attr. to JSON format :" + err.Error())
	}

	jsonBuf := bytes.NewBuffer(jsonReq)
	url := urlDict[cniApp.cniCmd]
	cniLog.Infof("process cni cmd: %s url: %s", cniApp.cniCmd, url)
	return cniApp.handleHTTP(url, jsonBuf)
}
1175689
func (p *Pss) process(pssmsg *PssMsg, raw bool, prox bool) error {
	metrics.GetOrRegisterCounter("pss.process", nil).Inc(1)

	var err error
	var recvmsg *whisper.ReceivedMessage
	var payload []byte
	var from PssAddress
	var asymmetric bool
	var keyid string
	var keyFunc func(envelope *whisper.Envelope) (*whisper.ReceivedMessage, string, PssAddress, error)

	envelope := pssmsg.Payload
	psstopic := Topic(envelope.Topic)

	if raw {
		payload = pssmsg.Payload.Data
	} else {
		if pssmsg.isSym() {
			keyFunc = p.processSym
		} else {
			asymmetric = true
			keyFunc = p.processAsym
		}

		recvmsg, keyid, from, err = keyFunc(envelope)
		if err != nil {
			return errors.New("Decryption failed")
		}
		payload = recvmsg.Payload
	}

	if len(pssmsg.To) < addressLength || prox {
		err = p.enqueue(pssmsg)
	}
	p.executeHandlers(psstopic, payload, from, raw, prox, asymmetric, keyid)
	return err
}
705280
func (l *Linode) Process() ([]*Response, error) {
	// Quickly handle the case where we have zero or one actions to perform.
	count := len(l.actions)
	if count == 0 {
		return nil, NewError(errors.New("linode: request must contain at least one action"))
	}
	defer l.Reset()
	if count == 1 {
		resp, err := l.Request(l.actions[0].parameters.Get(apiAction), l.actions[0].parameters, l.actions[0].result)
		if resp == nil {
			return nil, err
		}
		return []*Response{resp}, err
	}

	// Prepare the parameters.
	params := make([]Parameters, 0, len(l.actions))
	for _, action := range l.actions {
		params = append(params, action.parameters)
	}
	jsonParams, err := json.Marshal(params)
	if err != nil {
		return nil, NewError(err)
	}

	// Initialize the request.
	req, err := http.NewRequest("GET", l.apiEndpoint, nil)
	if err != nil {
		return nil, NewError(err)
	}
	query := Parameters{
		apiKey:          l.apiKey,
		apiAction:       "batch",
		apiRequestArray: string(jsonParams),
	}
	req.URL.RawQuery = query.Encode()

	// Do the request.
	resp, err := client.Do(req)
	if err != nil {
		return nil, NewError(err)
	}
	defer resp.Body.Close()

	// Decode the response.
	var response []*Response
	decoder := json.NewDecoder(resp.Body)
	if err = decoder.Decode(&response); err != nil {
		return nil, NewError(err)
	}

	// Decode the raw data into action-specific data.
	// FIXME: This whole block needs error handling, and I think since this
	// is handling multiple actions, it should probably handle errors on a
	// per-action basis.
	for index, action := range response {
		if l.actions[index].result == nil {
			continue
		}
		if err = json.Unmarshal(action.RawData, &l.actions[index].result); err != nil {
			continue
		}
		response[index].Data = l.actions[index].result
	}

	return response, nil
}
729970
func (o *ImageProcessOutput) Close() (err error) {
	if o.Body != nil {
		return o.Body.Close()
	}
	return
}
1047172
func (s *SystemScheduler) Process(eval *structs.Evaluation) error {
	// Store the evaluation
	s.eval = eval

	// Update our logger with the eval's information
	s.logger = s.logger.With("eval_id", eval.ID, "job_id", eval.JobID, "namespace", eval.Namespace)

	// Verify the evaluation trigger reason is understood
	switch eval.TriggeredBy {
	case structs.EvalTriggerJobRegister, structs.EvalTriggerNodeUpdate, structs.EvalTriggerFailedFollowUp,
		structs.EvalTriggerJobDeregister, structs.EvalTriggerRollingUpdate, structs.EvalTriggerPreemption,
		structs.EvalTriggerDeploymentWatcher, structs.EvalTriggerNodeDrain, structs.EvalTriggerAllocStop:
	default:
		desc := fmt.Sprintf("scheduler cannot handle '%s' evaluation reason",
			eval.TriggeredBy)
		return setStatus(s.logger, s.planner, s.eval, s.nextEval, nil, s.failedTGAllocs, structs.EvalStatusFailed, desc,
			s.queuedAllocs, "")
	}

	// Retry up to the maxSystemScheduleAttempts and reset if progress is made.
	progress := func() bool { return progressMade(s.planResult) }
	if err := retryMax(maxSystemScheduleAttempts, s.process, progress); err != nil {
		if statusErr, ok := err.(*SetStatusError); ok {
			return setStatus(s.logger, s.planner, s.eval, s.nextEval, nil, s.failedTGAllocs, statusErr.EvalStatus, err.Error(),
				s.queuedAllocs, "")
		}
		return err
	}

	// Update the status to complete
	return setStatus(s.logger, s.planner, s.eval, s.nextEval, nil, s.failedTGAllocs, structs.EvalStatusComplete, "",
		s.queuedAllocs, "")
}
1210991
func Process(file string) (*raml.APIDefinition, error) {
	routes, err := raml.ParseFile(file)
	if err != nil {
		return nil, fmt.Errorf("Failed parsing RAML file: %s\n", err.Error())
	}
	return routes, nil
}
1187486
func Process(out io.Writer, in io.Reader, opts ...Option) error {
	e := embedder{Fetcher: fetcher{}}
	for _, opt := range opts {
		opt.f(&e)
	}
	return process(out, in, e.runCommand)
}
713996
func NewProcess(addr string) *Process {
	p := &Process{
		addr:          addr,
		sequence:      make(map[string]map[string]int64),
		done:          make(map[string]bool),
		eventMut:      sync.NewMutex(),
		startComplete: make(chan struct{}),
		stopped:       make(chan struct{}),
	}
	return p
}
921299
func (b *backgroundLineLogger) Process() {
	b.logger.outputMutex.RLock()
	defer b.logger.outputMutex.RUnlock()

	for _, o := range b.logger.outputs {
		if o.Class&b.lineData.Class == b.lineData.Class {
			o.OutputWrapper.Output.Write(&b.lineData)
		}
	}
}