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.
 
 
 

61 lines
1.3 KiB

  1. // Copyright 2011 Xing Xing <mikespook@gmail.com>.
  2. // All rights reserved.
  3. // Use of this source code is governed by a MIT
  4. // license that can be found in the LICENSE file.
  5. package client
  6. import (
  7. )
  8. type poolItem struct {
  9. }
  10. /*
  11. The client pool
  12. usage:
  13. pool := client.NewPool()
  14. pool.Add("127.0.0.1:4730", 1)
  15. handle := pool.Do("ToUpper", []byte("abcdef"), JOB_LOW|JOB_BG)
  16. */
  17. type Pool struct {
  18. }
  19. // Create a new client.
  20. // Connect to "addr" through "network"
  21. // Eg.
  22. // client, err := client.New("127.0.0.1:4730")
  23. func NewPool() (pool *Pool) {
  24. }
  25. func (pool *Pool) Add(addr string, rate int) {
  26. // init a poolItem with Client & rate
  27. }
  28. // Do the function.
  29. // funcname is a string with function name.
  30. // data is encoding to byte array.
  31. // flag set the job type, include running level: JOB_LOW, JOB_NORMAL, JOB_HIGH,
  32. // and if it is background job: JOB_BG.
  33. // JOB_LOW | JOB_BG means the job is running with low level in background.
  34. func (pool *Pool) Do(funcname string, data []byte, flag byte) (handle string, err error) {
  35. // Select a job server
  36. }
  37. // Get job status from job server.
  38. // !!!Not fully tested.!!!
  39. func (pool *Pool) Status(handle string) {
  40. //
  41. }
  42. // Send a something out, get the samething back.
  43. func (pool *Pool) Echo(data []byte) {
  44. }
  45. // Close
  46. func (client *Client) Close() (err error) {
  47. }