Permalink
Browse files

example client

  • Loading branch information...
1 parent bdd2bb1 commit 1f0be6acb2e9ae5c616a9fbe3f930dfc3f8e5e24 @till till committed Dec 2, 2011
Showing with 37 additions and 0 deletions.
  1. +37 −0 pecl-client/example.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Run the reverse function.
+ *
+ * @link http://de2.php.net/manual/en/gearman.examples-reverse.php
+ */
+$gmclient= new GearmanClient();
+
+# Add default server (localhost).
+$gmclient->addServer();
+
+$function = 'reverse';
+$data = 'Hello!';
+
+do {
+
+ $result = $gmclient->do($function, $data);
+
+ switch($gmclient->returnCode()) {
+ case GEARMAN_WORK_DATA:
+ echo "Data: $result\n";
+ break;
+ case GEARMAN_WORK_STATUS:
+ list($numerator, $denominator)= $gmclient->doStatus();
+ echo "Status: $numerator/$denominator complete\n";
+ break;
+ case GEARMAN_WORK_FAIL:
+ echo "Failed\n";
+ exit;
+ case GEARMAN_SUCCESS:
+ break;
+ default:
+ echo "RET: " . $gmclient->returnCode() . "\n";
+ exit;
+ }
+}
+while($gmclient->returnCode() != GEARMAN_SUCCESS);

0 comments on commit 1f0be6a

Please sign in to comment.