// Setup prepares the Requester for benchmarking.
771138
func (n *nsqRequester) Setup() error {
	config := nsq.NewConfig()
	producer, err := nsq.NewProducer(n.url, config)
	if err != nil {
		return err
	}
	consumer, err := nsq.NewConsumer(n.topic, n.channel, config)
	if err != nil {
		return err
	}
	n.msgChan = make(chan []byte)
	consumer.AddConcurrentHandlers(nsq.HandlerFunc(func(m *nsq.Message) error {
		m.Finish()
		n.msgChan <- m.Body
		return nil
	}), 1)
	if err := consumer.ConnectToNSQD(n.url); err != nil {
		producer.Stop()
		return err
	}
	n.producer = producer
	n.consumer = consumer
	n.msg = make([]byte, n.payloadSize)
	for i := 0; i < n.payloadSize; i++ {
		n.msg[i] = 'A' + uint8(rand.Intn(26))
	}
	return nil
}
197015
func setup(c *caddy.Controller) error {
	configs, err := gzipParse(c)
	if err != nil {
		return err
	}

	httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
		return Gzip{Next: next, Configs: configs}
	})

	return nil
}
495300
func (h *handler) SetUp() (watcher.StringsWatcher, error) {
	actions, err := h.config.Facade.RunningActions(h.config.MachineTag)
	if err != nil {
		return nil, errors.Trace(err)
	}
	// We try to cancel any running action before starting up so actions don't linger around
	// We *should* really have only one action coming up here if the execution is serial but
	// this is best effort anyway.
	for _, action := range actions {
		tag, err := names.ParseActionTag(action.Action.Tag)
		if err != nil {
			logger.Infof("tried to cancel action %s but failed with error %v", action.Action.Tag, err)
			continue
		}
		err = h.config.Facade.ActionFinish(tag, params.ActionFailed, nil, "action cancelled")
		if err != nil {
			logger.Infof("tried to cancel action %s but failed with error %v", action.Action.Tag, err)
		}
	}
	return h.config.Facade.WatchActionNotifications(h.config.MachineTag)
}
67889
func (f *flexVolumeMounter) SetUp(fsGroup *int64) error {
	return f.SetUpAt(f.GetPath(), fsGroup)
}
715421
func setup(c *caddy.Controller) error {
	var max int

	for c.Next() {
		val := c.Val()
		switch val {
		case "requestlimit":
			if !c.NextArg() {
				fmt.Println("Missing limit argument for requestlimit")
				return c.ArgErr()
			} else {
				val := c.Val()
				if val != "" {
					max64, err := strconv.ParseInt(c.Val(), 10, 32)
					if err != nil {
						msg := fmt.Sprintf("Cannot parse request limit value %s", val)
						return errors.New(msg)
					} else {
						max = int(max64)
						fmt.Printf("Setting up requestlimit with a limit of %d\n", max)
						break
					}
				}
			}
		default:
			return c.ArgErr()
		}
	}

	httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
		return RequestLimitHandler{Next: next, sem: make(chan int, max)}
	})

	return nil
}
506914
func setup(c *caddy.Controller) error {
	rules, err := statusParse(c)
	if err != nil {
		return err
	}

	cfg := httpserver.GetConfig(c)
	mid := func(next httpserver.Handler) httpserver.Handler {
		return Status{Rules: rules, Next: next}
	}
	cfg.AddMiddleware(mid)

	return nil
}
477002
func setup(c *caddy.Controller) error {
	configs, err := browseParse(c)
	if err != nil {
		return err
	}

	b := Browse{
		Configs:       configs,
		IgnoreIndexes: false,
	}

	httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
		b.Next = next
		return b
	})

	return nil
}
329070
func Setup(selectedBackend string, opts map[string]string, goOpts *ExtraOptions) error {
	var err error

	setupOnce.Do(func() {
		err = setup(selectedBackend, opts, goOpts)
	})

	return err
}
126760
func (m *Registry) Setup() {
	m.Lock()
	defer m.Unlock()

	// add some memory data
	m.Services = Data
}
520890
func (p *LogsPump) Setup() error {
	var err error
	p.client, err = docker.NewClientFromEnv()
	return err
}
1349961
func (u *Undertaker) SetUp() (watcher.NotifyWatcher, error) {
	logger.Infof("setting up machine undertaker")
	return u.API.WatchMachineRemovals()
}
11868
func (r *redisRequester) Setup() error {
	conn, err := redis.Dial("tcp", r.url)
	if err != nil {
		return err
	}
	r.conn = conn
	return nil
}
313688
func Setup(allowPrivileged bool, privilegedSources PrivilegedSources, perConnectionBytesPerSec int64) {
	Initialize(Capabilities{
		AllowPrivileged:                        allowPrivileged,
		PrivilegedSources:                      privilegedSources,
		PerConnectionBandwidthLimitBytesPerSec: perConnectionBytesPerSec,
	})
}
1077834
func Setup(conf config.Config) error {
	downlinkLockDuration = conf.NetworkServer.Scheduler.ClassC.DownlinkLockDuration
	schedulerInterval = conf.NetworkServer.Scheduler.SchedulerInterval
	installationMargin = conf.NetworkServer.NetworkSettings.InstallationMargin
	downlinkTXPower = conf.NetworkServer.NetworkSettings.DownlinkTXPower

	return nil
}
741901
func Setup(conf config.Config) error {
	downlinkTXPower = conf.NetworkServer.NetworkSettings.DownlinkTXPower

	return nil
}
297664
func (b *hostPathMounter) SetUp(fsGroup *int64) error {
	err := validation.ValidatePathNoBacksteps(b.GetPath())
	if err != nil {
		return fmt.Errorf("invalid HostPath `%s`: %v", b.GetPath(), err)
	}

	if *b.pathType == v1.HostPathUnset {
		return nil
	}
	return checkType(b.GetPath(), b.pathType, b.mounter)
}
495839
func (r *amqpRequester) Setup() error {
	conn, err := amqp.Dial(r.url)
	if err != nil {
		return err
	}
	c, err := conn.Channel()
	if err != nil {
		return err
	}
	queue, err := c.QueueDeclare(
		r.queueName, // name
		false,       // not durable
		false,       // delete when unused
		true,        // exclusive
		false,       // no wait
		nil,         // arguments
	)
	if err != nil {
		return err
	}
	err = c.ExchangeDeclare(
		r.exchangeName, // name
		"fanout",       // type
		false,          // not durable
		false,          // auto-deleted
		false,          // internal
		false,          // no wait
		nil,            // arguments
	)
	if err != nil {
		return err
	}
	err = c.QueueBind(
		r.queueName,
		r.queueName,
		r.exchangeName,
		false,
		nil,
	)
	if err != nil {
		return err
	}

	inbound, err := c.Consume(
		r.queueName, // queue
		"",          // consumer
		true,        // auto ack
		false,       // exclusive
		true,        // no local
		false,       // no wait
		nil,         // args
	)
	if err != nil {
		return err
	}
	r.conn = conn
	r.queue = queue
	r.channel = c
	r.inbound = inbound
	r.msg = amqp.Publishing{
		DeliveryMode: amqp.Transient,
		Timestamp:    time.Now(),
		ContentType:  "text/plain",
		Body:         make([]byte, r.payloadSize),
	}
	return nil
}