php_gearman_client.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Gearman PHP Extension
  3. *
  4. * Copyright (C) 2008 James M. Luedke <contact@jamesluedke.com>,
  5. * Eric Day <eday@oddments.org>
  6. * All rights reserved.
  7. *
  8. * Use and distribution licensed under the PHP license. See
  9. * the LICENSE file in this directory for full text.
  10. */
  11. #ifndef __PHP_GEARMAN_CLIENT_H
  12. #define __PHP_GEARMAN_CLIENT_H
  13. #include "php.h"
  14. #include "php_ini.h"
  15. #include "ext/standard/info.h"
  16. #include "zend_exceptions.h"
  17. #include "zend_interfaces.h"
  18. #include "php_gearman.h"
  19. #include <libgearman-1.0/gearman.h>
  20. #include <libgearman-1.0/interface/status.h>
  21. #include <libgearman-1.0/status.h>
  22. extern zend_class_entry *gearman_client_ce;
  23. extern zend_object_handlers gearman_client_obj_handlers;
  24. void gearman_client_free_obj(zend_object *object);
  25. zend_object *gearman_client_obj_new(zend_class_entry *ce);
  26. typedef enum {
  27. GEARMAN_CLIENT_OBJ_CREATED = (1 << 0)
  28. } gearman_client_obj_flags_t;
  29. typedef struct {
  30. gearman_return_t ret;
  31. gearman_client_obj_flags_t flags;
  32. gearman_client_st client;
  33. /* used for keeping track of task interface callbacks */
  34. zval zworkload_fn;
  35. zval zcreated_fn;
  36. zval zdata_fn;
  37. zval zwarning_fn;
  38. zval zstatus_fn;
  39. zval zcomplete_fn;
  40. zval zexception_fn;
  41. zval zfail_fn;
  42. zend_ulong created_tasks;
  43. zval task_list;
  44. zend_object std;
  45. } gearman_client_obj;
  46. gearman_client_obj *gearman_client_fetch_object(zend_object *obj);
  47. #define Z_GEARMAN_CLIENT_P(zv) gearman_client_fetch_object(Z_OBJ_P((zv)))
  48. /* NOTE: It seems kinda weird that GEARMAN_WORK_FAIL is a valid
  49. * return code, however it is required for a worker to pass status
  50. * back to the client about a failed job, other return codes can
  51. * be passed back but they will cause a docref Warning. Might
  52. * want to think of a better solution XXX */
  53. #define PHP_GEARMAN_CLIENT_RET_OK(__ret) ((__ret) == GEARMAN_SUCCESS || \
  54. (__ret) == GEARMAN_PAUSE || \
  55. (__ret) == GEARMAN_IO_WAIT || \
  56. (__ret) == GEARMAN_WORK_STATUS || \
  57. (__ret) == GEARMAN_WORK_DATA || \
  58. (__ret) == GEARMAN_WORK_EXCEPTION || \
  59. (__ret) == GEARMAN_WORK_WARNING || \
  60. (__ret) == GEARMAN_WORK_FAIL)
  61. #endif /* __PHP_GEARMAN_CLIENT_H */