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
11 years ago
12 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. w.Work()
  25. ## Client
  26. c, err := client.New("tcp4", "127.0.0.1:4730")
  27. // ...
  28. defer c.Close()
  29. data := []byte("Hello\x00 world")
  30. c.ErrHandler = func(e error) {
  31. log.Println(e)
  32. panic(e)
  33. }
  34. jobHandler := func(job *client.Job) {
  35. log.Printf("%s", job.Data)
  36. }
  37. handle := c.Do("ToUpper", data, client.JOB_NORMAL, jobHandler)
  38. // ...
  39. Branches
  40. ========
  41. Version 0.x means: _It is far far away from stable._
  42. __Use at your own risk!__
  43. * 0.1-testing Old API and some known issues, eg. [issue-14](https://github.com/mikespook/gearman-go/issues/14)
  44. * 0.2-dev Refactoring a lot of things
  45. * master current usable version
  46. Authors
  47. =======
  48. * Xing Xing <mikespook@gmail.com> [Blog](http://mikespook.com) [@Twitter](http://twitter.com/mikespook)
  49. Open Source - MIT Software License
  50. ==================================
  51. Copyright (c) 2012 Xing Xing
  52. 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:
  53. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  54. 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.