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

Proposed by Brian Aker on 2013-08-23
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 2013-08-23 Pending
Review via email: mp+181725@code.launchpad.net
To post a comment you must log in.
867. By Brian Aker on 2013-08-30

Fix missing man pages

868. By Brian Aker on 2013-08-30

Fix uuid testing

869. By Brian Aker on 2013-08-30

Fix duplicate man page entry.

870. By Brian Aker on 2013-08-30

Fix docs

871. By Brian Aker on 2013-08-31

Fix spec file.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-08-15 06:28:02 +0000
3+++ ChangeLog 2013-08-31 03:15:41 +0000
4@@ -1,5 +1,5 @@
5 1.1.10
6-*
7+* Added gearman_job_use_client()
8
9 1.1.9 Fri Aug 2 02:39:25 EDT 2013
10 * Added gearman_task_is_finished()
11
12=== modified file 'configure.ac'
13--- configure.ac 2013-08-16 08:58:49 +0000
14+++ configure.ac 2013-08-31 03:15:41 +0000
15@@ -271,6 +271,7 @@
16
17 AX_LIBEVENT(,[AC_MSG_ERROR([Unable to find libevent])])
18
19+AX_UUID(,[AC_MSG_ERROR([Unable to find libuuid])])
20 AX_UUID_GENERATE_TIME_SAFE
21
22 AX_AM_JOBSERVER([yes])
23
24=== modified file 'docs/conf.py.in'
25--- docs/conf.py.in 2013-01-09 16:53:25 +0000
26+++ docs/conf.py.in 2013-08-31 03:15:41 +0000
27@@ -292,6 +292,7 @@
28 ('libgearman/gearman_job_st', 'gearman_job_free_all', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
29 ('libgearman/gearman_job_st', 'gearman_job_function_name', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
30 ('libgearman/gearman_job_st', 'gearman_job_handle', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
31+ ('libgearman/gearman_job_st', 'gearman_job_use_client', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
32 ('libgearman/gearman_job_st', 'gearman_job_send_complete', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
33 ('libgearman/gearman_job_st', 'gearman_job_send_data', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
34 ('libgearman/gearman_job_st', 'gearman_job_send_exception', u'Gearmand Documentation, http://gearman.info/', [u'Data Differential http://www.datadifferential.com/'], 3),
35
36=== modified file 'docs/libgearman/gearman_job_st.rst'
37--- docs/libgearman/gearman_job_st.rst 2013-08-16 08:41:58 +0000
38+++ docs/libgearman/gearman_job_st.rst 2013-08-31 03:15:41 +0000
39@@ -36,6 +36,8 @@
40
41 .. c:function:: void *gearman_job_take_workload(gearman_job_st *job, size_t *data_size)
42
43+.. c:function:: gearman_client_st *gearman_job_use_client(gearman_job_st *job)
44+
45 Link with -lgearman
46
47 -----------
48@@ -54,10 +56,13 @@
49
50 :c:func:`gearman_job_unique` return the unique value that was used for :c:type:`gearman_job_st`.
51
52-returns the :c:type:`gearman_job_st` workload. The size of it can be determined with :c:func:`gearman_job_workload_size`.
53+gearman_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`.
54 :c:func:`gearman_job_take_workload` is the same as :c:func:`gearman_job_workload` with the exception that the result must be
55 :manpage:`free(3)` by the caller.
56
57+gearman_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.
58+You 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.
59+
60 ------------
61 RETURN VALUE
62 ------------
63
64=== modified file 'libgearman-1.0/job.h'
65--- libgearman-1.0/job.h 2013-07-10 01:57:34 +0000
66+++ libgearman-1.0/job.h 2013-08-31 03:15:41 +0000
67@@ -150,6 +150,9 @@
68 gearman_worker_st *gearman_job_clone_worker(gearman_job_st *job);
69
70 GEARMAN_API
71+gearman_client_st *gearman_job_use_client(gearman_job_st *job);
72+
73+GEARMAN_API
74 const char *gearman_job_error(gearman_job_st *job);
75
76 /** @} */
77
78=== modified file 'libgearman-server/plugins/protocol/gear/protocol.cc'
79=== modified file 'libgearman/job.cc'
80--- libgearman/job.cc 2013-08-05 22:43:13 +0000
81+++ libgearman/job.cc 2013-08-31 03:15:41 +0000
82@@ -226,6 +226,7 @@
83
84 Job::Job(gearman_job_st* shell_, Worker& worker_):
85 _worker(worker_),
86+ _client(NULL),
87 next(NULL),
88 prev(NULL),
89 con(NULL),
90@@ -247,6 +248,30 @@
91 gearman_set_initialized(_shell, true);
92 }
93
94+Job::~Job()
95+{
96+ if (_client)
97+ {
98+ gearman_client_free(_client);
99+ }
100+
101+ delete reducer;
102+}
103+
104+gearman_client_st* Job::client()
105+{
106+ if (_client == NULL)
107+ {
108+ _client= gearman_client_create(NULL);
109+ if (_client)
110+ {
111+ gearman_universal_clone(_client->impl()->universal, _worker.universal);
112+ }
113+ }
114+
115+ return _client;
116+}
117+
118 bool gearman_job_build_reducer(Job* job, gearman_aggregator_fn *aggregator_fn)
119 {
120 if (job->reducer)
121@@ -272,6 +297,27 @@
122 return true;
123 }
124
125+
126+gearman_worker_st *gearman_job_clone_worker(gearman_job_st *job_shell)
127+{
128+ if (job_shell and job_shell->impl())
129+ {
130+ return gearman_worker_clone(NULL, job_shell->impl()->_worker.shell());
131+ }
132+
133+ return NULL;
134+}
135+
136+gearman_client_st *gearman_job_use_client(gearman_job_st *job_shell)
137+{
138+ if (job_shell and job_shell->impl())
139+ {
140+ return job_shell->impl()->client();
141+ }
142+
143+ return NULL;
144+}
145+
146 static inline void gearman_job_reset_error(Job* job)
147 {
148 if (job)
149@@ -778,9 +824,6 @@
150 }
151 job->_worker.job_count--;
152
153- delete job->reducer;
154- job->reducer= NULL;
155-
156 delete job;
157 }
158 else if (job_shell)
159
160=== modified file 'libgearman/job.hpp'
161--- libgearman/job.hpp 2013-07-15 19:50:11 +0000
162+++ libgearman/job.hpp 2013-08-31 03:15:41 +0000
163@@ -43,6 +43,7 @@
164 {
165 public:
166 Job(gearman_job_st* shell_, Worker& worker_);
167+ ~Job();
168
169 gearman_job_st* shell()
170 {
171@@ -72,6 +73,7 @@
172 }
173
174 Worker& _worker;
175+ gearman_client_st* _client;
176 Job *next;
177 Job *prev;
178 gearman_connection_st *con;
179@@ -85,6 +87,8 @@
180 return _worker.universal;
181 }
182
183+ gearman_client_st* client();
184+
185 gearman_universal_st& universal() const
186 {
187 return _worker.universal;
188
189=== modified file 'libgearman/worker.cc'
190--- libgearman/worker.cc 2013-08-23 07:08:19 +0000
191+++ libgearman/worker.cc 2013-08-31 03:15:41 +0000
192@@ -1439,16 +1439,6 @@
193 return gearman_universal_id(self->impl()->universal);
194 }
195
196-gearman_worker_st *gearman_job_clone_worker(gearman_job_st *job_shell)
197-{
198- if (job_shell and job_shell->impl())
199- {
200- return gearman_worker_clone(NULL, job_shell->impl()->_worker.shell());
201- }
202-
203- return NULL;
204-}
205-
206 gearman_return_t gearman_worker_set_identifier(gearman_worker_st *worker,
207 const char *id, size_t id_size)
208 {
209
210=== modified file 'm4/ax_uuid.m4'
211--- m4/ax_uuid.m4 2013-04-27 04:10:37 +0000
212+++ m4/ax_uuid.m4 2013-08-31 03:15:41 +0000
213@@ -5,9 +5,9 @@
214 #
215 # SYNOPSIS
216 #
217-# AX_UUID()
218-# AX_UUID_GENERATE_TIME()
219-# AX_UUID_GENERATE_TIME_SAFE()
220+# AX_UUID([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
221+# AX_UUID_GENERATE_TIME([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
222+# AX_UUID_GENERATE_TIME_SAFE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
223 #
224 # DESCRIPTION
225 #
226@@ -22,7 +22,7 @@
227 # and this notice are preserved. This file is offered as-is, without any
228 # warranty.
229
230-#serial 7
231+#serial 8
232
233 AC_DEFUN([AX_UUID],
234 [AC_PREREQ([2.63])dnl
235@@ -71,54 +71,66 @@
236
237 AC_SUBST([LIBUUID_LIB])
238 AM_CONDITIONAL([HAVE_LIBUUID],[test "x$ax_libuuid" = xyes])
239+
240+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
241+ AS_IF([test "x$ax_libuuid" = xyes],
242+ [$1],
243+ [$2])
244 ])
245
246 AC_DEFUN([AX_UUID_GENERATE_TIME],
247- [AC_PREREQ([2.63])dnl
248- AC_REQUIRE([AX_UUID])dnl
249- AC_CACHE_CHECK([for uuid_generate_time],
250- [ax_cv_uuid_generate_time],
251- [AX_SAVE_FLAGS
252- LIBS="$LIBUUID_LIB $LIBS"
253- AC_LANG_PUSH([C])
254- AC_RUN_IFELSE([
255- AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
256- uuid_t out;
257- uuid_generate_time(out);
258- ])],
259- [ax_cv_uuid_generate_time=yes],
260- [ax_cv_uuid_generate_time=no],
261- [AC_MSG_WARN([test program execution failed])])
262- AC_LANG_POP
263- AX_RESTORE_FLAGS
264- ])
265+ [AC_PREREQ([2.63])dnl
266+ AX_UUID([$1],[$2])
267+ AC_CACHE_CHECK([for uuid_generate_time],
268+ [ax_cv_uuid_generate_time],
269+ [AX_SAVE_FLAGS
270+ LIBS="$LIBUUID_LIB $LIBS"
271+ AC_LANG_PUSH([C])
272+ AC_RUN_IFELSE([
273+ AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
274+ uuid_t out;
275+ uuid_generate_time(out);
276+ ])],
277+ [ax_cv_uuid_generate_time=yes],
278+ [ax_cv_uuid_generate_time=no],
279+ [AC_MSG_WARN([test program execution failed])])
280+ AC_LANG_POP
281+ AX_RESTORE_FLAGS
282+ ])
283
284- AS_IF([test "$ax_cv_uuid_generate_time" = yes],
285- [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[1],[Define if uuid_generate_time is present in uuid/uuid.h.])],
286- [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[0],[Define if uuid_generate_time is present in uuid/uuid.h.])])
287- ])
288+ AS_IF([test "$ax_cv_uuid_generate_time" = yes],
289+ [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[1],[Define if uuid_generate_time is present in uuid/uuid.h.])],
290+ [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[0],[Define if uuid_generate_time is present in uuid/uuid.h.])])
291+ AS_IF([test "x$ax_cv_uuid_generate_time" = xyes],
292+ [$1],
293+ [$2])
294+ ])
295
296 AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE],
297- [AC_PREREQ([2.63])dnl
298- AC_REQUIRE([AX_UUID])dnl
299- AC_CACHE_CHECK([for uuid_generate_time_safe],
300- [ax_cv_uuid_generate_time_safe],
301- [AX_SAVE_FLAGS
302- LIBS="$LIBUUID_LIB $LIBS"
303- AC_LANG_PUSH([C])
304- AC_RUN_IFELSE([
305- AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
306- uuid_t out;
307- uuid_generate_time_safe(out);
308- ])],
309- [ax_cv_uuid_generate_time_safe=yes],
310- [ax_cv_uuid_generate_time_safe=no],
311- [AC_MSG_WARN([test program execution failed])])
312- AC_LANG_POP
313- AX_RESTORE_FLAGS
314- ])
315-
316- AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],
317- [AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE],[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],
318- [AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE],[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])])
319- ])
320+ [AC_PREREQ([2.63])dnl
321+ AX_UUID([$1],[$2])
322+ AC_CACHE_CHECK([for uuid_generate_time_safe],
323+ [ax_cv_uuid_generate_time_safe],
324+ [AX_SAVE_FLAGS
325+ LIBS="$LIBUUID_LIB $LIBS"
326+ AC_LANG_PUSH([C])
327+ AC_RUN_IFELSE([
328+ AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
329+ uuid_t out;
330+ uuid_generate_time_safe(out);
331+ ])],
332+ [ax_cv_uuid_generate_time_safe=yes],
333+ [ax_cv_uuid_generate_time_safe=no],
334+ [AC_MSG_WARN([test program execution failed])])
335+ AC_LANG_POP
336+ AX_RESTORE_FLAGS
337+ ])
338+
339+ AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],
340+ [AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE],[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],
341+ [AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE],[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])])
342+
343+ AS_IF([test "x$ax_cv_uuid_generate_time_safe" = xyes],
344+ [$1],
345+ [$2])
346+ ])
347
348=== modified file 'man/include.am'
349--- man/include.am 2013-08-16 08:58:49 +0000
350+++ man/include.am 2013-08-31 03:15:41 +0000
351@@ -87,6 +87,7 @@
352 notrans_dist_man_MANS+= gearman_job_st.3
353 notrans_dist_man_MANS+= gearman_job_take_workload.3
354 notrans_dist_man_MANS+= gearman_job_unique.3
355+notrans_dist_man_MANS+= gearman_job_use_client.3
356 notrans_dist_man_MANS+= gearman_job_workload.3
357 notrans_dist_man_MANS+= gearman_job_workload_size.3
358 notrans_dist_man_MANS+= gearman_log_fn.3
359
360=== modified file 'support/gearmand.spec.in'
361--- support/gearmand.spec.in 2013-07-18 05:59:53 +0000
362+++ support/gearmand.spec.in 2013-08-31 03:15:41 +0000
363@@ -235,6 +235,7 @@
364 %{_mandir}/man3/gearman_job_st.3.gz
365 %{_mandir}/man3/gearman_job_take_workload.3.gz
366 %{_mandir}/man3/gearman_job_unique.3.gz
367+%{_mandir}/man3/gearman_job_use_client.3.gz
368 %{_mandir}/man3/gearman_job_workload.3.gz
369 %{_mandir}/man3/gearman_job_workload_size.3.gz
370 %{_mandir}/man3/gearman_log_fn.3.gz
371
372=== modified file 'tests/libgearman-1.0/worker_test.cc'
373--- tests/libgearman-1.0/worker_test.cc 2013-08-20 09:27:42 +0000
374+++ tests/libgearman-1.0/worker_test.cc 2013-08-31 03:15:41 +0000
375@@ -62,6 +62,7 @@
376
377 #include "tests/start_worker.h"
378 #include "tests/workers/v2/call_exception.h"
379+#include "tests/workers/v2/client_echo.h"
380 #include "tests/workers/v2/echo_or_react.h"
381 #include "tests/workers/v2/echo_or_react_chunk.h"
382 #include "tests/workers/v2/call_exception.h"
383@@ -942,6 +943,75 @@
384 return TEST_SUCCESS;
385 }
386
387+static test_return_t gearman_job_client_TEST(void *)
388+{
389+ gearman_function_t call_client_echo_WORKER_FN= gearman_function_create(client_echo_WORKER);
390+ std::auto_ptr<worker_handle_st> handle(test_worker_start(libtest::default_port(),
391+ NULL,
392+ "client_echo",
393+ call_client_echo_WORKER_FN,
394+ NULL,
395+ gearman_worker_options_t(),
396+ 0)); // timeout
397+
398+ std::vector<gearman_task_st*> tasks;
399+ libgearman::Client client(libtest::default_port());
400+
401+ gearman_client_add_options(&client, GEARMAN_CLIENT_EXCEPTION);
402+
403+ for (size_t x= 0; x < 10; ++x)
404+ {
405+ char buffer[GEARMAN_MAXIMUM_INTEGER_DISPLAY_LENGTH];
406+ int buffer_length= snprintf(buffer, sizeof(buffer), "%d", int(x));
407+ gearman_return_t ret;
408+ gearman_task_st *task= gearman_client_add_task(&client,
409+ NULL, // preallocated task
410+ NULL, // context
411+ "client_echo", // function
412+ NULL, // unique
413+ (const void*)buffer, size_t(buffer_length), // workload
414+ &ret);
415+ ASSERT_EQ(ret, GEARMAN_SUCCESS);
416+ ASSERT_TRUE(task);
417+
418+ tasks.push_back(task);
419+ }
420+
421+ bool more= true;
422+ while (more)
423+ {
424+ for (std::vector<gearman_task_st*>::iterator iter= tasks.begin();
425+ iter != tasks.end(); ++iter)
426+ {
427+ if (gearman_task_return(*iter) == GEARMAN_UNKNOWN_STATE)
428+ {
429+ {
430+ gearman_return_t ret;
431+ do {
432+ ret= gearman_client_run_tasks(&client);
433+ } while (gearman_continue(ret));
434+
435+ if (gearman_failed(ret))
436+ {
437+ Error << gearman_strerror(ret);
438+ }
439+ ASSERT_EQ(GEARMAN_SUCCESS, ret);
440+ }
441+
442+ continue;
443+ }
444+ else
445+ {
446+ ASSERT_EQ(GEARMAN_SUCCESS, gearman_task_return(*iter));
447+ }
448+
449+ more= false;
450+ }
451+ }
452+
453+ return TEST_SUCCESS;
454+}
455+
456 static test_return_t gearman_job_send_exception_TEST(void *)
457 {
458 libgearman::Client client(libtest::default_port());
459@@ -1671,6 +1741,7 @@
460 {"gearman_client_job_status(is_known)", 0, gearman_client_job_status_is_known_TEST },
461 {"gearman_job_send_exception()", 0, gearman_job_send_exception_TEST },
462 {"gearman_job_send_exception(mass)", 0, gearman_job_send_exception_mass_TEST },
463+ {"gearman_job_client()", 0, gearman_job_client_TEST },
464 {"job order", 0, job_order_TEST },
465 {"job background order", 0, job_order_background_TEST },
466 {"echo_max", 0, echo_max_test },
467
468=== modified file 'tests/workers/include.am'
469--- tests/workers/include.am 2013-05-28 22:55:50 +0000
470+++ tests/workers/include.am 2013-08-31 03:15:41 +0000
471@@ -16,6 +16,7 @@
472 noinst_HEADERS+= tests/workers/v2/call_exception.h
473 noinst_HEADERS+= tests/workers/v2/called.h
474 noinst_HEADERS+= tests/workers/v2/check_order.h
475+noinst_HEADERS+= tests/workers/v2/client_echo.h
476 noinst_HEADERS+= tests/workers/v2/count.h
477 noinst_HEADERS+= tests/workers/v2/echo_or_react.h
478 noinst_HEADERS+= tests/workers/v2/echo_or_react_chunk.h
479@@ -46,6 +47,7 @@
480 tests_libstartworker_la_SOURCES+= tests/workers/v1/unique.cc
481 tests_libstartworker_la_SOURCES+= tests/workers/v2/call_exception.cc
482 tests_libstartworker_la_SOURCES+= tests/workers/v2/called.cc
483+tests_libstartworker_la_SOURCES+= tests/workers/v2/client_echo.cc
484 tests_libstartworker_la_SOURCES+= tests/workers/v2/count.cc
485 tests_libstartworker_la_SOURCES+= tests/workers/v2/echo_or_react.cc
486 tests_libstartworker_la_SOURCES+= tests/workers/v2/echo_or_react_chunk.cc
487
488=== added file 'tests/workers/v2/client_echo.cc'
489--- tests/workers/v2/client_echo.cc 1970-01-01 00:00:00 +0000
490+++ tests/workers/v2/client_echo.cc 2013-08-31 03:15:41 +0000
491@@ -0,0 +1,67 @@
492+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
493+ *
494+ * Gearmand client and server library.
495+ *
496+ * Copyright (C) 2013 Data Differential, http://datadifferential.com/
497+ * All rights reserved.
498+ *
499+ * Redistribution and use in source and binary forms, with or without
500+ * modification, are permitted provided that the following conditions are
501+ * met:
502+ *
503+ * * Redistributions of source code must retain the above copyright
504+ * notice, this list of conditions and the following disclaimer.
505+ *
506+ * * Redistributions in binary form must reproduce the above
507+ * copyright notice, this list of conditions and the following disclaimer
508+ * in the documentation and/or other materials provided with the
509+ * distribution.
510+ *
511+ * * The names of its contributors may not be used to endorse or
512+ * promote products derived from this software without specific prior
513+ * written permission.
514+ *
515+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
516+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
517+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
518+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
519+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
520+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
521+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
522+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
523+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
524+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
525+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
526+ *
527+ */
528+
529+#include <gear_config.h>
530+
531+#include <libtest/test.hpp>
532+
533+#include <libgearman-1.0/gearman.h>
534+
535+#include "tests/workers/v2/client_echo.h"
536+
537+#include <cassert>
538+#include <cstring>
539+
540+gearman_return_t client_echo_WORKER(gearman_job_st *job, void *)
541+{
542+ gearman_client_st* client= gearman_job_use_client(job);
543+
544+ if (client)
545+ {
546+ if (gearman_failed(gearman_client_echo(client, test_literal_param("Tastes great"))))
547+ {
548+ assert(gearman_client_error(client));
549+ return gearman_job_send_exception(job, gearman_client_error(client), strlen(gearman_client_error(client)));
550+ }
551+ }
552+ else
553+ {
554+ return gearman_job_send_exception(job, test_literal_param("Failed to allocate gearman_client_st"));
555+ }
556+
557+ return GEARMAN_SUCCESS;
558+}
559
560=== added file 'tests/workers/v2/client_echo.h'
561--- tests/workers/v2/client_echo.h 1970-01-01 00:00:00 +0000
562+++ tests/workers/v2/client_echo.h 2013-08-31 03:15:41 +0000
563@@ -0,0 +1,42 @@
564+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
565+ *
566+ * Gearmand client and server library.
567+ *
568+ * Copyright (C) 2013 Data Differential, http://datadifferential.com/
569+ * All rights reserved.
570+ *
571+ * Redistribution and use in source and binary forms, with or without
572+ * modification, are permitted provided that the following conditions are
573+ * met:
574+ *
575+ * * Redistributions of source code must retain the above copyright
576+ * notice, this list of conditions and the following disclaimer.
577+ *
578+ * * Redistributions in binary form must reproduce the above
579+ * copyright notice, this list of conditions and the following disclaimer
580+ * in the documentation and/or other materials provided with the
581+ * distribution.
582+ *
583+ * * The names of its contributors may not be used to endorse or
584+ * promote products derived from this software without specific prior
585+ * written permission.
586+ *
587+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
588+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
589+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
590+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
591+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
592+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
593+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
594+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
595+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
596+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
597+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
598+ *
599+ */
600+
601+#pragma once
602+
603+LIBTEST_API
604+gearman_return_t client_echo_WORKER(gearman_job_st *job, void *);
605+

Subscribers

People subscribed via source and target branches

to all changes: