Skip to content

Commit

Permalink
go vet format.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuri committed Oct 9, 2016
1 parent 12bea98 commit ada5d9f
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 19 deletions.
2 changes: 1 addition & 1 deletion beanstalk/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Example_put() {
}

func Example_putOtherTube() {
tube := &beanstalk.Tube{conn, "mytube"}
tube := &beanstalk.Tube{Conn: conn, Name: "mytube"}
id, err := tube.Put([]byte("myjob"), 1, 0, time.Minute)
if err != nil {
panic(err)
Expand Down
7 changes: 5 additions & 2 deletions currentTubeJobsActionsRow.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ func currentTubeJobsActionsRow(server string, tube string) string {
if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
return ``
}
tubeStats := &beanstalk.Tube{bstkConn, tube}
tubeStats := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
statsMap, _ := tubeStats.Stats()
if statsMap["pause-time-left"] == "0" {
pauseTimeLeft = fmt.Sprintf(`<a class="btn btn-default btn-sm" href="?server=%s&tube=%s&action=pause&count=-1"
title="Temporarily prevent jobs being reserved from the given tube. Pause for: %d seconds"><i class="glyphicon glyphicon-pause"></i>
Pause tube</a>`, server, tube, selfConf.TubePauseSeconds)
} else {
pauseTimeLeft = fmt.Sprintf(`<a class="btn btn-default btn-sm" href="?server=%s&tube=%s&action=pause&count=0"
title="Pause seconds left: %d"><i class="glyphicon glyphicon-play"></i> Unpause tube</a>`, server, tube, statsMap["pause-time-left"])
title="Pause seconds left: %s"><i class="glyphicon glyphicon-play"></i> Unpause tube</a>`, server, tube, statsMap["pause-time-left"])
}
bstkConn.Close()

Expand Down
12 changes: 9 additions & 3 deletions currentTubeJobsShowcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ func currentTubeJobsShowcaseReadySection(server string, tube string) string {
<div class="clearfix"></div><i>empty</i>`
}
tubes, _ := bstkConn.ListTubes()
tubeStats := &beanstalk.Tube{bstkConn, tube}
tubeStats := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
jobID, jobBody, err := tubeStats.PeekReady()
if err != nil {
bstkConn.Close()
Expand Down Expand Up @@ -153,7 +156,10 @@ func currentTubeJobsShowcaseDelayedSection(server string, tube string) string {
<div class="clearfix"></div><i>empty</i>`
}
tubes, _ := bstkConn.ListTubes()
tubeStats := &beanstalk.Tube{bstkConn, tube}
tubeStats := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
jobID, jobBody, err := tubeStats.PeekDelayed()
if err != nil {
bstkConn.Close()
Expand Down Expand Up @@ -276,7 +282,7 @@ func currentTubeJobsShowcaseBuriedSection(server string, tube string) string {
<div class="clearfix"></div><i>empty</i>`
}
tubes, _ := bstkConn.ListTubes()
tubeStats := &beanstalk.Tube{bstkConn, tube}
tubeStats := &beanstalk.Tube{Conn: bstkConn, Name: tube}
jobID, jobBody, err := tubeStats.PeekBuried()
if err != nil {
bstkConn.Close()
Expand Down
2 changes: 1 addition & 1 deletion currentTubeJobsSummaryTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func currentTubeJobsSummaryTable(server string, tube string) string {
if v != tube {
continue
}
tubeStats := &beanstalk.Tube{bstkConn, v}
tubeStats := &beanstalk.Tube{Conn: bstkConn, Name: v}
statsMap, err := tubeStats.Stats()
if err != nil {
continue
Expand Down
45 changes: 36 additions & 9 deletions lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func addJob(server string, tube string, data string, priority string, delay stri
if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
return
}
bstkTube := &beanstalk.Tube{bstkConn, tube}
bstkTube := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
bstkTube.Put([]byte(data), uint32(tubePriority), time.Duration(tubeDelay)*time.Second, time.Duration(tubeTTR)*time.Second)
bstkConn.Close()
}
Expand Down Expand Up @@ -57,7 +60,10 @@ func deleteAll(server string, tube string) {
if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
return
}
bstkTube := &beanstalk.Tube{bstkConn, tube}
bstkTube := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
for {
readyJob, _, err := bstkTube.PeekReady()
if err != nil {
Expand Down Expand Up @@ -94,7 +100,10 @@ func kick(server string, tube string, count string) {
if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
return
}
bstkTube := &beanstalk.Tube{bstkConn, tube}
bstkTube := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
bstkTube.Kick(bound)
bstkConn.Close()
}
Expand Down Expand Up @@ -122,7 +131,10 @@ func pause(server string, tube string, count string) {
if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
return
}
bstkTube := &beanstalk.Tube{bstkConn, tube}
bstkTube := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
if count == "-1" {
bstkTube.Pause(3600 * time.Second) // Pause tube
bstkConn.Close()
Expand All @@ -149,7 +161,10 @@ func moveReadyJobsTo(server string, tube string, destTube string, destState stri
if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
return
}
bstkTube := &beanstalk.Tube{bstkConn, tube}
bstkTube := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
switch destState {
case "buried":
tubeSet := beanstalk.NewTubeSet(bstkConn, tube)
Expand All @@ -168,7 +183,10 @@ func moveReadyJobsTo(server string, tube string, destTube string, destState stri
bstkConn.Close()
return
}
bstkDestTube := &beanstalk.Tube{bstkConn, destTube}
bstkDestTube := &beanstalk.Tube{
Conn: bstkConn,
Name: destTube,
}
for {
readyJob, readyBody, err := bstkTube.PeekReady()
if err != nil {
Expand All @@ -194,8 +212,14 @@ func moveBuriedJobsTo(server string, tube string, destTube string, destState str
if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
return
}
bstkTube := &beanstalk.Tube{bstkConn, tube}
bstkDestTube := &beanstalk.Tube{bstkConn, destTube}
bstkTube := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
bstkDestTube := &beanstalk.Tube{
Conn: bstkConn,
Name: destTube,
}
for {
buriedJob, buriedBody, err := bstkTube.PeekBuried()
if err != nil {
Expand Down Expand Up @@ -234,7 +258,10 @@ func searchTube(server string, tube string, limit string, searchStr string) stri
return currentTubeJobsSummaryTable(server, tube)
}
result := []SearchResult{}
bstkTube := &beanstalk.Tube{bstkConn, tube}
bstkTube := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
tubeStat, err := bstkTube.Stats()
if err != nil {
bstkConn.Close()
Expand Down
5 changes: 4 additions & 1 deletion sampleJobUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ func loadSample(server string, tube string, key string) {
if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
return
}
bstkTube := &beanstalk.Tube{bstkConn, tube}
bstkTube := &beanstalk.Tube{
Conn: bstkConn,
Name: tube,
}
bstkTube.Put([]byte(data), uint32(DefaultPriority), time.Duration(DefaultDelay)*time.Second, time.Duration(DefaultTTR)*time.Second)
bstkConn.Close()
return
Expand Down
5 changes: 4 additions & 1 deletion tplNav.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func getServerTubes(server string) string {
th += fmt.Sprintf(`<th name="%s">%s</th>`, v, v)
}
for _, v := range tubes {
tubeStats := &beanstalk.Tube{bstkConn, v}
tubeStats := &beanstalk.Tube{
Conn: bstkConn,
Name: v,
}
statsMap, err := tubeStats.Stats()
if err != nil {
continue
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func parseFlags() {
os.Exit(1)
}
if *helpPtr == true {
fmt.Println("aurora version: 0.1\r\nCopyright (c) 2016 Ri Xu https://xuri.me \r\n\r\nUsage: aurora [OPTIONS] [cmd [arg ...]]\n -c <filename> Use config file. (default: aurora.toml)\r\n -h \t\t Output this help and exit.\r\n -v \t\t Output version and exit.\r\n")
fmt.Println("aurora version: 0.1\r\nCopyright (c) 2016 Ri Xu https://xuri.me \r\n\r\nUsage: aurora [OPTIONS] [cmd [arg ...]]\n -c <filename> Use config file. (default: aurora.toml)\r\n -h \t\t Output this help and exit.\r\n -v \t\t Output version and exit.")
os.Exit(1)
}
}
Expand Down

0 comments on commit ada5d9f

Please sign in to comment.