You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.5 KiB

12 years ago
12 years ago
12 years ago
12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Gearman API for golang
  2. This package is a [Gearman](http://gearman.org/) API for [Golang](http://golang.org).
  3. It was implemented a native protocol for both worker and client API.
  4. Copyright 2012 Xing Xing <mikespook@gmail.com>
  5. All rights reserved.
  6. Use of this source code is governed by a MIT license that can be found
  7. in the LICENSE file.
  8. # INSTALL
  9. Install the client package:
  10. > $ go get bitbucket.org/mikespook/gearman-go/client
  11. Install the worker package:
  12. > $ go get bitbucket.org/mikespook/gearman-go/worker
  13. Install both:
  14. > $ go get bitbucket.org/mikespook/gearman-go
  15. # SAMPLE OF USAGE
  16. ## Worker
  17. w := worker.New(worker.Unlimited)
  18. w.ErrHandler = func(e error) {
  19. log.Println(e)
  20. }
  21. w.AddServer("127.0.0.1:4730")
  22. w.AddFunc("ToUpper", ToUpper, 0)
  23. w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
  24. w.Work()
  25. ## Client
  26. c, err := client.New("127.0.0.1:4730")
  27. // ...
  28. defer c.Close()
  29. echo := []byte("Hello\x00 world")
  30. c.JobHandler = func(job *client.Job) error {
  31. log.Printf("%s", job.Data)
  32. return nil
  33. }
  34. c.ErrHandler = func(e error) {
  35. log.Println(e)
  36. panic(e)
  37. }
  38. handle, err := c.Do("ToUpper", echo, client.JOB_NORMAL)
  39. // ...
  40. # Contacts
  41. Xing Xing <mikespook@gmail.com>
  42. [Blog](http://mikespook.com)
  43. [@Twitter](http://twitter.com/mikespook)
  44. # History
  45. * 0.1 Code refactoring; Redesign the API.
  46. * 0.0.1 Initial implementation, ugly code-style, slow profermance and unstable API.
  47. # TODO
  48. * Can not grab a job correctly.
  49. * Worker's auto-reconnection.