// Run runs the headers behavior
505034
func Run(t crossdock.T) {
	t = createHeadersT(t)

	fatals := crossdock.Fatals(t)
	assert := crossdock.Assert(t)
	checks := crossdock.Checks(t)

	dispatcher := disp.Create(t)
	fatals.NoError(dispatcher.Start(), "could not start Dispatcher")
	defer dispatcher.Stop()

	var caller headerCaller
	encoding := t.Param(params.Encoding)
	switch encoding {
	case "raw":
		caller = rawCaller{raw.New(dispatcher.ClientConfig("yarpc-test"))}
	case "json":
		caller = jsonCaller{json.New(dispatcher.ClientConfig("yarpc-test"))}
	case "thrift":
		caller = thriftCaller{echoclient.New(dispatcher.ClientConfig("yarpc-test"))}
	default:
		fatals.Fail("", "unknown encoding %q", encoding)
	}

	token1 := random.String(10)
	token2 := random.String(10)

	tests := []struct {
		desc string
		give map[string]string
		want map[string]string
	}{
		{
			"valid headers",
			map[string]string{"token1": token1, "token2": token2},
			map[string]string{"token1": token1, "token2": token2},
		},
		{
			"non-string values",
			map[string]string{"token": "42"},
			map[string]string{"token": "42"},
		},
		{
			"empty strings",
			map[string]string{"token": ""},
			map[string]string{"token": ""},
		},
		{
			"no headers",
			nil,
			nil,
		},
		{
			"empty map",
			map[string]string{},
			map[string]string{},
		},
		{
			"varying casing",
			map[string]string{"ToKeN1": token1, "tOkEn2": token2},
			map[string]string{"token1": token1, "token2": token2},
		},
		{
			"http header conflict",
			map[string]string{"Rpc-Procedure": "does not exist"},
			map[string]string{"rpc-procedure": "does not exist"},
		},
		{
			"mixed case value",
			map[string]string{"token": "MIXED case Value"},
			map[string]string{"token": "MIXED case Value"},
		},
	}

	for _, tt := range tests {
		gotHeaders, err := caller.Call(tt.give)
		if checks.NoError(err, "%v: call failed", tt.desc) {
			internal.RemoveVariableMapKeys(gotHeaders)

			// assert.Equal doesn't work with nil maps
			if len(tt.want) == 0 {
				assert.Empty(gotHeaders, "%v: returns valid headers", tt.desc)
			} else {
				assert.Equal(tt.want, gotHeaders, "%v: returns valid headers", tt.desc)
			}
		}
	}
}
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)
	}
}
808622
func (m *Main) Run() error {
	src, err := NewSource(
		OptSrcBucket(m.Bucket),
		OptSrcPrefix(m.Prefix),
		OptSrcRegion(m.Region),
		OptSrcBufSize(1000),
		OptSrcSubjectAt(m.SubjectAt),
	)
	if err != nil {
		return errors.Wrap(err, "getting s3 source")
	}

	parser := pdk.NewDefaultGenericParser()
	if len(m.SubjectPath) == 0 && m.SubjectAt == "" {
		parser.Subjecter = pdk.BlankSubjecter{}
	} else if len(m.SubjectPath) == 0 && m.SubjectAt != "" {
		m.SubjectPath = []string{m.SubjectAt}
		parser.EntitySubjecter = pdk.SubjectPath(m.SubjectPath)
	} else {
		parser.EntitySubjecter = pdk.SubjectPath(m.SubjectPath)
	}

	mapper := pdk.NewCollapsingMapper()
	mapper.Framer = &m.Framer

	indexer, err := pdk.SetupPilosa(m.PilosaHosts, m.Index, nil, m.BatchSize)
	if err != nil {
		return errors.Wrap(err, "setting up Pilosa")
	}
	ingester := pdk.NewIngester(src, parser, mapper, indexer)

	go func() {
		err = pdk.StartMappingProxy(m.Proxy, pdk.NewPilosaForwarder(m.PilosaHosts[0], mapper.Translator))
		log.Fatal(errors.Wrap(err, "starting mapping proxy"))
	}()
	return errors.Wrap(ingester.Run(), "running ingester")
}
1174906
func (m *cloudResourceSyncManager) Run(stopCh <-chan struct{}) {
	wait.Until(m.syncNodeAddresses, m.syncPeriod, stopCh)
}
1203216
func (r *PluginRunner) Run(ctx context.Context, wrapper RunnerUtil, pluginSets map[int]plugin.PluginSet, hs plugin.HandshakeConfig, env []string, logger log.Logger) (*plugin.Client, error) {
	return r.runCommon(ctx, wrapper, pluginSets, hs, env, logger, false)
}
347648
func (c *enableCommand) Run(_ *cmd.Context) error {
	api, err := c.apiFunc(c)
	if err != nil {
		return errors.Annotate(err, "cannot connect to the API")
	}
	defer api.Close()

	return api.SwitchBlockOff(c.target)
}
559063
func (c *DeleteHostCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
	ctx := cli.GetContext(app, c, env)
	// TODO(smut): Validate required fields client-side.
	client := getClient(ctx)
	_, err := client.DeleteHost(ctx, &c.req)
	if err != nil {
		errors.Log(ctx, err)
		return 1
	}
	return 0
}
1150463
func (c *removeCommand) Run(ctx *cmd.Context) (err error) {
	client, err := getRemoveImageAPI(&c.CachedImagesCommandBase)
	if err != nil {
		return err
	}
	defer client.Close()

	return client.DeleteImage(c.Kind, c.Series, c.Arch)
}
239393
func (engine *Engine) Run(addr ...string) (err error) {
	defer func() { debugPrintError(err) }()

	address := resolveAddress(addr)
	debugPrint("Listening and serving HTTP on %s\n", address)
	err = http.ListenAndServe(address, engine)
	return
}
5204
func (mod *WebBee) Run(cin chan bees.Event) {
	mod.eventChan = cin

	srv := &http.Server{Addr: mod.addr, Handler: mod}
	l, err := net.Listen("tcp", mod.addr)
	if err != nil {
		mod.LogErrorf("Can't listen on %s", mod.addr)
		return
	}
	defer l.Close()

	go func() {
		err := srv.Serve(l)
		if err != nil {
			mod.LogErrorf("Server error: %v", err)
		}
		// Go 1.8+: srv.Close()
	}()

	select {
	case <-mod.SigChan:
		return
	}
}
719010
func (c *Client) Run(ctx context.Context, req *Request, resp interface{}) error {
	select {
	case <-ctx.Done():
		return ctx.Err()
	default:
	}
	if len(req.files) > 0 && !c.useMultipartForm {
		return errors.New("cannot send files with PostFields option")
	}
	if c.useMultipartForm {
		return c.runWithPostFields(ctx, req, resp)
	}
	return c.runWithJSON(ctx, req, resp)
}
829576
func Run(completeOptions completedServerRunOptions, stopCh <-chan struct{}) error {
	// To help debugging, immediately log version
	klog.Infof("Version: %+v", version.Get())

	server, err := CreateServerChain(completeOptions, stopCh)
	if err != nil {
		return err
	}

	return server.PrepareRun().Run(stopCh)
}
484180
func (m *Main) Run() error {
	if m.Seed == -1 {
		m.Seed = time.Now().UnixNano()
	}

	schema := gopilosa.NewSchema()
	idx := schema.Index(m.Index)
	idx.Field(m.Field, gopilosa.OptFieldTypeSet(gopilosa.CacheTypeRanked, 50000))
	indexer, err := pdk.SetupPilosa(m.PilosaHosts, m.Index, schema, m.BatchSize)
	if err != nil {
		return errors.Wrap(err, "setting up Pilosa")
	}

	ug := newUserGetter(m.Seed)

	for i := uint64(0); i < m.Num; i++ {
		indexer.AddColumn(m.Field, i, ug.ID())
	}

	return errors.Wrap(indexer.Close(), "closing indexer")
}
980534
func Run(engine *Engine, protocol string) (string, chan struct{}, chan struct{}) {
	// launch server
	server, err := transport.Launch(protocol + "://localhost:0")
	if err != nil {
		panic(err)
	}

	// prepare channels
	quit := make(chan struct{})
	done := make(chan struct{})

	// start accepting connections
	engine.Accept(server)

	// prepare shutdown
	go func() {
		// wait for signal
		<-quit

		// errors from close are ignored
		_ = server.Close()

		// close broker
		engine.Close()

		close(done)
	}()

	// get random port
	_, port, _ := net.SplitHostPort(server.Addr().String())

	return port, quit, done
}
1284378
func (c *unexposeCommand) Run(_ *cmd.Context) error {
	client, err := c.getAPI()
	if err != nil {
		return err
	}
	defer client.Close()
	return block.ProcessBlockedError(client.Unexpose(c.ApplicationName), block.BlockChange)
}
390151
func (m *Main) Run() (err error) {
	log.Printf("Running Main: %#v", m)
	var src pdk.Source
	if m.RegistryURL == "" {
		isrc := NewSource()
		isrc.Hosts = m.Hosts
		isrc.Topics = m.Topics
		isrc.Group = m.Group
		isrc.MaxMsgs = m.MaxRecords
		src = isrc
		if err := isrc.Open(); err != nil {
			return errors.Wrap(err, "opening kafka source")
		}
	} else {
		isrc := NewConfluentSource()
		isrc.Hosts = m.Hosts
		isrc.Topics = m.Topics
		isrc.Group = m.Group
		isrc.RegistryURL = m.RegistryURL
		isrc.MaxMsgs = m.MaxRecords
		src = isrc
		if err := isrc.Open(); err != nil {
			return errors.Wrap(err, "opening kafka source")
		}
	}

	if m.TranslatorDir == "" {
		m.TranslatorDir, err = ioutil.TempDir("", "pdk")
		if err != nil {
			return errors.Wrap(err, "creating temp directory")
		}
	}

	translateColumns := true
	parser := pdk.NewDefaultGenericParser()
	if len(m.SubjectPath) == 0 {
		parser.Subjecter = pdk.BlankSubjecter{}
		translateColumns = false
	} else {
		parser.EntitySubjecter = pdk.SubjectPath(m.SubjectPath)
	}

	mapper := pdk.NewCollapsingMapper()
	mapper.Translator, err = leveldb.NewTranslator(m.TranslatorDir)
	if err != nil {
		return errors.Wrap(err, "creating translator")
	}
	mapper.Framer = &m.Framer
	if translateColumns {
		log.Println("translating columns")
		mapper.ColTranslator, err = leveldb.NewFieldTranslator(m.TranslatorDir, "__columns")
		if err != nil {
			return errors.Wrap(err, "creating column translator")
		}
	} else {
		log.Println("not translating columns")
	}

	indexer, err := pdk.SetupPilosa(m.PilosaHosts, m.Index, nil, m.BatchSize)
	if err != nil {
		return errors.Wrap(err, "setting up Pilosa")
	}

	ingester := pdk.NewIngester(src, parser, mapper, indexer)
	if len(m.AllowedFields) > 0 {
		ingester.AllowedFields = make(map[string]bool)
		for _, fram := range m.AllowedFields {
			ingester.AllowedFields[fram] = true
		}
	}
	m.proxy = http.Server{
		Addr:    m.Proxy,
		Handler: pdk.NewPilosaForwarder(m.PilosaHosts[0], mapper.Translator, mapper.ColTranslator),
	}
	go func() {
		err := m.proxy.ListenAndServe()
		if err != nil {
			log.Printf("proxy closed: %v", err)
		}
	}()
	return errors.Wrap(ingester.Run(), "running ingester")
}
650559
func (e *Archive) Run(c *fi.Context) error {
	return fi.DefaultDeltaRunMethod(e, c)
}