Skip to content

Instantly share code, notes, and snippets.

@marcusramberg
Created August 6, 2013 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusramberg/6169114 to your computer and use it in GitHub Desktop.
Save marcusramberg/6169114 to your computer and use it in GitHub Desktop.
my $coll=$self->mango->db->collection('control');
$coll->drop;
$coll->create({capped=>\1, max=>2, size=>100});
$self->{control} = $coll->find->tailable(1);
$self->{control}->timeout(-1);
my $cb;
$cb= sub {
my ($sub, $err,$doc) = @_;
return $sub->next($cb) if $err;
my $action = "ctrl_".$doc->{command};
$self->$action($doc->{cid});
};
$self->{control}->next($cb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment