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.2 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
12 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Gearman-Go
  2. ==========
  3. This package is a [Gearman](http://gearman.org/) API for [Golang](http://golang.org).
  4. It was implemented a native protocol for both worker and client API.
  5. Install
  6. =======
  7. Install the client package:
  8. > $ go get github.com/mikespook/gearman-go/client
  9. Install the worker package:
  10. > $ go get github.com/mikespook/gearman-go/worker
  11. Install both:
  12. > $ go get github.com/mikespook/gearman-go
  13. Usage
  14. =====
  15. ## Worker
  16. w := worker.New(worker.Unlimited)
  17. w.ErrHandler = func(e error) {
  18. log.Println(e)
  19. }
  20. w.AddServer("127.0.0.1:4730")
  21. w.AddFunc("ToUpper", ToUpper, worker.Immediately)
  22. w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
  23. w.Work()
  24. ## Client
  25. c, err := client.New("127.0.0.1:4730")
  26. // ...
  27. defer c.Close()
  28. data := []byte("Hello\x00 world")
  29. c.ErrHandler = func(e error) {
  30. log.Println(e)
  31. panic(e)
  32. }
  33. jobHandler := func(job *client.Job) {
  34. log.Printf("%s", job.Data)
  35. }
  36. handle := c.Do("ToUpper", data, client.JOB_NORMAL, jobHandler)
  37. // ...
  38. Authors
  39. =======
  40. * Xing Xing <mikespook@gmail.com> [Blog](http://mikespook.com) [@Twitter](http://twitter.com/mikespook)
  41. Open Source - MIT Software License
  42. ==================================
  43. Copyright (c) 2012 Xing Xing
  44. 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:
  45. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  46. 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.