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 2.7 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
12 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. Gearman-Go
  2. ==========
  3. [![Build Status](https://travis-ci.org/mikespook/gearman-go.png?branch=master)](https://travis-ci.org/mikespook/gearman-go)
  4. This package is a [Gearman](http://gearman.org/) API for [Golang](http://golang.org).
  5. It was implemented a native protocol for both worker and client API.
  6. Install
  7. =======
  8. Install the client package:
  9. > $ go get github.com/mikespook/gearman-go/client
  10. Install the worker package:
  11. > $ go get github.com/mikespook/gearman-go/worker
  12. Install both:
  13. > $ go get github.com/mikespook/gearman-go
  14. Usage
  15. =====
  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, worker.Immediately)
  23. w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
  24. if err := w.Ready(); err != nil {
  25. log.Fatal(err)
  26. return
  27. }
  28. go w.Work()
  29. ## Client
  30. c, err := client.New("tcp4", "127.0.0.1:4730")
  31. // ...
  32. defer c.Close()
  33. data := []byte("Hello\x00 world")
  34. c.ErrHandler = func(e error) {
  35. log.Println(e)
  36. panic(e)
  37. }
  38. jobHandler := func(job *client.Job) {
  39. log.Printf("%s", job.Data)
  40. }
  41. handle := c.Do("ToUpper", data, client.JOB_NORMAL, jobHandler)
  42. // ...
  43. Branches
  44. ========
  45. Version 0.x means: _It is far far away from stable._
  46. __Use at your own risk!__
  47. * 0.1-testing Old API and some known issues, eg. [issue-14](https://github.com/mikespook/gearman-go/issues/14)
  48. * 0.2-dev Refactoring a lot of things
  49. * master current usable version
  50. Authors
  51. =======
  52. * Xing Xing <mikespook@gmail.com> [Blog](http://mikespook.com) [@Twitter](http://twitter.com/mikespook)
  53. Open Source - MIT Software License
  54. ==================================
  55. Copyright (c) 2012 Xing Xing
  56. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  57. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  58. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.