// Run starts the oneway behavior, testing a combination of encodings and transports
495836
func Run(t crossdock.T) {
	callBackHandler, serverCalledBack := newCallBackHandler()
	dispatcher, callBackAddr := dispatcher.CreateOnewayDispatcher(t, callBackHandler)
	defer dispatcher.Stop()

	encoding := t.Param(params.Encoding)
	switch encoding {
	case "raw":
		Raw(t, dispatcher, serverCalledBack, callBackAddr)
	case "json":
		JSON(t, dispatcher, serverCalledBack, callBackAddr)
	case "thrift":
		Thrift(t, dispatcher, serverCalledBack, callBackAddr)
	case "protobuf":
		Protobuf(t, dispatcher, serverCalledBack, callBackAddr)
	default:
		crossdock.Fatals(t).Fail("unknown encoding", "%v", encoding)
	}
}
69419
func (u *DropsondeMarshaller) Run(inputChan <-chan *events.Envelope, outputChan chan<- []byte) {
	for message := range inputChan {

		messageBytes, err := proto.Marshal(message)
		if err != nil {
			u.logger.Errorf("dropsondeMarshaller: marshal error %v", err)
			metrics.BatchIncrementCounter("dropsondeMarshaller.marshalErrors")
			continue
		}

		u.incrementMessageCount(message.GetEventType())
		outputChan <- messageBytes
	}
}
1022634
func (m *Main) Run() (err error) {
	m.trans, err = newTranslator("ssdbmapping")
	if err != nil {
		return errors.Wrap(err, "getting new translator")
	}
	log.Println("setting up pilosa")
	schema, err := m.schema()
	if err != nil {
		return errors.Wrap(err, "describing schema")
	}
	m.index, err = pdk.SetupPilosa(m.Hosts, m.Index, schema, 1000000)
	if err != nil {
		return errors.Wrap(err, "setting up Pilosa")
	}

	log.Println("reading in edge tables.")
	custs, parts, supps, dates, err := m.setupEdgeTables()
	if err != nil {
		return errors.Wrap(err, "setting up edge tables")
	}

	log.Println("reading lineorder table.")
	rc := make(chan *record, m.RecordBuf) // TODO tweak for perf

	go func() {
		err := m.runReaders(rc, custs, parts, supps, dates)
		if err != nil {
			log.Println(errors.Wrap(err, "running readers"))
		}
		close(rc)
	}()

	log.Println("running mappers")
	err = m.runMappers(rc)
	if err != nil {
		return errors.Wrap(err, "running mappers")
	}

	log.Println("mappers finished - starting proxy")
	ph := pdk.NewPilosaForwarder("localhost:10101", m.trans)
	return pdk.StartMappingProxy("localhost:3456", ph)
}
299153
func (s *scheduler) run(sections chan uint64, dist chan *request, done chan []byte, quit chan struct{}, wg *sync.WaitGroup) {
	// Create a forwarder channel between requests and responses of the same size as
	// the distribution channel (since that will block the pipeline anyway).
	pend := make(chan uint64, cap(dist))

	// Start the pipeline schedulers to forward between user -> distributor -> user
	wg.Add(2)
	go s.scheduleRequests(sections, dist, pend, quit, wg)
	go s.scheduleDeliveries(pend, done, quit, wg)
}
872150
func (e *PGPKeyGen) Run(m libkb.MetaContext) error {

	// generate a new pgp key with defaults (and no push)
	var genArg libkb.PGPGenArg
	if e.genArg != nil {
		genArg = *e.genArg
	}
	genArg.Ids = libkb.ImportPGPIdentities(e.arg.CreateUids.Ids)
	arg := PGPKeyImportEngineArg{
		AllowMulti: true,
		OnlySave:   true,
		Gen:        &genArg,
	}
	eng := NewPGPKeyImportEngine(m.G(), arg)
	if err := RunEngine2(m, eng); err != nil {
		return err
	}

	// tell the UI about the key
	m.Debug("generated pgp key: %s", eng.bundle.GetFingerprint())
	pub, err := eng.bundle.Encode()
	if err != nil {
		return err
	}
	keyArg := keybase1.KeyGeneratedArg{
		Kid: eng.bundle.GetKID(),
		Key: keybase1.KeyInfo{
			Fingerprint: eng.bundle.GetFingerprint().String(),
			Key:         pub,
			Desc:        eng.bundle.VerboseDescription(),
		},
	}
	if err := m.UIs().PgpUI.KeyGenerated(m.Ctx(), keyArg); err != nil {
		return err
	}

	// ask if we should push private key to api server if user has a password
	hasRandomPw, err := libkb.LoadHasRandomPw(m, keybase1.LoadHasRandomPwArg{})
	if err != nil {
		return err
	}
	pushPrivate, err := m.UIs().PgpUI.ShouldPushPrivate(m.Ctx(), keybase1.ShouldPushPrivateArg{
		SessionID: m.UIs().SessionID,
		Prompt:    !hasRandomPw,
	})
	if err != nil {
		return err
	}

	m.Debug("push private generated pgp key to API server? %v", pushPrivate)
	if err := e.push(m, eng.bundle, pushPrivate); err != nil {
		return err
	}

	// tell ui everything finished
	return m.UIs().PgpUI.Finished(m.Ctx(), m.UIs().SessionID)
}
1320246
func (c *runner) Run(name string, arg ...string) error {
	return c.RunWithOptions(CommandOpts{}, name, arg...)
}
1085065
func (c *dumpCommand) Run(ctx *cmd.Context) error {
	client, err := c.getAPI()
	if err != nil {
		return err
	}
	defer client.Close()

	_, modelDetails, err := c.ModelCommandBase.ModelDetails()
	if err != nil {
		return errors.Annotate(err, "getting model details")
	}

	modelTag := names.NewModelTag(modelDetails.ModelUUID)
	results, err := client.DumpModel(modelTag, c.simplified)
	if err != nil {
		return err
	}

	return c.out.Write(ctx, results)
}
1116274
func (c *configCommand) Run(ctx *cmd.Context) error {
	client, err := c.getAPI()
	if err != nil {
		return err
	}
	defer client.Close()
	return c.action(client, ctx)
}
33630
func (c *ListCharmResourcesCommand) Run(ctx *cmd.Context) error {
	ctx.Warningf(DeprecatedSince)
	return c.baseRun(ctx)
}
1028518
func Run(cmd string, args ...string) error {
	return RunWith(nil, cmd, args...)
}
132335
func (c *Container) Run(ctx context.Context, configOverride *config.ServiceConfig) (int, error) {
	var (
		errCh       chan error
		out, stderr io.Writer
		in          io.ReadCloser
		inFd        uintptr
	)

	if configOverride.StdinOpen {
		in = os.Stdin
	}
	if configOverride.Tty {
		out = os.Stdout
		stderr = os.Stderr
	}

	options := types.ContainerAttachOptions{
		Stream: true,
		Stdin:  configOverride.StdinOpen,
		Stdout: configOverride.Tty,
		Stderr: configOverride.Tty,
	}

	resp, err := c.client.ContainerAttach(ctx, c.container.ID, options)
	if err != nil {
		return -1, err
	}

	if configOverride.StdinOpen {
		// set raw terminal
		inFd, _ = term.GetFdInfo(in)
		state, err := term.SetRawTerminal(inFd)
		if err != nil {
			return -1, err
		}
		// restore raw terminal
		defer term.RestoreTerminal(inFd, state)
	}

	// holdHijackedConnection (in goroutine)
	errCh = make(chan error, 1)
	go func() {
		errCh <- holdHijackedConnection(configOverride.Tty, in, out, stderr, resp)
	}()

	if err := c.client.ContainerStart(ctx, c.container.ID, types.ContainerStartOptions{}); err != nil {
		return -1, err
	}

	if configOverride.Tty {
		ws, err := term.GetWinsize(inFd)
		if err != nil {
			return -1, err
		}

		resizeOpts := types.ResizeOptions{
			Height: uint(ws.Height),
			Width:  uint(ws.Width),
		}

		if err := c.client.ContainerResize(ctx, c.container.ID, resizeOpts); err != nil {
			return -1, err
		}
	}

	if err := <-errCh; err != nil {
		logrus.Debugf("Error hijack: %s", err)
		return -1, err
	}

	exitedContainer, err := c.client.ContainerInspect(ctx, c.container.ID)
	if err != nil {
		return -1, err
	}

	return exitedContainer.State.ExitCode, nil
}
387867
func (o *Options) Run() error {
	defer close(o.errCh)
	if len(o.WriteConfigTo) > 0 {
		return o.writeConfigFile()
	}

	proxyServer, err := NewProxyServer(o)
	if err != nil {
		return err
	}

	if o.CleanupAndExit {
		return proxyServer.CleanupAndExit()
	}

	o.proxyServer = proxyServer
	return o.runLoop()
}
198515
func Run(w io.Writer, appArgs []string, ask prompt.Prompt) (help.HelpMessage, error) {
	r := &runner{}
	return r.run(w, appArgs, ask)
}
390972
func (a *adapter) Run() error {
	prompt()

	go func() {
		for {
			line, _, err := a.in.ReadLine()
			message := a.newMessage(string(line))

			if err != nil {
				if err == io.EOF {
					break
					// a.Robot.signalChan <- syscall.SIGTERM
				}
				fmt.Println("error:", err)
			}
			a.Receive(message)
			prompt()
		}
	}()

	<-a.quit
	return nil
}
1097416
func (Pipe) Run(ctx *context.Context) error {
	if ctx.SkipSign {
		return pipe.ErrSkipSignEnabled
	}

	switch ctx.Config.Sign.Artifacts {
	case "checksum":
		return sign(ctx, ctx.Artifacts.Filter(artifact.ByType(artifact.Checksum)).List())
	case "all":
		return sign(ctx, ctx.Artifacts.Filter(
			artifact.Or(
				artifact.ByType(artifact.UploadableArchive),
				artifact.ByType(artifact.UploadableBinary),
				artifact.ByType(artifact.Checksum),
				artifact.ByType(artifact.LinuxPackage),
			)).List())
	case "none":
		return pipe.ErrSkipSignEnabled
	default:
		return fmt.Errorf("invalid list of artifacts to sign: %s", ctx.Config.Sign.Artifacts)
	}
}
123687
func (s *Server) Run() {
	var err error

	addr := s.config.Get("server.host") + ":" + s.config.Get("server.port")
	log.Printf("Listening on address: %q", addr)

	s.net, err = net.Listen("tcp", addr)
	if err != nil {
		log.Fatal(err)
	}
	defer s.net.Close()

	// Start server ticker
	go s.doTick()

	for !s.working {
		// Wait for a connection.
		conn, err := s.net.Accept()
		if err != nil {
			log.Println(err)
		}

		// Handle the connection in a new goroutine.
		// Multiple connections may be served concurrently.
		go s.handle(conn)
	}
}
463141
func (mf Migration) Run(c *Connection) error {
	if mf.Runner == nil {
		return errors.Errorf("no runner defined for %s", mf.Path)
	}
	return mf.Runner(mf, c)
}