go fmt
This commit is contained in:
parent
a003eac543
commit
ad9b3cb988
@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"github.com/mikespook/gearman-go/client"
|
||||
"log"
|
||||
"sync"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -4,10 +4,10 @@ import (
|
||||
"github.com/mikespook/gearman-go/worker"
|
||||
"github.com/mikespook/golib/signal"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
"net"
|
||||
)
|
||||
|
||||
func ToUpper(job worker.Job) ([]byte, error) {
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"net"
|
||||
"sync"
|
||||
"io"
|
||||
)
|
||||
|
||||
// The agent of job server.
|
||||
@ -66,7 +66,7 @@ func (a *agent) work() {
|
||||
break
|
||||
}
|
||||
|
||||
} else if( err == io.EOF ){
|
||||
} else if err == io.EOF {
|
||||
a.disconnect_error(err)
|
||||
break
|
||||
}
|
||||
@ -105,7 +105,7 @@ func (a *agent) work() {
|
||||
}
|
||||
|
||||
func (a *agent) disconnect_error(err error) {
|
||||
if( a.conn != nil ){
|
||||
if a.conn != nil {
|
||||
err = &WorkerDisconnectError{
|
||||
err: err,
|
||||
agent: a,
|
||||
@ -143,12 +143,12 @@ func (a *agent) PreSleep() {
|
||||
a.write(outpack)
|
||||
}
|
||||
|
||||
func (a *agent) reconnect() (error){
|
||||
func (a *agent) reconnect() error {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
conn, err := net.Dial(a.net, a.addr)
|
||||
if err != nil {
|
||||
return err;
|
||||
return err
|
||||
}
|
||||
a.conn = conn
|
||||
a.rw = bufio.NewReadWriter(bufio.NewReader(a.conn),
|
||||
|
@ -176,7 +176,7 @@ func TestDcRc(t *testing.T) {
|
||||
worker.ErrorHandler = func(e error) {
|
||||
wdc, wdcok := e.(*WorkerDisconnectError)
|
||||
|
||||
if( wdcok){
|
||||
if wdcok {
|
||||
log.Println("Reconnecting!")
|
||||
reconnected := false
|
||||
for tries := 20; !reconnected && tries > 0; tries-- {
|
||||
@ -184,11 +184,10 @@ func TestDcRc(t *testing.T) {
|
||||
if rcerr != nil {
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
} else {
|
||||
reconnected = true;
|
||||
reconnected = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
panic("Some other kind of error " + e.Error())
|
||||
}
|
||||
|
@ -153,8 +153,8 @@ func TestWorkWithoutReady(t * testing.T){
|
||||
done := make(chan bool, 1)
|
||||
|
||||
other_worker.JobHandler = func(j Job) error {
|
||||
if( ! other_worker.ready ){
|
||||
t.Error("Worker not ready as expected");
|
||||
if !other_worker.ready {
|
||||
t.Error("Worker not ready as expected")
|
||||
}
|
||||
done <- true
|
||||
return nil
|
||||
@ -165,14 +165,14 @@ func TestWorkWithoutReady(t * testing.T){
|
||||
}()
|
||||
|
||||
go func() {
|
||||
other_worker.Work();
|
||||
other_worker.Work()
|
||||
}()
|
||||
|
||||
// With the all-in-one Work() we don't know if the
|
||||
// worker is ready at this stage so we may have to wait a sec:
|
||||
go func() {
|
||||
tries := 5
|
||||
for( tries > 0 ){
|
||||
for tries > 0 {
|
||||
if other_worker.ready {
|
||||
other_worker.Echo([]byte("Hello"))
|
||||
break
|
||||
@ -209,7 +209,7 @@ func TestWorkWithoutReadyWithPanic(t * testing.T){
|
||||
t.Error("Work should raise a panic.")
|
||||
done <- true
|
||||
}()
|
||||
other_worker.Work();
|
||||
other_worker.Work()
|
||||
}()
|
||||
go func() {
|
||||
time.Sleep(2 * time.Second)
|
||||
|
Loading…
Reference in New Issue
Block a user