// start is a StartFunc for a Worker manifold.
488519
func (config ManifoldConfig) start(context dependency.Context) (worker.Worker, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Trace(err)
	}

	var agent agent.Agent
	if err := context.Get(config.AgentName, &agent); err != nil {
		return nil, errors.Trace(err)
	}
	var apiConn api.Connection
	if err := context.Get(config.APICallerName, &apiConn); err != nil {
		return nil, errors.Trace(err)
	}
	facade, err := config.NewRemoteRelationsFacade(apiConn)
	if err != nil {
		return nil, errors.Trace(err)
	}

	w, err := config.NewWorker(Config{
		ModelUUID:                agent.CurrentConfig().Model().Id(),
		RelationsFacade:          facade,
		NewRemoteModelFacadeFunc: remoteRelationsFacadeForModelFunc(config.NewControllerConnection),
		Clock:                    clock.WallClock,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return w, nil
}
246582
func Start() {
	connect()
	go startBatcher(commonBatchStream)

	for i := range registry {
		debug("starting", registry[i])
		go registry[i].StartLoop()
	}
}
705316
func (p *Process) Start(ctx context.Context) error {
	r, err := p.t.shim.Start(ctx, &shim.StartRequest{
		ID: p.id,
	})
	if err != nil {
		return errdefs.FromGRPC(err)
	}
	p.t.events.Publish(ctx, runtime.TaskExecStartedEventTopic, &eventstypes.TaskExecStarted{
		ContainerID: p.t.id,
		Pid:         r.Pid,
		ExecID:      p.id,
	})
	return nil
}
1162290
func (config ManifoldConfig) start(context dependency.Context) (worker.Worker, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Trace(err)
	}

	var apiCaller base.APICaller
	if err := context.Get(config.APICallerName, &apiCaller); err != nil {
		return nil, errors.Trace(err)
	}

	var broker caas.Broker
	if err := context.Get(config.BrokerName, &broker); err != nil {
		return nil, errors.Trace(err)
	}

	client := config.NewClient(apiCaller)
	w, err := config.NewWorker(Config{
		ControllerUUID:    config.ControllerUUID,
		ModelUUID:         config.ModelUUID,
		ApplicationGetter: client,
		LifeGetter:        client,
		ServiceExposer:    broker,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return w, nil
}
713062
func (s *schedulerWorkflow) Start(t *task) {
	workflowLogger.WithFields(log.Fields{
		"_block":    "workflow-start",
		"task-id":   t.id,
		"task-name": t.name,
	}).Debug("Starting workflow")
	s.state = WorkflowStarted
	j := newCollectorJob(s.metrics, t.deadlineDuration, t.metricsManager, t.workflow.configTree, t.id, s.tags)

	// dispatch 'collect' job to be worked
	// Block until the job has been either run or skipped.
	errors := t.manager.Work(j).Promise().Await()

	if len(errors) > 0 {
		t.RecordFailure(errors)
		event := new(scheduler_event.MetricCollectionFailedEvent)
		event.TaskID = t.id
		event.Errors = errors
		defer s.eventEmitter.Emit(event)
		return
	}

	// Send event
	event := new(scheduler_event.MetricCollectedEvent)
	event.TaskID = t.id
	event.Metrics = j.(*collectorJob).metrics
	defer s.eventEmitter.Emit(event)

	// walk through the tree and dispatch work
	workJobs(s.processNodes, s.publishNodes, t, j)
}
967778
func (p *process) Start(ctx context.Context) error {
	_, err := p.shim.task.Start(ctx, &task.StartRequest{
		ID:     p.shim.ID(),
		ExecID: p.id,
	})
	if err != nil {
		return errdefs.FromGRPC(err)
	}
	return nil
}
644735
func (worker *DbWorker) start() {
	worker.workInfo.Status(Start, worker)
	worker.ControlChannel <- func() (WorkerPhase, *DbWorker) { return Start, worker }
	for job := range worker.InputChannel {
		worker.invoke(job)
	}
	worker.workInfo.Status(Stop, worker)
	worker.ControlChannel <- func() (WorkerPhase, *DbWorker) { return Stop, worker }
	if worker.TimeoutChannel != nil {
		close(worker.TimeoutChannel)
	}
}
97251
func (f *asyncFlusher) start(numParallel int) {
	f.chunks = make(chan chunk)
	for i := 0; i < numParallel; i++ {
		f.wg.Add(1)
		go func() {
			defer f.wg.Done()
			f.uploaderLoop()
		}()
	}
}
157642
func (o *Once) Start(f func() error) error {
	if o.state.CAS(int32(Idle), int32(Starting)) {
		var err error
		if f != nil {
			err = f()
		}

		// skip forward to error state
		if err != nil {
			o.setError(err)
			o.state.Store(int32(Errored))
			close(o.stoppingCh)
			close(o.stopCh)
		} else {
			o.state.Store(int32(Running))
		}
		close(o.startCh)

		return err
	}

	<-o.startCh
	return o.loadError()
}
842262
func manifoldStart(
	apiCaller base.APICaller,
	newExternalControllerWatcherClient NewExternalControllerWatcherClientFunc,
) (worker.Worker, error) {
	client := externalcontrollerupdater.New(apiCaller)
	worker, err := New(
		client,
		newExternalControllerWatcherClient,
		clock.WallClock,
	)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return worker, nil
}
601926
func Manifold(config ManifoldConfig) dependency.Manifold {
	return dependency.Manifold{
		Inputs: []string{
			config.RaftName,
		},
		Start: config.start,
		Output: func(in worker.Worker, out interface{}) error {
			if w, ok := in.(wrappedWorker); ok {
				in = w.Worker
			}
			return engine.FlagOutput(in, out)
		},
	}
}
634626
func (r *runner) Start() {
	if !atomic.CompareAndSwapUint32(r.state, runnerIdle, runnerWorking) {
		// Already working. Cannot start.
		return
	}

	r.startFromWorking(atomic.LoadInt64(r.ts.now))
}
697545
func (reg *Manager) Start(ctx context.Context, wg *sync.WaitGroup) error {
	defer wg.Done()

	if reg.cfg.RegistrationCollective == "" {
		reg.cfg.RegistrationCollective = reg.cfg.MainCollective
	}

	var err error
	var registrator Registrator

	for _, rtype := range reg.cfg.Registration {
		switch rtype {
		case "":
			return nil
		case "file_content":
			registrator, err = registration.NewFileContent(reg.cfg, reg.log)
			if err != nil {
				return fmt.Errorf("Cannot start File Content Registrator: %s", err)
			}
		default:
			return fmt.Errorf("Unknown registration plugin: %s", reg.cfg.Registration)
		}

		reg.log.Infof("Starting registration worker for %s", rtype)
		reg.RegisterProvider(ctx, wg, registrator)
	}

	return nil
}
1340977
func (b *Driver) Start() (err error) {
	b.Init()

	// send commands
	go func() {
		for {
			packet := <-b.packetChannel
			err := b.write(packet)
			if err != nil {
				b.Publish(b.Event(Error), err)
			}
		}
	}()

	go func() {
		for {
			b.adaptor().ReadCharacteristic(responseCharacteristic)
			time.Sleep(100 * time.Millisecond)
		}
	}()

	b.ConfigureCollisionDetection(DefaultCollisionConfig())

	return
}
96226
func Start(f func(time.Duration) string) *Stopwatch {
	s := New(f)
	s.Start()

	return s
}
729602
func (w *worker) start() {
	for {
		select {
		case q := <-w.rcv:
			// assert that deadline is not exceeded
			if chrono.Chrono.Now().Before(q.Job().Deadline()) {
				q.Job().Run()
			} else {
				// the deadline was exceeded and this job will not run
				q.Job().AddErrors(errors.New("Worker refused to run overdue job."))
			}

			// mark the job complete
			q.Promise().Complete(q.Job().Errors())

		// the single kill-channel -- used when resizing worker pools
		case <-w.kamikaze:
			return

		//the broadcast that kills all workers
		case <-workerKillChan:
			return
		}
	}
}
206796
func Manifold(config ManifoldConfig) dependency.Manifold {
	return dependency.Manifold{
		Inputs: []string{
			config.APICallerName,
		},
		Start: func(context dependency.Context) (worker.Worker, error) {
			if err := config.Validate(); err != nil {
				return nil, errors.Trace(err)
			}
			var apiCaller base.APICaller
			if err := context.Get(config.APICallerName, &apiCaller); err != nil {
				return nil, err
			}
			return manifoldStart(apiCaller, config.NewExternalControllerWatcherClient)
		},
	}
}