Examples out of date

Bug #1397141 reported by Steven Barre
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
New
Undecided
Unassigned

Bug Description

Some of the code in the examples folder appears to be out of date.

I'm a PHP person, so I could be wrong here. I got here seeing that the PHP documentation is also out of date and found it was simply based on the example C++ code.

According to the Changelog http://gearman.info/changes.html in v0.21 the do function was changed to always complete. I think its now a blocking operation and can't get back status from the worker. It will either succeed or fail.

reverse_client.cc has code to get back the status, but as best as I can tell, this doesn't actually work anymore.

=================================================
  do
  {
    size_t result_size;
    char *result;
    result= (char *)gearman_client_do(&client, "reverse", NULL,
                                      text_to_echo.c_str(), text_to_echo.size(),
                                      &result_size, &ret);
    if (ret == GEARMAN_WORK_DATA)
    {
      std::cout.write(result, result_size);

      free(result);
      continue;
    }
    else if (ret == GEARMAN_WORK_STATUS)
    {
      uint32_t numerator;
      uint32_t denominator;

      gearman_client_do_status(&client, &numerator, &denominator);
      std::clog << "Status: " << numerator << "/" << denominator << std::endl;
      continue;
    }
    else if (ret == GEARMAN_SUCCESS)
    {
      std::cout.write(result, result_size);
      free(result);
    }
    else if (ret == GEARMAN_WORK_FAIL)
    {
      gearmand::error::message("Work failed");
      exit_code= EXIT_FAILURE;
      break;
    }
    else
    {
      gearmand::error::message(gearman_client_error(&client));
      exit_code= EXIT_FAILURE;
      break;
    }

    --count;

  } while (count);

=================================================

From my reading of the _cliend_do function http://bazaar.launchpad.net/~tangent-trunk/gearmand/1.0/view/head:/libgearman/client.cc#L114 it will only return GEARMAN_SUCCESS or an error, never work status or work data.

Again, I'm a PHP person, so I may be wrong here. I know this is likely a low priority, but if someone could at least just confirm my understanding I'll be happy for now.

Thanks for the amazing tool!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.