// Process builds a list of packages from the boson file
168630
func (d *Docker) Register(bus *evbus.EventBus, context *context.Context) { //returns args and volumes to mount

	client, _ := NewClient("unix:///var/run/docker.sock")

	bus.Subscribe("artemide:start", Start) //Subscribing to artemide:start, Hello will be called
	bus.Subscribe("artemide:source:docker", client.Unpack)

}
356628
func (t *trg) process(n interface{}) (evn []event) {
	t.Lock()
	w, ge, err := t.t.Watched(n)
	if err != nil {
		t.Unlock()
		dbgprintf("trg: %v event lookup failed: %q", Event(ge), err)
		return
	}

	e := decode(ge, w.eDir|w.eNonDir)
	if ge&int64(not2nat[Remove]|not2nat[Rename]) == 0 {
		switch fi, err := os.Stat(w.p); {
		case err != nil:
		default:
			if err = t.t.Watch(fi, w, encode(w.eDir|w.eNonDir, fi.IsDir())); err != nil {
				dbgprintf("trg: %q is no longer watched: %q", w.p, err)
				t.t.Del(w)
			}
		}
	}
	if e == Event(0) && (!w.fi.IsDir() || (ge&int64(not2nat[Write])) == 0) {
		t.Unlock()
		return
	}

	if w.fi.IsDir() {
		evn = append(evn, t.dir(w, n, e, Event(ge))...)
	} else {
		evn = append(evn, t.file(w, n, e)...)
	}
	if Event(ge)&(not2nat[Remove]|not2nat[Rename]) != 0 {
		t.t.Del(w)
	}
	t.Unlock()
	return
}
1318632
func (f *auto_complete_file) process_data(data []byte) {
	cur, filedata, block := rip_off_decl(data, f.cursor)
	file, err := parser.ParseFile(f.fset, "", filedata, parser.AllErrors)
	if err != nil && *g_debug {
		log_parse_error("Error parsing input file (outer block)", err)
	}
	f.package_name = package_name(file)

	f.decls = make(map[string]*decl)
	f.packages = collect_package_imports(f.name, file.Decls, f.context)
	f.filescope = new_scope(nil)
	f.scope = f.filescope

	for _, d := range file.Decls {
		anonymify_ast(d, 0, f.filescope)
	}

	// process all top-level declarations
	for _, decl := range file.Decls {
		append_to_top_decls(f.decls, decl, f.scope)
	}
	if block != nil {
		// process local function as top-level declaration
		decls, err := parse_decl_list(f.fset, block)
		if err != nil && *g_debug {
			log_parse_error("Error parsing input file (inner block)", err)
		}

		for _, d := range decls {
			anonymify_ast(d, 0, f.filescope)
		}

		for _, decl := range decls {
			append_to_top_decls(f.decls, decl, f.scope)
		}

		// process function internals
		f.cursor = cur
		for _, decl := range decls {
			f.process_decl_locals(decl)
		}
	}

}
1251744
func (c *CoreScheduler) Process(eval *structs.Evaluation) error {
	switch eval.JobID {
	case structs.CoreJobEvalGC:
		return c.evalGC(eval)
	case structs.CoreJobNodeGC:
		return c.nodeGC(eval)
	case structs.CoreJobJobGC:
		return c.jobGC(eval)
	case structs.CoreJobDeploymentGC:
		return c.deploymentGC(eval)
	case structs.CoreJobForceGC:
		return c.forceGC(eval)
	default:
		return fmt.Errorf("core scheduler cannot handle job '%s'", eval.JobID)
	}
}
472066
func process(workload Workload, result *Result) (err error) {

	c := make(chan int, len(workload.Requests))
	result.Responses = make([]Response, len(workload.Requests))

	for index, _ := range workload.Requests {

		if workload.UseHeaders {
			replaceHeaderValues(&workload.Requests[index].Header, &workload.header)
		}

		if workload.StrictOrder {
			syncRequest(&workload.Requests[index], &result.Responses[index])
		} else {
			go asyncRequest(&workload.Requests[index], &result.Responses[index], c)
		}
	}

	// if async, wait for our responses or timeout
	if !workload.StrictOrder {

		// create a timeout so we don't wait forever
		var timeout <-chan time.Time

		if workload.Timeout > 0 {
			timeout = time.After(time.Duration(workload.Timeout))
		} else {
			timeout = time.After(DefaultTimeout)
		}

		for index := 0; index < len(workload.Requests); index++ {
			select {
			case <-c:
			case <-timeout:
				log.Warn("[process] Timed out waiting for all go routines to complete")
				break
			}
		}
	}
	return
}
271893
func (c *Container) ExecdProcesses() (o []rproc.Process) {
	c.mu.Lock()
	defer c.mu.Unlock()
	for _, p := range c.processes {
		o = append(o, p)
	}
	return o
}
261324
func process(h *handler, in nativemessaging.JSONDecoder, out nativemessaging.JSONEncoder) error {
	var resp Response
	var req Request

	// If input fails to parse, we can't guarantee future inputs will
	// get into a parseable state so we abort after sending an error
	// response.
	abortErr := in.Decode(&req)

	var err error
	if abortErr == nil {
		resp.Result, err = h.Handle(&req)
	}

	if err == io.EOF {
		// Closed
		return err
	} else if err != nil {
		resp.Status = "error"
		resp.Message = err.Error()
	} else {
		// Success
		resp.Status = "ok"
	}
	resp.Client = req.Client

	err = out.Encode(resp)
	if err != nil {
		// TODO: Log this somewhere?
		fmt.Fprintf(os.Stderr, "error: %s", err)
		os.Exit(1)
	}

	return abortErr
}
100043
func list(env Env, template, pkg string) ([]string, error) {
	if env == nil {
		env = getEnv()
	}

	lst, err := runProgram(env, 60*time.Second, "go", "list", "-f", template, pkg)
	if err != nil {
		return nil, err
	}

	return strings.Split(strings.Trim(string(lst), "\n"), "\n"), nil
}
926066
func (c *ConfigPolicyNode) Process(m map[string]ctypes.ConfigValue) (*map[string]ctypes.ConfigValue, *ProcessingErrors) {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	pErrors := NewProcessingErrors()
	// Loop through each rule and process
	for key, rule := range c.rules {
		// items exists for rule
		if cv, ok := m[key]; ok {
			// Validate versus matching data
			e := rule.Validate(cv)
			if e != nil {
				pErrors.AddError(e)
			}
		} else {
			// If it was required add error
			if rule.Required() {
				e := fmt.Errorf("required key missing (%s)", key)
				pErrors.AddError(e)
			} else {
				// If default returns we should add it
				cv := rule.Default()
				if cv != nil {
					m[key] = cv
				}

			}
		}
	}

	if pErrors.HasErrors() {
		return nil, pErrors
	}
	return &m, pErrors
}
1174346
func process(dst interface{}, src interface{}, args ...Options) error {
	var (
		options        = Options{}
		srcValue       = reflect.Indirect(reflect.ValueOf(src))
		dstValue       = reflect.Indirect(reflect.ValueOf(dst))
		srcFieldNames  = getFieldNames(src)
		srcMethodNames = getMethodNames(src)
	)

	if len(args) > 0 {
		options = args[0]
	}

	if !dstValue.CanAddr() {
		return fmt.Errorf("destination %+v is unaddressable", dstValue.Interface())
	}

	for _, f := range srcFieldNames {
		var (
			srcFieldValue               = srcValue.FieldByName(f)
			srcFieldType, srcFieldFound = srcValue.Type().FieldByName(f)
			srcFieldName                = srcFieldType.Name
			dstFieldName                = srcFieldName
			tagOptions                  TagOptions
		)

		if !srcFieldFound {
			continue
		}

		if options.Reversed {
			tagOptions = getTagOptions(srcFieldType.Tag.Get(TagName))
			if v, ok := tagOptions[FieldOptionName]; ok && v != "" {
				dstFieldName = v
			}
		} else {
			if name, opts := getRelatedField(dst, srcFieldName); name != "" {
				dstFieldName, tagOptions = name, opts
			}
		}

		if _, ok := tagOptions[SkipOptionName]; ok {
			continue
		}

		var (
			dstFieldType, dstFieldFound = dstValue.Type().FieldByName(dstFieldName)
			dstFieldValue               = dstValue.FieldByName(dstFieldName)
		)

		if !dstFieldFound {
			continue
		}

		// Force option for empty interfaces and nullable types
		_, force := tagOptions[ForceOptionName]

		// Valuer -> ptr
		if isNullableType(srcFieldType.Type) && dstFieldValue.Kind() == reflect.Ptr && force {
			// We have same nullable type on both sides
			if srcFieldValue.Type().AssignableTo(dstFieldType.Type) {
				dstFieldValue.Set(srcFieldValue)
				continue
			}

			v, _ := srcFieldValue.Interface().(driver.Valuer).Value()
			if v == nil {
				continue
			}

			valueType := reflect.TypeOf(v)

			ptr := reflect.New(valueType)
			ptr.Elem().Set(reflect.ValueOf(v))

			if valueType.AssignableTo(dstFieldType.Type.Elem()) {
				dstFieldValue.Set(ptr)
			}

			continue
		}

		// Valuer -> value
		if isNullableType(srcFieldType.Type) {
			// We have same nullable type on both sides
			if srcFieldValue.Type().AssignableTo(dstFieldType.Type) {
				dstFieldValue.Set(srcFieldValue)
				continue
			}

			if force {
				v, _ := srcFieldValue.Interface().(driver.Valuer).Value()
				if v == nil {
					continue
				}

				rv := reflect.ValueOf(v)
				if rv.Type().AssignableTo(dstFieldType.Type) {
					dstFieldValue.Set(rv)
				}
			}

			continue
		}

		if dstFieldValue.Kind() == reflect.Interface {
			if force {
				dstFieldValue.Set(srcFieldValue)
			}
			continue
		}

		// Ptr -> Value
		if srcFieldType.Type.Kind() == reflect.Ptr && !srcFieldValue.IsNil() && dstFieldType.Type.Kind() != reflect.Ptr {
			indirect := reflect.Indirect(srcFieldValue)

			if indirect.Type().AssignableTo(dstFieldType.Type) {
				dstFieldValue.Set(indirect)
				continue
			}
		}

		// Other types
		if srcFieldType.Type.AssignableTo(dstFieldType.Type) {
			dstFieldValue.Set(srcFieldValue)
		}
	}

	for _, m := range srcMethodNames {
		name, opts := getRelatedField(dst, m)
		if name == "" {
			continue
		}

		if _, ok := opts[SkipOptionName]; ok {
			continue
		}

		method := reflect.ValueOf(src).MethodByName(m)
		if !method.IsValid() {
			return fmt.Errorf("method %s is invalid", m)
		}

		var (
			dstFieldType, _ = dstValue.Type().FieldByName(name)
			dstFieldValue   = dstValue.FieldByName(name)
			_, withContext  = opts[ContextOptionName]
			_, force        = opts[ForceOptionName]
		)

		args := []reflect.Value{}
		if withContext {
			args = []reflect.Value{reflect.ValueOf(options.Context)}
		}

		var (
			result          = method.Call(args)[0]
			resultInterface = result.Interface()
			resultValue     = reflect.ValueOf(resultInterface)
			resultType      = resultValue.Type()
		)

		// Value -> Ptr
		if dstFieldValue.Kind() == reflect.Ptr && force {
			ptr := reflect.New(resultType)
			ptr.Elem().Set(resultValue)

			if ptr.Type().AssignableTo(dstFieldType.Type) {
				dstFieldValue.Set(ptr)
			}

			continue
		}

		// Ptr -> value
		if resultValue.Kind() == reflect.Ptr && force {
			if resultValue.Elem().Type().AssignableTo(dstFieldType.Type) {
				dstFieldValue.Set(resultValue.Elem())
			}

			continue
		}

		if resultType.AssignableTo(dstFieldType.Type) && result.IsValid() {
			dstFieldValue.Set(result)
		}
	}

	return nil
}
1149194
func run(program string) (*model.Package, error) {
	f, err := ioutil.TempFile("", "")
	if err != nil {
		return nil, err
	}

	filename := f.Name()
	defer os.Remove(filename)
	if err := f.Close(); err != nil {
		return nil, err
	}

	// Run the program.
	cmd := exec.Command(program, "-output", filename)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		return nil, err
	}

	f, err = os.Open(filename)
	if err != nil {
		return nil, err
	}

	// Process output.
	var pkg model.Package
	if err := gob.NewDecoder(f).Decode(&pkg); err != nil {
		return nil, err
	}

	if err := f.Close(); err != nil {
		return nil, err
	}

	return &pkg, nil
}
917654
func (prc ListProcessor) Process(nim image.Image, params imageserver.Params) (image.Image, error) {
	for _, p := range prc {
		var err error
		nim, err = p.Process(nim, params)
		if err != nil {
			return nil, err
		}
	}
	return nim, nil
}
867869
func (c ImportConverter) Process(r *Runner) error {
	fmt.Println("~~~ Rewriting Imports ~~~")

	err := filepath.Walk(".", c.processFile)
	if err != nil {
		return err
	}

	if _, err := os.Stat("Gopkg.toml"); err != nil {
		return nil
	}

	b, err := ioutil.ReadFile("Gopkg.toml")
	if err != nil {
		return err
	}

	for k := range c.Data {
		if bytes.Contains(b, []byte(k)) {
			r.Warnings = append(r.Warnings, fmt.Sprintf("Your Gopkg.toml contains the following import that need to be changed MANUALLY: %s", k))
		}
	}

	return nil
}
1150669
func (c *Container) Process(id string) (rproc.Process, error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	if id == "" {
		if c.process == nil {
			return nil, errors.Wrapf(errdefs.ErrFailedPrecondition, "container must be created")
		}
		return c.process, nil
	}
	p, ok := c.processes[id]
	if !ok {
		return nil, errors.Wrapf(errdefs.ErrNotFound, "process does not exist %s", id)
	}
	return p, nil
}
873690
func process(c net.Conn, handler Function, timeout int) {

	defer c.Close()

	b4 := make([]byte, 4)

	log.Println("starting Server.process: connection accepted")

	for {

		// Each message has a 4 byte header, an integer indicating the length:
		//
		//    message = LEN(uint32) BYTES
		//
		// Thus, first read 4 bytes (LEN)

		c.SetReadDeadline(time.Now().Add(time.Second * time.Duration(timeout)))
		i, err := c.Read(b4)

		if i == 0 {
			break
		}

		if err != nil || i != 4 {
			log.Println("ogdlrf.Serve, error while trying to read LEN,", i, err)
			break
		}

		l := int(binary.BigEndian.Uint32(b4))
		log.Println("ogdlrf.Serve, rec LEN", l)
		if l == 0 {
			log.Println("LEN is 0, timeout was", timeout)
			break
		}

		// Read the body of the message

		buf := make([]byte, l)
		if buf == nil {
			log.Println("ogdlrf.Serve, cannot allocate memory for message")
			break
		}
		i, err = c.Read(buf)

		if err != nil {
			log.Println("ogdlrf.Serve, error reading message body, ", err)
			break
		}

		if i != l {
			log.Println("ogdlrf.Serve, error reading message body, LEN is", i, "should be", l)
			break
		}

		g := ogdl.FromBinary(buf)
		if g == nil || g.Out == nil {
			log.Println("ogdlrf.Serve, nothing in buf to produce a graph")
			break
		}
		r := handler(c, g)

		// Write message back
		buf = r.Binary()
		binary.BigEndian.PutUint32(b4, uint32(len(buf)))

		i, err = c.Write(b4)

		if i != 4 || err != nil {
			log.Println("ogdlrf.Serve, error writing LEN header", i, err)
			break
		}

		i, err = c.Write(buf)

		if err != nil {
			log.Println("ogdlrf.Serve, error writing body,", err)
			break
		}
		if i != len(buf) {
			log.Println("ogdlrf.Serve, error writing body, LEN is", i, "should be", len(buf))
			break
		}
		log.Println("ogdlrf.Serve, body LEN", len(buf))
	}
	log.Println("ending Server.process and closing connection")
}
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, "")
}
1217518
func (f ProcessorFunc) Process(nim image.Image, params imageserver.Params) (image.Image, error) {
	return f(nim, params)
}