예제 #1
0
func helpCmd(c *beanstalk.Conn) {
	printUsageInfo()
	fmt.Println("\nAvailable tube actions:")
	fmt.Println("- info")
	fmt.Println("- kick [bound]")
	fmt.Println("- delete all|{id}")
	fmt.Println("- put {data} [pri] [delay] [ttr]")
	if c != nil {
		tubes, _ := c.ListTubes()
		fmt.Printf("\nAvailable tubes: %s\n", strings.Join(tubes, " | "))
	}
	fmt.Println("\nGlobal args:")
	fmt.Println("-b=127.0.0.1:11300\tBeanstalkd [addr]:port")
	fmt.Println("")
}
예제 #2
0
func (this *Beanstalkd) selectTubes(conn *beanstalk.Conn) *beanstalk.Tube {
	tubes, err := conn.ListTubes()
	if err != nil {
		this.Log.Error("Could not retrieve list of tubes: %s", err.Error())
	}
	for _, tube := range tubes {
		t := &beanstalk.Tube{conn, tube}
		stats, err := t.Stats()
		if err != nil {
			this.Log.Error("Could not get stats for tube %s", t)
		}

		ready, _ := strconv.Atoi(stats["current-jobs-ready"])
		watching, _ := strconv.Atoi(stats["current-watching"])
		if ready > 0 && watching < this.MaxWatchers {
			return t
		}
	}
	return nil
}