karzilla: a green fist above the word SMASH! (Default)
[staff profile] karzilla

Bug counts: resolved 229, assigned 23, needs-review 19



Continuing on the subject of things that weren't as hard as I feared: making a gearman worker.

Here's your basic gearman worker in its entirety:
use LJ::Worker::Gearman;
gearman_decl( 'name-of-worker'  => \&worker );
gearman_work();
sub worker {
    # stuff what needs doing
}

And then you call it with something like LJ::gearman_client()->dispatch_background( 'name-of-worker', ...) (at least for my purposes, which were "go do this other time-consuming thing somewhere else and don't tell me what happens.")

The only real voodoo, AFAICT, is that you have to use Storable methods (freeze/thaw) for passing the function arguments from the web execution to the worker execution. I just did a copy and paste of code from someone else's worker script and it worked like a charm.

Later on I get to either write more gearman workers or overcome my fear of TheSchwartz, depending on whether or not gearman can do everything I need for delivering vgifts.

Date: 2010-08-30 05:43 pm (UTC)
alierak: (Default)
From: [personal profile] alierak
Also, it looks like the non-Gearman, non-Schwartz workers are: birthday-notify, directory-meta, expunge-users, paidstatus, search-updater, stats-collection, subscribe-hubbub, and t-memlimit. Most of those inherit from LJ::Worker::Manual, but a couple are just doing their own thing. I think these types may be suited for background tasks that are either periodic or asynchronously queued and don't need many bells and whistles.

Profile

karzilla: a green fist above the word SMASH! (Default)
Karzilla, Destroyer of Bugs

November 2022

S M T W T F S
  12345
678910 1112
13141516171819
20212223242526
27282930   

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 16th, 2026 12:14 pm
Powered by Dreamwidth Studios