Skip to content

Fix #1369 + #1370: adding GearmanClient::setXXXCallback documentation #3861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions reference/gearman/gearmanclient/setclientcallback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
</methodsynopsis>
<para>
Sets the callback function for accepting data packets for a task. The callback function should
take a single argument, a <classname>GearmanTask</classname> object.
Sets the callback function for accepting data packets for a task.
</para>
<note>
<para>
This method has been replaced by <methodname>GearmanClient::setDataCallback</methodname> in
the 0.6.0 release of the Gearman extension.
</para>
</note>
<note>
<para>
The callback will only be triggered for tasks that are added (e.g. by calling <methodname>GearmanClient::addTask</methodname>)
after calling this method.
</para>
</note>
</refsect1>

<refsect1 role="parameters">
Expand All @@ -33,8 +38,33 @@
<term><parameter>callback</parameter></term>
<listitem>
<para>
A function or method to call
A function or method to call.
It must return either nothing (which defaults to <constant>GEARMAN_SUCCESS</constant>)
or a valid <link linkend="gearman.constants">Gearman return value</link>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably rephrasing this to:

Suggested change
It must return either nothing (which defaults to <constant>GEARMAN_SUCCESS</constant>)
or a valid <link linkend="gearman.constants">Gearman return value</link>.
It should return a valid <link linkend="gearman.constants">Gearman return value</link>.
However, if &null; is returned it defaults to <constant>GEARMAN_SUCCESS</constant>.

as void functions do return null.

</para>
<methodsynopsis>
<type class="union"><type>int</type><type>void</type></type><methodname><replaceable>callback</replaceable></methodname>
<methodparam><type>GearmanTask</type><parameter>task</parameter></methodparam>
<methodparam><type>mixed</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<variablelist>
<varlistentry>
<term><parameter>task</parameter></term>
<listitem>
<para>
The task this callback is called for.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
Whatever has been passed to <methodname>GearmanClient::addTask</methodname> (or equivalent method) as <parameter>context</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist>
Expand Down
41 changes: 36 additions & 5 deletions reference/gearman/gearmanclient/setcompletecallback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,60 @@
&reftitle.description;
<methodsynopsis role="GearmanClient">
<modifier>public</modifier> <type>bool</type><methodname>GearmanClient::setCompleteCallback</methodname>
<methodparam><type>callable</type><parameter>function</parameter></methodparam>
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
</methodsynopsis>
<para>
Use to set a function to be called when a <classname>GearmanTask</classname> is completed, or
Use to set a callback function to be called when a <classname>GearmanTask</classname> is completed, or
when <methodname>GearmanJob::sendComplete</methodname> is invoked by a worker (whichever happens
first).
</para>
<para>
This callback executes only when executing a <classname>GearmanTask</classname> using
<methodname>GearmanClient::runTasks</methodname>. It is not used for individual jobs.
</para>
</para>
<note>
<para>
The callback will only be triggered for tasks that are added (e.g. by calling <methodname>GearmanClient::addTask</methodname>)
after calling this method.
</para>
</note>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>function</parameter></term>
<term><parameter>callback</parameter></term>
<listitem>
<para>
A function to be called
A function to be called.
It must return either nothing (which defaults to <constant>GEARMAN_SUCCESS</constant>)
or a valid <link linkend="gearman.constants">Gearman return value</link>.
</para>
<methodsynopsis>
<type class="union"><type>int</type><type>void</type></type><methodname><replaceable>callback</replaceable></methodname>
<methodparam><type>GearmanTask</type><parameter>task</parameter></methodparam>
<methodparam><type>mixed</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<variablelist>
<varlistentry>
<term><parameter>task</parameter></term>
<listitem>
<para>
The task this callback is called for.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
Whatever has been passed to <methodname>GearmanClient::addTask</methodname> (or equivalent method) as <parameter>context</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist>
Expand Down
40 changes: 35 additions & 5 deletions reference/gearman/gearmanclient/setcreatedcallback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,54 @@
&reftitle.description;
<methodsynopsis role="GearmanClient">
<modifier>public</modifier> <type>bool</type><methodname>GearmanClient::setCreatedCallback</methodname>
<methodparam><type>callable</type><parameter>function</parameter></methodparam>
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
</methodsynopsis>
<para>
Sets a function to be called when a task is received and queued by the Gearman job server.
The callback should accept a single argument, a <classname>GearmanTask</classname> object.
Sets a callback function to be called when a task is received and queued by the Gearman job server.
</para>
<note>
<para>
The callback will only be triggered for tasks that are added (e.g. by calling <methodname>GearmanClient::addTask</methodname>)
after calling this method.
</para>
</note>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>function</parameter></term>
<term><parameter>callback</parameter></term>
<listitem>
<para>
A function to call
A function to call.
It must return either nothing (which defaults to <constant>GEARMAN_SUCCESS</constant>)
or a valid <link linkend="gearman.constants">Gearman return value</link>.
</para>
<methodsynopsis>
<type class="union"><type>int</type><type>void</type></type><methodname><replaceable>callback</replaceable></methodname>
<methodparam><type>GearmanTask</type><parameter>task</parameter></methodparam>
<methodparam><type>mixed</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<variablelist>
<varlistentry>
<term><parameter>task</parameter></term>
<listitem>
<para>
The task this callback is called for.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
Whatever has been passed to <methodname>GearmanClient::addTask</methodname> (or equivalent method) as <parameter>context</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist>
Expand Down
40 changes: 35 additions & 5 deletions reference/gearman/gearmanclient/setdatacallback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,54 @@
&reftitle.description;
<methodsynopsis role="GearmanClient">
<modifier>public</modifier> <type>bool</type><methodname>GearmanClient::setDataCallback</methodname>
<methodparam><type>callable</type><parameter>function</parameter></methodparam>
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
</methodsynopsis>
<para>
Sets the callback function for accepting data packets for a task. The callback function should
take a single argument, a <classname>GearmanTask</classname> object.
Sets the callback function for accepting data packets for a task.
</para>
<note>
<para>
The callback will only be triggered for tasks that are added (e.g. by calling <methodname>GearmanClient::addTask</methodname>)
after calling this method.
</para>
</note>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>function</parameter></term>
<term><parameter>callback</parameter></term>
<listitem>
<para>
A function or method to call
A function or method to call.
It must return either nothing (which defaults to <constant>GEARMAN_SUCCESS</constant>)
or a valid <link linkend="gearman.constants">Gearman return value</link>.
</para>
<methodsynopsis>
<type class="union"><type>int</type><type>void</type></type><methodname><replaceable>callback</replaceable></methodname>
<methodparam><type>GearmanTask</type><parameter>task</parameter></methodparam>
<methodparam><type>mixed</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<variablelist>
<varlistentry>
<term><parameter>task</parameter></term>
<listitem>
<para>
The task this callback is called for.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
Whatever has been passed to <methodname>GearmanClient::addTask</methodname> (or equivalent method) as <parameter>context</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist>
Expand Down
39 changes: 35 additions & 4 deletions reference/gearman/gearmanclient/setexceptioncallback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,54 @@
&reftitle.description;
<methodsynopsis role="GearmanClient">
<modifier>public</modifier> <type>bool</type><methodname>GearmanClient::setExceptionCallback</methodname>
<methodparam><type>callable</type><parameter>function</parameter></methodparam>
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
</methodsynopsis>
<para>
Specifies a function to call when a worker for a task sends an exception.
Specifies a callback function to call when a worker for a task sends an exception.
</para>
<note>
<para>
The callback will only be triggered for tasks that are added (e.g. by calling <methodname>GearmanClient::addTask</methodname>)
after calling this method.
</para>
</note>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>function</parameter></term>
<term><parameter>callback</parameter></term>
<listitem>
<para>
Function to call when the worker throws an exception
Function to call when the worker throws an exception.
It must return either nothing (which defaults to <constant>GEARMAN_SUCCESS</constant>)
or a valid <link linkend="gearman.constants">Gearman return value</link>.
</para>
<methodsynopsis>
<type class="union"><type>int</type><type>void</type></type><methodname><replaceable>callback</replaceable></methodname>
<methodparam><type>GearmanTask</type><parameter>task</parameter></methodparam>
<methodparam><type>mixed</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<variablelist>
<varlistentry>
<term><parameter>task</parameter></term>
<listitem>
<para>
The task this callback is called for.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
Whatever has been passed to <methodname>GearmanClient::addTask</methodname> (or equivalent method) as <parameter>context</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist>
Expand Down
40 changes: 35 additions & 5 deletions reference/gearman/gearmanclient/setfailcallback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,54 @@
&reftitle.description;
<methodsynopsis role="GearmanClient">
<modifier>public</modifier> <type>bool</type><methodname>GearmanClient::setFailCallback</methodname>
<methodparam><type>callable</type><parameter>function</parameter></methodparam>
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
</methodsynopsis>
<para>
Sets the callback function to be used when a task does not complete successfully. The function
should accept a single argument, a <classname>GearmanTask</classname> object.
Sets the callback function to be used when a task does not complete successfully.
</para>
<note>
<para>
The callback will only be triggered for tasks that are added (e.g. by calling <methodname>GearmanClient::addTask</methodname>)
after calling this method.
</para>
</note>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>function</parameter></term>
<term><parameter>callback</parameter></term>
<listitem>
<para>
A function to call
A function to call.
It must return either nothing (which defaults to <constant>GEARMAN_SUCCESS</constant>)
or a valid <link linkend="gearman.constants">Gearman return value</link>.
</para>
<methodsynopsis>
<type class="union"><type>int</type><type>void</type></type><methodname><replaceable>callback</replaceable></methodname>
<methodparam><type>GearmanTask</type><parameter>task</parameter></methodparam>
<methodparam><type>mixed</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<variablelist>
<varlistentry>
<term><parameter>task</parameter></term>
<listitem>
<para>
The task this callback is called for.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
Whatever has been passed to <methodname>GearmanClient::addTask</methodname> (or equivalent method) as <parameter>context</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist>
Expand Down
Loading