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.4 KiB

11 years ago
11 years ago
12 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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. Copyright 2012 Xing Xing <mikespook@gmail.com>
  6. All rights reserved.
  7. Use of this source code is governed by a MIT license that can be found
  8. in the LICENSE file.
  9. Install
  10. =======
  11. Install the client package:
  12. > $ go get github.com/mikespook/gearman-go/client
  13. Install the worker package:
  14. > $ go get github.com/mikespook/gearman-go/worker
  15. Install both:
  16. > $ go get github.com/mikespook/gearman-go
  17. Usage
  18. =====
  19. ## Worker
  20. w := worker.New(worker.Unlimited)
  21. w.ErrHandler = func(e error) {
  22. log.Println(e)
  23. }
  24. w.AddServer("127.0.0.1:4730")
  25. w.AddFunc("ToUpper", ToUpper, worker.Immediately)
  26. w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
  27. w.Work()
  28. ## Client
  29. c, err := client.New("127.0.0.1:4730")
  30. // ...
  31. defer c.Close()
  32. echo := []byte("Hello\x00 world")
  33. c.JobHandler = func(job *client.Job) error {
  34. log.Printf("%s", job.Data)
  35. return nil
  36. }
  37. c.ErrHandler = func(e error) {
  38. log.Println(e)
  39. panic(e)
  40. }
  41. handle, err := c.Do("ToUpper", echo, client.JOB_NORMAL)
  42. // ...
  43. Authors
  44. =======
  45. Xing Xing <mikespook@gmail.com> [Blog](http://mikespook.com) [@Twitter](http://twitter.com/mikespook)
  46. Open Source - MIT Software License
  47. ==================================
  48. Copyright (c) 2012 Xing Xing
  49. 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:
  50. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  51. 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.