// Run executes the Bee's event loop.
972710
func (mod *FacebookBee) Run(eventChan chan bees.Event) {
	mod.evchan = eventChan

	since := strconv.FormatInt(time.Now().UTC().Unix(), 10)
	timeout := time.Duration(10 * time.Second)

	for {
		select {
		case <-mod.SigChan:
			return
		case <-time.After(time.Duration(timeout)):
			var err error
			since, err = mod.handleStream(since)
			if err != nil {
				panic(err)
			}
		}

		timeout = time.Minute
	}
}
381259
func Run() int {
	robot, err := hal.NewRobot()
	if err != nil {
		fmt.Println(err)
		return 1
	}

	robot.Handle(
		getHandler,
		setHandler,
		deleteHandler,
		usersHandler,
		userHandler,
	)

	if err := robot.Run(); err != nil {
		hal.Logger.Error(err)
		return 1
	}
	return 0
}
695468
func (c *Cron) Run() {
	if c.running {
		return
	}
	c.running = true
	c.run()
}
671762
func (mod *mastodonBee) Run(eventChan chan bees.Event) {
	// Create the new api client
	c := mastodon.NewClient(&mastodon.Config{
		Server:       mod.server,
		ClientID:     mod.clientID,
		ClientSecret: mod.clientSecret,
	})
	// authorize it
	err := c.Authenticate(context.Background(), mod.email, mod.password)
	if err != nil {
		mod.LogErrorf("Authorization failed, make sure the mastodon credentials are correct: %s", err)
		return
	}
	// try to get user account
	acc, err := c.GetAccountCurrentUser(context.Background())
	if err != nil {
		mod.LogErrorf("Failed to get current user account: %v", err)
	}
	mod.Logf("Successfully logged in: %s", acc.URL)

	// set client
	mod.client = c

	// set eventchan
	mod.evchan = eventChan

	select {
	case <-mod.SigChan:
		return
	}
}
461957
func (a *AllocGarbageCollector) Run() {
	ticker := time.NewTicker(a.config.Interval)
	for {
		select {
		case <-a.triggerCh:
		case <-ticker.C:
		case <-a.shutdownCh:
			ticker.Stop()
			return
		}

		if err := a.keepUsageBelowThreshold(); err != nil {
			a.logger.Error("error garbage collecting allocations", "error", err)
		}
	}
}
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
}
46883
func (darwin *darwinRecord) Run(e Executable) (string, error) {
	runAction := "Running " + darwin.description + ":"
	e.Run()
	return runAction + " completed.", nil
}
1050930
func (o *Organizer) Run() {
	if o.only != nil {
		o.runTest(o.only)
		return
	}

	for _, test := range o.tests {
		o.runTest(&test)
	}
}
26293
func (d *Parser) Run() {
	defer close(d.Output)
	for sentence := range d.Input {
		dep, err := d.predict(sentence)

		if err != nil {
			d.Error <- err
			return
		}
		d.Output <- dep
	}
	return
}
393355
func (s *Server) Run() {
	go s.updater()
	go s.notifier()
	go s.manager()

	<-s.quit
}
42805
func (mod *TimeBee) Run(eventChan chan bees.Event) {
	mod.eventChan = eventChan
	for {
		select {
		case <-mod.SigChan:
			return

		default:
		}

		mod.timer()
		time.Sleep(500 * time.Millisecond)
	}
}
646371
func (k8s *Kubernetes) Run(qorJob worker.QorJobInterface) error {
	job := qorJob.GetJob()

	if job.Handler != nil {
		return job.Handler(qorJob.GetSerializableArgument(qorJob), qorJob)
	}

	return errors.New("no handler found for job " + job.Name)
}
1088379
func (mod *TelegramBee) Run(eventChan chan bees.Event) {
	var err error
	mod.bot, err = telegram.NewBotAPI(mod.apiKey)
	if err != nil {
		mod.LogErrorf("Authorization failed, make sure the Telegram API key is correct: %s", err)
		return
	}
	mod.Logf("Authorized on account %s", mod.bot.Self.UserName)

	u := telegram.NewUpdate(0)
	u.Timeout = 60

	updates, err := mod.bot.GetUpdatesChan(u)
	if err != nil {
		panic(err)
	}

	for {
		select {
		case <-mod.SigChan:
			return
		case update := <-updates:
			if update.Message == nil || update.Message.Text == "" {
				continue
			}

			ev := bees.Event{
				Bee:  mod.Name(),
				Name: "message",
				Options: []bees.Placeholder{
					{
						Name:  "text",
						Type:  "string",
						Value: update.Message.Text,
					},
					{
						Name:  "chat_id",
						Type:  "string",
						Value: strconv.FormatInt(update.Message.Chat.ID, 10),
					},
					{
						Name:  "user_id",
						Type:  "string",
						Value: strconv.Itoa(update.Message.From.ID),
					},
				},
			}
			eventChan <- ev
		}
	}
}
383639
func (c *registerCommand) Run(ctx *cmd.Context) error {
	err := c.run(ctx)
	if err != nil && c.onRunError != nil {
		c.onRunError()
	}
	return err
}
572579
func (c *disableCommand) Run(ctx *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.SwitchBlockOn(c.target, c.message)
}
95643
func (j *resizeJob) run() error {
	j.Logger.Printf("run resizeJob")
	// Set job state to RUNNING.
	j.setState(resizeJobStateRunning)

	// Job can be considered done in the case where it doesn't require any action.
	if !j.nodesArePending() {
		j.Logger.Printf("resizeJob contains no pending tasks; mark as done")
		j.result <- resizeJobStateDone
		return nil
	}

	j.Logger.Printf("distribute tasks for resizeJob")
	err := j.distributeResizeInstructions()
	if err != nil {
		j.result <- resizeJobStateAborted
		return errors.Wrap(err, "distributing instructions")
	}
	return nil
}
1103697
func (op *CaasOperatorAgent) Run(ctx *cmd.Context) (err error) {
	defer op.Done(err)
	if err := op.maybeCopyAgentConfig(); err != nil {
		return errors.Annotate(err, "creating agent config from template")
	}
	agentConfig := op.CurrentConfig()
	machineLock, err := machinelock.New(machinelock.Config{
		AgentName:   op.Tag().String(),
		Clock:       clock.WallClock,
		Logger:      loggo.GetLogger("juju.machinelock"),
		LogFilename: agent.MachineLockLogFilename(agentConfig),
	})
	// There will only be an error if the required configuration
	// values are not passed in.
	if err != nil {
		return errors.Trace(err)
	}
	op.machineLock = machineLock
	op.upgradeComplete = upgradesteps.NewLock(agentConfig)

	logger.Infof("caas operator %v start (%s [%s])", op.Tag().String(), jujuversion.Current, runtime.Compiler)
	if flags := featureflag.String(); flags != "" {
		logger.Warningf("developer feature flags enabled: %s", flags)
	}

	op.runner.StartWorker("api", op.Workers)
	return cmdutil.AgentDone(logger, op.runner.Wait())
}