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.

пре 11 година
пре 11 година
пре 11 година
пре 10 година
пре 10 година
пре 11 година
пре 12 година
пре 11 година
пре 12 година
пре 11 година
пре 10 година
пре 11 година
пре 11 година
пре 9 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 12 година
пре 11 година
пре 12 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. Gearman-Go
  2. ==========
  3. This module is a [Gearman](http://gearman.org/) API for the [Go Programming Language](http://golang.org).
  4. The protocols were written in pure Go. It contains two sub-packages:
  5. The client package is used for sending jobs to the Gearman job server,
  6. and getting responses from the server.
  7. "github.com/mikespook/gearman-go/client"
  8. The worker package will help developers in developing Gearman worker
  9. service easily.
  10. "github.com/mikespook/gearman-go/worker"
  11. [![Build Status](https://travis-ci.org/mikespook/gearman-go.png?branch=master)](https://travis-ci.org/mikespook/gearman-go)
  12. [![GoDoc](https://godoc.org/github.com/mikespook/gearman-go?status.png)](https://godoc.org/github.com/mikespook/gearman-go)
  13. Install
  14. =======
  15. Install the client package:
  16. > $ go get github.com/mikespook/gearman-go/client
  17. Install the worker package:
  18. > $ go get github.com/mikespook/gearman-go/worker
  19. Both of them:
  20. > $ go get github.com/mikespook/gearman-go
  21. Usage
  22. =====
  23. ## Worker
  24. ```go
  25. // Limit number of concurrent jobs execution.
  26. // Use worker.Unlimited (0) if you want no limitation.
  27. w := worker.New(worker.OneByOne)
  28. w.ErrHandler = func(e error) {
  29. log.Println(e)
  30. }
  31. w.AddServer("127.0.0.1:4730")
  32. // Use worker.Unlimited (0) if you want no timeout
  33. w.AddFunc("ToUpper", ToUpper, worker.Unlimited)
  34. // This will give a timeout of 5 seconds
  35. w.AddFunc("ToUpperTimeOut5", ToUpper, 5)
  36. if err := w.Ready(); err != nil {
  37. log.Fatal(err)
  38. return
  39. }
  40. go w.Work()
  41. ```
  42. ## Client
  43. ```go
  44. // ...
  45. c, err := client.New("tcp4", "127.0.0.1:4730")
  46. // ... error handling
  47. defer c.Close()
  48. c.ErrorHandler = func(e error) {
  49. log.Println(e)
  50. }
  51. echo := []byte("Hello\x00 world")
  52. echomsg, err := c.Echo(echo)
  53. // ... error handling
  54. log.Println(string(echomsg))
  55. jobHandler := func(resp *client.Response) {
  56. log.Printf("%s", resp.Data)
  57. }
  58. handle, err := c.Do("ToUpper", echo, client.JobNormal, jobHandler)
  59. // ...
  60. ```
  61. Branches
  62. ========
  63. Version 0.x means: _It is far far away from stable._
  64. __Use at your own risk!__
  65. * master current usable version
  66. * 0.2-dev Refactoring a lot of things
  67. * 0.1-testing Old API and some known issues, eg. [issue-14](https://github.com/mikespook/gearman-go/issues/14)
  68. Contributors
  69. ============
  70. Great thanks to all of you for your support and interest!
  71. (_Alphabetic order_)
  72. * [Alex Zylman](https://github.com/azylman)
  73. * [C.R. Kirkwood-Watts](https://github.com/kirkwood)
  74. * [Damian Gryski](https://github.com/dgryski)
  75. * [Gabriel Cristian Alecu](https://github.com/AzuraMeta)
  76. * [Graham Barr](https://github.com/gbarr)
  77. * [Ingo Oeser](https://github.com/nightlyone)
  78. * [jake](https://github.com/jbaikge)
  79. * [Joe Higton](https://github.com/draxil)
  80. * [Jonathan Wills](https://github.com/runningwild)
  81. * [Kevin Darlington](https://github.com/kdar)
  82. * [miraclesu](https://github.com/miraclesu)
  83. * [Paul Mach](https://github.com/paulmach)
  84. * [Randall McPherson](https://github.com/rlmcpherson)
  85. * [Sam Grimee](https://github.com/sgrimee)
  86. Maintainer
  87. ==========
  88. * [Xing Xing](http://mikespook.com) &lt;<mikespook@gmail.com>&gt; [@Twitter](http://twitter.com/mikespook)
  89. Open Source - MIT Software License
  90. ==================================
  91. See LICENSE.