Merge lp:~brianaker/gearmand/gearmnan_job_use_client into lp:gearmand

Proposed by Brian Aker
Status: Merged
Merged at revision: 869
Proposed branch: lp:~brianaker/gearmand/gearmnan_job_use_client
Merge into: lp:gearmand
Diff against target: 605 lines (+307/-64)
15 files modified
ChangeLog (+1/-1)
configure.ac (+1/-0)
docs/conf.py.in (+1/-0)
docs/libgearman/gearman_job_st.rst (+6/-1)
libgearman-1.0/job.h (+3/-0)
libgearman/job.cc (+46/-3)
libgearman/job.hpp (+4/-0)
libgearman/worker.cc (+0/-10)
m4/ax_uuid.m4 (+61/-49)
man/include.am (+1/-0)
support/gearmand.spec.in (+1/-0)
tests/libgearman-1.0/worker_test.cc (+71/-0)
tests/workers/include.am (+2/-0)
tests/workers/v2/client_echo.cc (+67/-0)
tests/workers/v2/client_echo.h (+42/-0)
To merge this branch: bzr merge lp:~brianaker/gearmand/gearmnan_job_use_client
Reviewer Review Type Date Requested Status
Tangent Trunk Pending
Review via email: mp+181725@code.launchpad.net
To post a comment you must log in.
867. By Brian Aker

Fix missing man pages

868. By Brian Aker

Fix uuid testing

869. By Brian Aker

Fix duplicate man page entry.

870. By Brian Aker

Fix docs

871. By Brian Aker

Fix spec file.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2013-08-15 06:28:02 +0000
+++ ChangeLog 2013-08-31 03:15:41 +0000
@@ -1,5 +1,5 @@
11.1.1011.1.10
2*2* Added gearman_job_use_client()
33
41.1.9 Fri Aug 2 02:39:25 EDT 201341.1.9 Fri Aug 2 02:39:25 EDT 2013
5* Added gearman_task_is_finished()5* Added gearman_task_is_finished()
66
=== modified file 'configure.ac'
--- configure.ac 2013-08-16 08:58:49 +0000
+++ configure.ac 2013-08-31 03:15:41 +0000
@@ -271,6 +271,7 @@
271271
272AX_LIBEVENT(,[AC_MSG_ERROR([Unable to find libevent])])272AX_LIBEVENT(,[AC_MSG_ERROR([Unable to find libevent])])
273273
274AX_UUID(,[AC_MSG_ERROR([Unable to find libuuid])])
274AX_UUID_GENERATE_TIME_SAFE275AX_UUID_GENERATE_TIME_SAFE
275276
276AX_AM_JOBSERVER([yes])277AX_AM_JOBSERVER([yes])
277278
=== modified file 'docs/conf.py.in'
--- docs/conf.py.in 2013-01-09 16:53:25 +0000
+++ docs/conf.py.in 2013-08-31 03:15:41 +0000
@@ -292,6 +292,7 @@
292 ('libgearman/gearman_job_st', 'gearman_job_free_all', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),292 ('libgearman/gearman_job_st', 'gearman_job_free_all', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
293 ('libgearman/gearman_job_st', 'gearman_job_function_name', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),293 ('libgearman/gearman_job_st', 'gearman_job_function_name', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
294 ('libgearman/gearman_job_st', 'gearman_job_handle', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),294 ('libgearman/gearman_job_st', 'gearman_job_handle', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
295 ('libgearman/gearman_job_st', 'gearman_job_use_client', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
295 ('libgearman/gearman_job_st', 'gearman_job_send_complete', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),296 ('libgearman/gearman_job_st', 'gearman_job_send_complete', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
296 ('libgearman/gearman_job_st', 'gearman_job_send_data', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),297 ('libgearman/gearman_job_st', 'gearman_job_send_data', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
297 ('libgearman/gearman_job_st', 'gearman_job_send_exception', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),298 ('libgearman/gearman_job_st', 'gearman_job_send_exception', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
298299
=== modified file 'docs/libgearman/gearman_job_st.rst'
--- docs/libgearman/gearman_job_st.rst 2013-08-16 08:41:58 +0000
+++ docs/libgearman/gearman_job_st.rst 2013-08-31 03:15:41 +0000
@@ -36,6 +36,8 @@
3636
37.. c:function:: void *gearman_job_take_workload(gearman_job_st *job, size_t *data_size)37.. c:function:: void *gearman_job_take_workload(gearman_job_st *job, size_t *data_size)
3838
39.. c:function:: gearman_client_st *gearman_job_use_client(gearman_job_st *job)
40
39Link with -lgearman41Link with -lgearman
4042
41-----------43-----------
@@ -54,10 +56,13 @@
5456
55:c:func:`gearman_job_unique` return the unique value that was used for :c:type:`gearman_job_st`. 57:c:func:`gearman_job_unique` return the unique value that was used for :c:type:`gearman_job_st`.
5658
57returns the :c:type:`gearman_job_st` workload. The size of it can be determined with :c:func:`gearman_job_workload_size`.59gearman_job_take_workload returns the :c:type:`gearman_job_st` workload. The size of it can be determined with :c:func:`gearman_job_workload_size`.
58:c:func:`gearman_job_take_workload` is the same as :c:func:`gearman_job_workload` with the exception that the result must be60:c:func:`gearman_job_take_workload` is the same as :c:func:`gearman_job_workload` with the exception that the result must be
59:manpage:`free(3)` by the caller.61:manpage:`free(3)` by the caller.
6062
63gearman_job_use_client returns a :c:type:`gearman_client_st` configured from gearman_job_st. The gearman_client_st can be used to communicate client API commands to the server.
64You do not, and should not, call :c:func:`gearman_client_free` on the gearman_client_st. It is cleaned up when job is cleaned up.
65
61------------66------------
62RETURN VALUE67RETURN VALUE
63------------68------------
6469
=== modified file 'libgearman-1.0/job.h'
--- libgearman-1.0/job.h 2013-07-10 01:57:34 +0000
+++ libgearman-1.0/job.h 2013-08-31 03:15:41 +0000
@@ -150,6 +150,9 @@
150gearman_worker_st *gearman_job_clone_worker(gearman_job_st *job);150gearman_worker_st *gearman_job_clone_worker(gearman_job_st *job);
151151
152GEARMAN_API152GEARMAN_API
153gearman_client_st *gearman_job_use_client(gearman_job_st *job);
154
155GEARMAN_API
153 const char *gearman_job_error(gearman_job_st *job);156 const char *gearman_job_error(gearman_job_st *job);
154157
155/** @} */158/** @} */
156159
=== modified file 'libgearman-server/plugins/protocol/gear/protocol.cc'
=== modified file 'libgearman/job.cc'
--- libgearman/job.cc 2013-08-05 22:43:13 +0000
+++ libgearman/job.cc 2013-08-31 03:15:41 +0000
@@ -226,6 +226,7 @@
226226
227Job::Job(gearman_job_st* shell_, Worker& worker_):227Job::Job(gearman_job_st* shell_, Worker& worker_):
228 _worker(worker_),228 _worker(worker_),
229 _client(NULL),
229 next(NULL),230 next(NULL),
230 prev(NULL),231 prev(NULL),
231 con(NULL),232 con(NULL),
@@ -247,6 +248,30 @@
247 gearman_set_initialized(_shell, true);248 gearman_set_initialized(_shell, true);
248}249}
249250
251Job::~Job()
252{
253 if (_client)
254 {
255 gearman_client_free(_client);
256 }
257
258 delete reducer;
259}
260
261gearman_client_st* Job::client()
262{
263 if (_client == NULL)
264 {
265 _client= gearman_client_create(NULL);
266 if (_client)
267 {
268 gearman_universal_clone(_client->impl()->universal, _worker.universal);
269 }
270 }
271
272 return _client;
273}
274
250bool gearman_job_build_reducer(Job* job, gearman_aggregator_fn *aggregator_fn)275bool gearman_job_build_reducer(Job* job, gearman_aggregator_fn *aggregator_fn)
251{276{
252 if (job->reducer)277 if (job->reducer)
@@ -272,6 +297,27 @@
272 return true;297 return true;
273}298}
274299
300
301gearman_worker_st *gearman_job_clone_worker(gearman_job_st *job_shell)
302{
303 if (job_shell and job_shell->impl())
304 {
305 return gearman_worker_clone(NULL, job_shell->impl()->_worker.shell());
306 }
307
308 return NULL;
309}
310
311gearman_client_st *gearman_job_use_client(gearman_job_st *job_shell)
312{
313 if (job_shell and job_shell->impl())
314 {
315 return job_shell->impl()->client();
316 }
317
318 return NULL;
319}
320
275static inline void gearman_job_reset_error(Job* job)321static inline void gearman_job_reset_error(Job* job)
276{322{
277 if (job)323 if (job)
@@ -778,9 +824,6 @@
778 }824 }
779 job->_worker.job_count--;825 job->_worker.job_count--;
780826
781 delete job->reducer;
782 job->reducer= NULL;
783
784 delete job;827 delete job;
785 }828 }
786 else if (job_shell)829 else if (job_shell)
787830
=== modified file 'libgearman/job.hpp'
--- libgearman/job.hpp 2013-07-15 19:50:11 +0000
+++ libgearman/job.hpp 2013-08-31 03:15:41 +0000
@@ -43,6 +43,7 @@
43{43{
44public:44public:
45 Job(gearman_job_st* shell_, Worker& worker_);45 Job(gearman_job_st* shell_, Worker& worker_);
46 ~Job();
4647
47 gearman_job_st* shell()48 gearman_job_st* shell()
48 {49 {
@@ -72,6 +73,7 @@
72 }73 }
7374
74 Worker& _worker;75 Worker& _worker;
76 gearman_client_st* _client;
75 Job *next;77 Job *next;
76 Job *prev;78 Job *prev;
77 gearman_connection_st *con;79 gearman_connection_st *con;
@@ -85,6 +87,8 @@
85 return _worker.universal;87 return _worker.universal;
86 }88 }
8789
90 gearman_client_st* client();
91
88 gearman_universal_st& universal() const92 gearman_universal_st& universal() const
89 {93 {
90 return _worker.universal;94 return _worker.universal;
9195
=== modified file 'libgearman/worker.cc'
--- libgearman/worker.cc 2013-08-23 07:08:19 +0000
+++ libgearman/worker.cc 2013-08-31 03:15:41 +0000
@@ -1439,16 +1439,6 @@
1439 return gearman_universal_id(self->impl()->universal);1439 return gearman_universal_id(self->impl()->universal);
1440}1440}
14411441
1442gearman_worker_st *gearman_job_clone_worker(gearman_job_st *job_shell)
1443{
1444 if (job_shell and job_shell->impl())
1445 {
1446 return gearman_worker_clone(NULL, job_shell->impl()->_worker.shell());
1447 }
1448
1449 return NULL;
1450}
1451
1452gearman_return_t gearman_worker_set_identifier(gearman_worker_st *worker,1442gearman_return_t gearman_worker_set_identifier(gearman_worker_st *worker,
1453 const char *id, size_t id_size)1443 const char *id, size_t id_size)
1454{1444{
14551445
=== modified file 'm4/ax_uuid.m4'
--- m4/ax_uuid.m4 2013-04-27 04:10:37 +0000
+++ m4/ax_uuid.m4 2013-08-31 03:15:41 +0000
@@ -5,9 +5,9 @@
5#5#
6# SYNOPSIS6# SYNOPSIS
7#7#
8# AX_UUID()8# AX_UUID([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
9# AX_UUID_GENERATE_TIME()9# AX_UUID_GENERATE_TIME([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
10# AX_UUID_GENERATE_TIME_SAFE()10# AX_UUID_GENERATE_TIME_SAFE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
11#11#
12# DESCRIPTION12# DESCRIPTION
13#13#
@@ -22,7 +22,7 @@
22# and this notice are preserved. This file is offered as-is, without any22# and this notice are preserved. This file is offered as-is, without any
23# warranty.23# warranty.
2424
25#serial 725#serial 8
2626
27AC_DEFUN([AX_UUID],27AC_DEFUN([AX_UUID],
28 [AC_PREREQ([2.63])dnl28 [AC_PREREQ([2.63])dnl
@@ -71,54 +71,66 @@
7171
72 AC_SUBST([LIBUUID_LIB])72 AC_SUBST([LIBUUID_LIB])
73 AM_CONDITIONAL([HAVE_LIBUUID],[test "x$ax_libuuid" = xyes])73 AM_CONDITIONAL([HAVE_LIBUUID],[test "x$ax_libuuid" = xyes])
74
75# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
76 AS_IF([test "x$ax_libuuid" = xyes],
77 [$1],
78 [$2])
74 ])79 ])
7580
76 AC_DEFUN([AX_UUID_GENERATE_TIME],81 AC_DEFUN([AX_UUID_GENERATE_TIME],
77 [AC_PREREQ([2.63])dnl82 [AC_PREREQ([2.63])dnl
78 AC_REQUIRE([AX_UUID])dnl83 AX_UUID([$1],[$2])
79 AC_CACHE_CHECK([for uuid_generate_time],84 AC_CACHE_CHECK([for uuid_generate_time],
80 [ax_cv_uuid_generate_time],85 [ax_cv_uuid_generate_time],
81 [AX_SAVE_FLAGS86 [AX_SAVE_FLAGS
82 LIBS="$LIBUUID_LIB $LIBS"87 LIBS="$LIBUUID_LIB $LIBS"
83 AC_LANG_PUSH([C])88 AC_LANG_PUSH([C])
84 AC_RUN_IFELSE([89 AC_RUN_IFELSE([
85 AC_LANG_PROGRAM([#include <uuid/uuid.h>],[90 AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
86 uuid_t out;91 uuid_t out;
87 uuid_generate_time(out);92 uuid_generate_time(out);
88 ])],93 ])],
89 [ax_cv_uuid_generate_time=yes],94 [ax_cv_uuid_generate_time=yes],
90 [ax_cv_uuid_generate_time=no],95 [ax_cv_uuid_generate_time=no],
91 [AC_MSG_WARN([test program execution failed])])96 [AC_MSG_WARN([test program execution failed])])
92 AC_LANG_POP97 AC_LANG_POP
93 AX_RESTORE_FLAGS98 AX_RESTORE_FLAGS
94 ])99 ])
95100
96 AS_IF([test "$ax_cv_uuid_generate_time" = yes],101 AS_IF([test "$ax_cv_uuid_generate_time" = yes],
97 [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[1],[Define if uuid_generate_time is present in uuid/uuid.h.])],102 [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[1],[Define if uuid_generate_time is present in uuid/uuid.h.])],
98 [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[0],[Define if uuid_generate_time is present in uuid/uuid.h.])])103 [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[0],[Define if uuid_generate_time is present in uuid/uuid.h.])])
99 ])104 AS_IF([test "x$ax_cv_uuid_generate_time" = xyes],
105 [$1],
106 [$2])
107 ])
100108
101 AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE],109 AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE],
102 [AC_PREREQ([2.63])dnl110 [AC_PREREQ([2.63])dnl
103 AC_REQUIRE([AX_UUID])dnl111 AX_UUID([$1],[$2])
104 AC_CACHE_CHECK([for uuid_generate_time_safe],112 AC_CACHE_CHECK([for uuid_generate_time_safe],
105 [ax_cv_uuid_generate_time_safe],113 [ax_cv_uuid_generate_time_safe],
106 [AX_SAVE_FLAGS114 [AX_SAVE_FLAGS
107 LIBS="$LIBUUID_LIB $LIBS"115 LIBS="$LIBUUID_LIB $LIBS"
108 AC_LANG_PUSH([C])116 AC_LANG_PUSH([C])
109 AC_RUN_IFELSE([117 AC_RUN_IFELSE([
110 AC_LANG_PROGRAM([#include <uuid/uuid.h>],[118 AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
111 uuid_t out;119 uuid_t out;
112 uuid_generate_time_safe(out);120 uuid_generate_time_safe(out);
113 ])],121 ])],
114 [ax_cv_uuid_generate_time_safe=yes],122 [ax_cv_uuid_generate_time_safe=yes],
115 [ax_cv_uuid_generate_time_safe=no],123 [ax_cv_uuid_generate_time_safe=no],
116 [AC_MSG_WARN([test program execution failed])])124 [AC_MSG_WARN([test program execution failed])])
117 AC_LANG_POP125 AC_LANG_POP
118 AX_RESTORE_FLAGS126 AX_RESTORE_FLAGS
119 ])127 ])
120128
121 AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],129 AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],
122 [AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE],[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],130 [AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE],[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],
123 [AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE],[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])])131 [AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE],[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])])
124 ])132
133 AS_IF([test "x$ax_cv_uuid_generate_time_safe" = xyes],
134 [$1],
135 [$2])
136 ])
125137
=== modified file 'man/include.am'
--- man/include.am 2013-08-16 08:58:49 +0000
+++ man/include.am 2013-08-31 03:15:41 +0000
@@ -87,6 +87,7 @@
87notrans_dist_man_MANS+= gearman_job_st.387notrans_dist_man_MANS+= gearman_job_st.3
88notrans_dist_man_MANS+= gearman_job_take_workload.388notrans_dist_man_MANS+= gearman_job_take_workload.3
89notrans_dist_man_MANS+= gearman_job_unique.389notrans_dist_man_MANS+= gearman_job_unique.3
90notrans_dist_man_MANS+= gearman_job_use_client.3
90notrans_dist_man_MANS+= gearman_job_workload.391notrans_dist_man_MANS+= gearman_job_workload.3
91notrans_dist_man_MANS+= gearman_job_workload_size.392notrans_dist_man_MANS+= gearman_job_workload_size.3
92notrans_dist_man_MANS+= gearman_log_fn.393notrans_dist_man_MANS+= gearman_log_fn.3
9394
=== modified file 'support/gearmand.spec.in'
--- support/gearmand.spec.in 2013-07-18 05:59:53 +0000
+++ support/gearmand.spec.in 2013-08-31 03:15:41 +0000
@@ -235,6 +235,7 @@
235%{_mandir}/man3/gearman_job_st.3.gz235%{_mandir}/man3/gearman_job_st.3.gz
236%{_mandir}/man3/gearman_job_take_workload.3.gz236%{_mandir}/man3/gearman_job_take_workload.3.gz
237%{_mandir}/man3/gearman_job_unique.3.gz237%{_mandir}/man3/gearman_job_unique.3.gz
238%{_mandir}/man3/gearman_job_use_client.3.gz
238%{_mandir}/man3/gearman_job_workload.3.gz239%{_mandir}/man3/gearman_job_workload.3.gz
239%{_mandir}/man3/gearman_job_workload_size.3.gz240%{_mandir}/man3/gearman_job_workload_size.3.gz
240%{_mandir}/man3/gearman_log_fn.3.gz241%{_mandir}/man3/gearman_log_fn.3.gz
241242
=== modified file 'tests/libgearman-1.0/worker_test.cc'
--- tests/libgearman-1.0/worker_test.cc 2013-08-20 09:27:42 +0000
+++ tests/libgearman-1.0/worker_test.cc 2013-08-31 03:15:41 +0000
@@ -62,6 +62,7 @@
6262
63#include "tests/start_worker.h"63#include "tests/start_worker.h"
64#include "tests/workers/v2/call_exception.h"64#include "tests/workers/v2/call_exception.h"
65#include "tests/workers/v2/client_echo.h"
65#include "tests/workers/v2/echo_or_react.h"66#include "tests/workers/v2/echo_or_react.h"
66#include "tests/workers/v2/echo_or_react_chunk.h"67#include "tests/workers/v2/echo_or_react_chunk.h"
67#include "tests/workers/v2/call_exception.h"68#include "tests/workers/v2/call_exception.h"
@@ -942,6 +943,75 @@
942 return TEST_SUCCESS;943 return TEST_SUCCESS;
943}944}
944945
946static test_return_t gearman_job_client_TEST(void *)
947{
948 gearman_function_t call_client_echo_WORKER_FN= gearman_function_create(client_echo_WORKER);
949 std::auto_ptr<worker_handle_st> handle(test_worker_start(libtest::default_port(),
950 NULL,
951 "client_echo",
952 call_client_echo_WORKER_FN,
953 NULL,
954 gearman_worker_options_t(),
955 0)); // timeout
956
957 std::vector<gearman_task_st*> tasks;
958 libgearman::Client client(libtest::default_port());
959
960 gearman_client_add_options(&client, GEARMAN_CLIENT_EXCEPTION);
961
962 for (size_t x= 0; x < 10; ++x)
963 {
964 char buffer[GEARMAN_MAXIMUM_INTEGER_DISPLAY_LENGTH];
965 int buffer_length= snprintf(buffer, sizeof(buffer), "%d", int(x));
966 gearman_return_t ret;
967 gearman_task_st *task= gearman_client_add_task(&client,
968 NULL, // preallocated task
969 NULL, // context
970 "client_echo", // function
971 NULL, // unique
972 (const void*)buffer, size_t(buffer_length), // workload
973 &ret);
974 ASSERT_EQ(ret, GEARMAN_SUCCESS);
975 ASSERT_TRUE(task);
976
977 tasks.push_back(task);
978 }
979
980 bool more= true;
981 while (more)
982 {
983 for (std::vector<gearman_task_st*>::iterator iter= tasks.begin();
984 iter != tasks.end(); ++iter)
985 {
986 if (gearman_task_return(*iter) == GEARMAN_UNKNOWN_STATE)
987 {
988 {
989 gearman_return_t ret;
990 do {
991 ret= gearman_client_run_tasks(&client);
992 } while (gearman_continue(ret));
993
994 if (gearman_failed(ret))
995 {
996 Error << gearman_strerror(ret);
997 }
998 ASSERT_EQ(GEARMAN_SUCCESS, ret);
999 }
1000
1001 continue;
1002 }
1003 else
1004 {
1005 ASSERT_EQ(GEARMAN_SUCCESS, gearman_task_return(*iter));
1006 }
1007
1008 more= false;
1009 }
1010 }
1011
1012 return TEST_SUCCESS;
1013}
1014
945static test_return_t gearman_job_send_exception_TEST(void *)1015static test_return_t gearman_job_send_exception_TEST(void *)
946{1016{
947 libgearman::Client client(libtest::default_port());1017 libgearman::Client client(libtest::default_port());
@@ -1671,6 +1741,7 @@
1671 {"gearman_client_job_status(is_known)", 0, gearman_client_job_status_is_known_TEST },1741 {"gearman_client_job_status(is_known)", 0, gearman_client_job_status_is_known_TEST },
1672 {"gearman_job_send_exception()", 0, gearman_job_send_exception_TEST },1742 {"gearman_job_send_exception()", 0, gearman_job_send_exception_TEST },
1673 {"gearman_job_send_exception(mass)", 0, gearman_job_send_exception_mass_TEST },1743 {"gearman_job_send_exception(mass)", 0, gearman_job_send_exception_mass_TEST },
1744 {"gearman_job_client()", 0, gearman_job_client_TEST },
1674 {"job order", 0, job_order_TEST },1745 {"job order", 0, job_order_TEST },
1675 {"job background order", 0, job_order_background_TEST },1746 {"job background order", 0, job_order_background_TEST },
1676 {"echo_max", 0, echo_max_test },1747 {"echo_max", 0, echo_max_test },
16771748
=== modified file 'tests/workers/include.am'
--- tests/workers/include.am 2013-05-28 22:55:50 +0000
+++ tests/workers/include.am 2013-08-31 03:15:41 +0000
@@ -16,6 +16,7 @@
16noinst_HEADERS+= tests/workers/v2/call_exception.h16noinst_HEADERS+= tests/workers/v2/call_exception.h
17noinst_HEADERS+= tests/workers/v2/called.h17noinst_HEADERS+= tests/workers/v2/called.h
18noinst_HEADERS+= tests/workers/v2/check_order.h18noinst_HEADERS+= tests/workers/v2/check_order.h
19noinst_HEADERS+= tests/workers/v2/client_echo.h
19noinst_HEADERS+= tests/workers/v2/count.h20noinst_HEADERS+= tests/workers/v2/count.h
20noinst_HEADERS+= tests/workers/v2/echo_or_react.h21noinst_HEADERS+= tests/workers/v2/echo_or_react.h
21noinst_HEADERS+= tests/workers/v2/echo_or_react_chunk.h22noinst_HEADERS+= tests/workers/v2/echo_or_react_chunk.h
@@ -46,6 +47,7 @@
46tests_libstartworker_la_SOURCES+= tests/workers/v1/unique.cc47tests_libstartworker_la_SOURCES+= tests/workers/v1/unique.cc
47tests_libstartworker_la_SOURCES+= tests/workers/v2/call_exception.cc48tests_libstartworker_la_SOURCES+= tests/workers/v2/call_exception.cc
48tests_libstartworker_la_SOURCES+= tests/workers/v2/called.cc49tests_libstartworker_la_SOURCES+= tests/workers/v2/called.cc
50tests_libstartworker_la_SOURCES+= tests/workers/v2/client_echo.cc
49tests_libstartworker_la_SOURCES+= tests/workers/v2/count.cc51tests_libstartworker_la_SOURCES+= tests/workers/v2/count.cc
50tests_libstartworker_la_SOURCES+= tests/workers/v2/echo_or_react.cc52tests_libstartworker_la_SOURCES+= tests/workers/v2/echo_or_react.cc
51tests_libstartworker_la_SOURCES+= tests/workers/v2/echo_or_react_chunk.cc53tests_libstartworker_la_SOURCES+= tests/workers/v2/echo_or_react_chunk.cc
5254
=== added file 'tests/workers/v2/client_echo.cc'
--- tests/workers/v2/client_echo.cc 1970-01-01 00:00:00 +0000
+++ tests/workers/v2/client_echo.cc 2013-08-31 03:15:41 +0000
@@ -0,0 +1,67 @@
1/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Gearmand client and server library.
4 *
5 * Copyright (C) 2013 Data Differential, http://datadifferential.com/
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#include <gear_config.h>
39
40#include <libtest/test.hpp>
41
42#include <libgearman-1.0/gearman.h>
43
44#include "tests/workers/v2/client_echo.h"
45
46#include <cassert>
47#include <cstring>
48
49gearman_return_t client_echo_WORKER(gearman_job_st *job, void *)
50{
51 gearman_client_st* client= gearman_job_use_client(job);
52
53 if (client)
54 {
55 if (gearman_failed(gearman_client_echo(client, test_literal_param("Tastes great"))))
56 {
57 assert(gearman_client_error(client));
58 return gearman_job_send_exception(job, gearman_client_error(client), strlen(gearman_client_error(client)));
59 }
60 }
61 else
62 {
63 return gearman_job_send_exception(job, test_literal_param("Failed to allocate gearman_client_st"));
64 }
65
66 return GEARMAN_SUCCESS;
67}
068
=== added file 'tests/workers/v2/client_echo.h'
--- tests/workers/v2/client_echo.h 1970-01-01 00:00:00 +0000
+++ tests/workers/v2/client_echo.h 2013-08-31 03:15:41 +0000
@@ -0,0 +1,42 @@
1/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Gearmand client and server library.
4 *
5 * Copyright (C) 2013 Data Differential, http://datadifferential.com/
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#pragma once
39
40LIBTEST_API
41gearman_return_t client_echo_WORKER(gearman_job_st *job, void *);
42

Subscribers

People subscribed via source and target branches

to all changes: