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()
|
||||
defer client.Close()
|
||||
client.AddServer("127.0.0.1:4730")
|
||||
echo := []byte("Hello\x00world")
|
||||
echo := []byte("Hello\x00 world")
|
||||
|
||||
if data, err := client.Echo(echo); err != nil {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
data := bytes.Split(job.Data, []byte{'\x00'}, 5)
|
||||
data := bytes.SplitN(job.Data, []byte{'\x00'}, 5)
|
||||
if len(data) != 5 {
|
||||
err = os.NewError("Data Error.")
|
||||
return
|
||||
|
@ -66,7 +66,7 @@ func (job *ClientJob) Result() (data []byte, err os.Error) {
|
||||
err = os.NewError("Work exception.")
|
||||
fallthrough
|
||||
case WORK_COMPLETE:
|
||||
s := bytes.Split(job.Data, []byte{'\x00'}, 2)
|
||||
s := bytes.SplitN(job.Data, []byte{'\x00'}, 2)
|
||||
if len(s) != 2 {
|
||||
err = os.NewError("Invalid data.")
|
||||
return
|
||||
@ -85,7 +85,7 @@ func (job *ClientJob) Update() (data []byte, err os.Error) {
|
||||
err = os.NewError("The job is not a update.")
|
||||
return
|
||||
}
|
||||
s := bytes.Split(job.Data, []byte{'\x00'}, 2)
|
||||
s := bytes.SplitN(job.Data, []byte{'\x00'}, 2)
|
||||
if len(s) != 2 {
|
||||
err = os.NewError("Invalid data.")
|
||||
return
|
||||
|
@ -27,7 +27,6 @@ const (
|
||||
// read buffer size
|
||||
BUFFER_SIZE = 1024
|
||||
|
||||
|
||||
// \x00REQ
|
||||
REQ = 5391697
|
||||
REQ_STR = "\x00REQ"
|
||||
@ -87,7 +86,7 @@ type Job interface {
|
||||
|
||||
// Extract the error message
|
||||
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 {
|
||||
err = os.NewError("The input is not a error data.")
|
||||
return
|
||||
|
@ -82,7 +82,6 @@ func (worker *Worker) AddServer(addr string) (err os.Error) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Add a function.
|
||||
// Plz added job servers first, then functions.
|
||||
// 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 {
|
||||
limit = 4
|
||||
}
|
||||
jobdata := bytes.Split(job.Data, []byte{'\x00'}, limit)
|
||||
jobdata := bytes.SplitN(job.Data, []byte{'\x00'}, limit)
|
||||
job.Handle = string(jobdata[0])
|
||||
funcname := string(jobdata[1])
|
||||
if job.DataType == JOB_ASSIGN {
|
||||
|
Loading…
Reference in New Issue
Block a user