.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "GEARMAN_WORKER_DEFINE_FUNCTION" "3" "Jan 31, 2024" "1.1.20+ds" "Gearmand" .SH NAME gearman_worker_define_function \- Gearmand Documentation, http://gearman.info/ .SH SYNOPSIS .sp #include .INDENT 0.0 .TP .B type gearman_function_t .UNINDENT .INDENT 0.0 .TP .B \fI\%gearman_return_t\fP gearman_worker_define_function(\fI\%gearman_worker_st\fP *worker, const char *function_name, const \fI\%size_t\fP function_name_length, const \fI\%gearman_function_t\fP function, const \fI\%uint32_t\fP timeout, void *context) .UNINDENT .INDENT 0.0 .TP .B type gearman_function_fn .UNINDENT .INDENT 0.0 .TP .B type gearman_aggregator_fn .UNINDENT .sp Link with \-lgearman .SH DESCRIPTION .sp \fI\%gearman_worker_define_function()\fP defines functions for a worker. .sp The interface is callback by design. When the server has a job for the worker, \fI\%gearman_function_fn\fP is evoked with a \fI\%gearman_job_st\fP representing the job, and the context that was defined originally when the function was defined. .sp Results are sent back to the client by invoking \fI\%gearman_job_send_data()\fP\&. .sp If the client specified an reducer function, then the output of the \fI\%gearman_function_fn\fP will be sent to that function. You can split the work out to the reducer function by sending data multiple times with \fI\%gearman_job_send_data()\fP\&. .sp If any errors are detected then the entire job is cancelled. The \fI\%gearman_aggregator_fn\fP will be called when all mapped jobs have completed. The result of this function will be what is returned to the client. .sp The callback function needs to return one of the following errors: .sp \fI\%GEARMAN_SUCCESS\fP .sp The function was successful. .sp \fI\%GEARMAN_FAIL\fP .sp An error has occurred, the job we not processed, and the worker cannot continue. .sp \fI\%GEARMAN_ERROR\fP .sp A transient error has occurred, like a network failure, and the job can be restarted. .sp If a value other then the above are returned it is converted to a \fI\%GEARMAN_FAIL\fP and \fI\%gearman_worker_work()\fP returns \fI\%GEARMAN_INVALID_ARGUMENT\fP\&. .sp \fI\%gearman_job_send_complete()\fP and \fI\%gearman_job_send_fail()\fP cannot be used with any functions created with \fI\%gearman_worker_define_function()\fP\&. .SH RETURN VALUE .sp \fI\%gearman_return_t\fP .SH HOME .sp To find out more information please check: \fI\%http://gearman.info/\fP .SH SEE ALSO .sp \fBgearmand(8)\fP \fBlibgearman(3)\fP \fBgearman_strerror(3)\fP \fBgearman_client_error\fP \fBgearman_client_execute_reduce\fP .SH AUTHOR Data Differential http://www.datadifferential.com/ .SH COPYRIGHT 2011-2024, Data Differential, http://www.datadifferential.com/ .\" Generated by docutils manpage writer. .