gofix for go's weekly version: weekly.2011-09-01
This commit is contained in:
parent
22866616cd
commit
e50c4533af
@ -9,7 +9,7 @@ func main() {
|
|||||||
client := gearman.NewClient()
|
client := gearman.NewClient()
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
client.AddServer("127.0.0.1:4730")
|
client.AddServer("127.0.0.1:4730")
|
||||||
echo := []byte("Hello\x00world")
|
echo := []byte("Hello\x00 world")
|
||||||
|
|
||||||
if data, err := client.Echo(echo); err != nil {
|
if data, err := client.Echo(echo); err != nil {
|
||||||
log.Println(string(data))
|
log.Println(string(data))
|
||||||
|
@ -205,7 +205,7 @@ func (client *Client) Status(handle string) (known, running bool, numerator, den
|
|||||||
if job, err = client.readLastJob(STATUS_RES); err != nil {
|
if job, err = client.readLastJob(STATUS_RES); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := bytes.Split(job.Data, []byte{'\x00'}, 5)
|
data := bytes.SplitN(job.Data, []byte{'\x00'}, 5)
|
||||||
if len(data) != 5 {
|
if len(data) != 5 {
|
||||||
err = os.NewError("Data Error.")
|
err = os.NewError("Data Error.")
|
||||||
return
|
return
|
||||||
|
@ -66,7 +66,7 @@ func (job *ClientJob) Result() (data []byte, err os.Error) {
|
|||||||
err = os.NewError("Work exception.")
|
err = os.NewError("Work exception.")
|
||||||
fallthrough
|
fallthrough
|
||||||
case WORK_COMPLETE:
|
case WORK_COMPLETE:
|
||||||
s := bytes.Split(job.Data, []byte{'\x00'}, 2)
|
s := bytes.SplitN(job.Data, []byte{'\x00'}, 2)
|
||||||
if len(s) != 2 {
|
if len(s) != 2 {
|
||||||
err = os.NewError("Invalid data.")
|
err = os.NewError("Invalid data.")
|
||||||
return
|
return
|
||||||
@ -85,7 +85,7 @@ func (job *ClientJob) Update() (data []byte, err os.Error) {
|
|||||||
err = os.NewError("The job is not a update.")
|
err = os.NewError("The job is not a update.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s := bytes.Split(job.Data, []byte{'\x00'}, 2)
|
s := bytes.SplitN(job.Data, []byte{'\x00'}, 2)
|
||||||
if len(s) != 2 {
|
if len(s) != 2 {
|
||||||
err = os.NewError("Invalid data.")
|
err = os.NewError("Invalid data.")
|
||||||
return
|
return
|
||||||
|
@ -27,7 +27,6 @@ const (
|
|||||||
// read buffer size
|
// read buffer size
|
||||||
BUFFER_SIZE = 1024
|
BUFFER_SIZE = 1024
|
||||||
|
|
||||||
|
|
||||||
// \x00REQ
|
// \x00REQ
|
||||||
REQ = 5391697
|
REQ = 5391697
|
||||||
REQ_STR = "\x00REQ"
|
REQ_STR = "\x00REQ"
|
||||||
@ -87,7 +86,7 @@ type Job interface {
|
|||||||
|
|
||||||
// Extract the error message
|
// Extract the error message
|
||||||
func getError(data []byte) (eno os.Errno, err os.Error) {
|
func getError(data []byte) (eno os.Errno, err os.Error) {
|
||||||
rel := bytes.Split(data, []byte{'\x00'}, 2)
|
rel := bytes.SplitN(data, []byte{'\x00'}, 2)
|
||||||
if len(rel) != 2 {
|
if len(rel) != 2 {
|
||||||
err = os.NewError("The input is not a error data.")
|
err = os.NewError("The input is not a error data.")
|
||||||
return
|
return
|
||||||
|
@ -82,7 +82,6 @@ func (worker *Worker) AddServer(addr string) (err os.Error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add a function.
|
// Add a function.
|
||||||
// Plz added job servers first, then functions.
|
// Plz added job servers first, then functions.
|
||||||
// The API will tell every connected job server that 'I can do this'
|
// The API will tell every connected job server that 'I can do this'
|
||||||
@ -224,7 +223,7 @@ func (worker *Worker) exec(job *WorkerJob) (err os.Error) {
|
|||||||
} else {
|
} else {
|
||||||
limit = 4
|
limit = 4
|
||||||
}
|
}
|
||||||
jobdata := bytes.Split(job.Data, []byte{'\x00'}, limit)
|
jobdata := bytes.SplitN(job.Data, []byte{'\x00'}, limit)
|
||||||
job.Handle = string(jobdata[0])
|
job.Handle = string(jobdata[0])
|
||||||
funcname := string(jobdata[1])
|
funcname := string(jobdata[1])
|
||||||
if job.DataType == JOB_ASSIGN {
|
if job.DataType == JOB_ASSIGN {
|
||||||
|
Loading…
Reference in New Issue
Block a user