<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Untitled &#187; gearman</title>
	<atom:link href="http://ammonlauritzen.com/blog/tag/gearman/feed/" rel="self" type="application/rss+xml" />
	<link>http://ammonlauritzen.com/blog</link>
	<description>and still for good reason.</description>
	<lastBuildDate>Wed, 05 May 2010 18:43:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>gearman 0.3 php extension api</title>
		<link>http://ammonlauritzen.com/blog/2009/05/26/gearman-03-php-extension-api/</link>
		<comments>http://ammonlauritzen.com/blog/2009/05/26/gearman-03-php-extension-api/#comments</comments>
		<pubDate>Tue, 26 May 2009 21:10:17 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[gearman]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ammonlauritzen.com/blog/?p=500</guid>
		<description><![CDATA[No real preamble to be made here. Gearman is a distributed job queuing system by the fine folks who brought us memcached. It is nicer than anything else I&#8217;ve looked at. I am attempting to switch one of my projects over to it (replacing a crufty curl + unix sockets + memcached monstrosity that attempted [...]]]></description>
			<content:encoded><![CDATA[<p>No real preamble to be made here. <a href='http://gearman.org'>Gearman</a> is a distributed job queuing system by the <a href='http://danga.com/'>fine folks</a> who brought us <a href='http://danga.com/memcached/'>memcached</a>. It is nicer than anything else I&#8217;ve looked at. I am attempting to switch one of my projects over to it (replacing a crufty curl + unix sockets + memcached monstrosity that attempted to do the same job).</p>
<p>The documentation is lacking, but if the discussion group is any indication, real docs are a high priority for the project team. Today, I visited the IRC channel to ask for a status update on docs for the PHP extension api (as opposed to the PEAR all-script api, whose auto-generated docs are broken). Turns out my suspicions were right. Documentation is a high priority and none currently exists for the api in question. However&#8230; I was informed that the classes support reflection&#8230; so <img src='http://ammonlauritzen.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A quick grep of the source for the extension tells me that I am looking at four classes: GearmanClient, GearmanWorker, GearmanJob, and GearmanTask. A ridiculously short php script later&#8230;</p>
<pre class="brush: php;">
&lt;?
Reflection::export( new ReflectionClass('GearmanWorker') );
Reflection::export( new ReflectionClass('GearmanClient') );
Reflection::export( new ReflectionClass('GearmanJob') );
Reflection::export( new ReflectionClass('GearmanTask') );
?&gt;
</pre>
<p>And I can at least try to make a human readable list of available methods.</p>
<h3>GearmanWorker</h3>
<ul>
<li>__construct()</li>
<li>clone()</li>
<li>error()</li>
<li>returnCode()</li>
<li>setOptions( $option, $data )</li>
<li>addServer( $host, $port ) &#8211; both args optional, examples say defaults are localhost on port 4730.</li>
<li>addFunction( $function_name, $function, $data, $timeout ) &#8211; data and timeout optional</li>
<li>work()</li>
</ul>
<h3>GearmanClient</h3>
<ul>
<li>__construct()</li>
<li>clone()</li>
<li>error()</li>
<li>setOptions( $option, $data )</li>
<li>addServer( $host, $port ) &#8211; reflection says REQUIRED, however the provided examples and personal experience says otherwise</li>
<li>do( $function_name, $workload, $unique ) &#8211; unique is optional</li>
<li>doHigh( $function_name, $workload, $unique ) &#8211; unique is optional</li>
<li>doLow( $function_name, $workload, $unique ) &#8211; unique is optional</li>
<li>doJobHandle()</li>
<li>doStatus()</li>
<li>doBackground( $function_name, $workload, $unique ) &#8211; unique is optional</li>
<li>doHighBackground( $function_name, $workload, $unique ) &#8211; unique is optional</li>
<li>doLowBackground( $function_name, $workload, $unique ) &#8211; unique is optional</li>
<li>jobStatus( $job_handle )</li>
<li>echo( $workload )</li>
<li>addTask( $function_name, $workload, $data, $unique ) &#8211; data and unique are optional</li>
<li>addTaskHigh( $function_name, $workload, $data, $unique ) &#8211; data and unique are optional</li>
<li>addTaskLow( $function_name, $workload, $data, $unique ) &#8211; data and unique are optional</li>
<li>addTaskBackground( $function_name, $workload, $data, $unique ) &#8211; data and unique are optional</li>
<li>addTaskHighBackground( $function_name, $workload, $data, $unique ) &#8211; data and unique are optional</li>
<li>addTaskLowBackground( $function_name, $workload, $data, $unique ) &#8211; data and unique are optional</li>
<li>addTaskStatus( $job_handle, $data ) &#8211; data is optional</li>
<li>setWorkloadCallback( $callback )</li>
<li>setCreatedCallback( $callback)</li>
<li>setClientCallback( $callback)</li>
<li>setWarningCallback( $callback)</li>
<li>setStatusCallback( $callback)</li>
<li>setCompleteCallback( $callback)</li>
<li>setExceptionCallback( $callback)</li>
<li>setFailCallback( $callback)</li>
<li>clearCallbacks()</li>
<li>data()</li>
<li>setData( $data )</li>
<li>runTasks()</li>
</ul>
<h3>GearmanJob</h3>
<ul>
<li>__construct()</li>
<li>returnCode()</li>
<li>workload()</li>
<li>workloadSize()</li>
<li>warning( $warning )</li>
<li>status( $numerator, $denominator )</li>
<li>handle()</li>
<li>unique()</li>
<li>data( $data )</li>
<li>complete( $result )</li>
<li>exception( $exception )</li>
<li>fail()</li>
<li>functionName()</li>
<li>setReturn( $gearman_return_t )</li>
</ul>
<h3>GearmanTask</h3>
<ul>
<li>__construct()</li>
<li>returnCode()</li>
<li>create()</li>
<li>free()</li>
<li>function()</li>
<li>uuid()</li>
<li>jobHandle()</li>
<li>isKnown()</li>
<li>isRunning()</li>
<li>taskNumerator()</li>
<li>taskDenominator()</li>
<li>data()</li>
<li>dataSize()</li>
<li>takeData( $task_object ) &#8211; optional</li>
<li>sendData( $data )</li>
<li>recvData( $data_len )</li>
</ul>
<p>The extension also appears to expose all constants defined in the C api.</p>
<p>I have since added this to the official <a href='http://www.gearman.org/doku.php?id=php_reflection'>wiki</a> &#8211; so there are at least SOME docs on the site now <img src='http://ammonlauritzen.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://ammonlauritzen.com/blog/2009/05/26/gearman-03-php-extension-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
