Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

peek jobs in a tube

  • Loading branch information...
commit 36810a672a31c4936deed8ca0e1c6e4aa35e0b5a 1 parent 7d222f2
@rizen rizen authored
View
28 lib/Wing/Rest/Wingman.pm
@@ -77,6 +77,34 @@ post '/api/wingman/tubes/:tube/pause' => sub {
}
};
+get '/api/wingman/tubes/:tube/jobs/buried' => sub {
+ my $user = get_user_by_session_id()->verify_is_admin();
+ my $job = Wingman->new->peek_buried(params->{tube});
+ if (defined $job) {
+ return $job->describe;
+ }
+ ouch 404, 'No buried jobs.';
+};
+
+get '/api/wingman/tubes/:tube/jobs/ready' => sub {
+ my $user = get_user_by_session_id()->verify_is_admin();
+ my $job = Wingman->new->peek_ready(params->{tube});
+ if (defined $job) {
+ return $job->describe;
+ }
+ ouch 404, 'No ready jobs.';
+};
+
+get '/api/wingman/tubes/:tube/jobs/delayed' => sub {
+ my $user = get_user_by_session_id()->verify_is_admin();
+ my $job = Wingman->new->peek_delayed(params->{tube});
+ if (defined $job) {
+ return $job->describe;
+ }
+ ouch 404, 'No delayed jobs.';
+};
+
+
### JOBS
get '/api/wingman/jobs' => sub {
View
57 lib/Wingman.pm
@@ -312,45 +312,90 @@ sub peek {
return undef;
}
-=head2 peek_ready ( )
+=head2 peek_ready ( [ tube ] )
Fetch the next ready job without reserving it.
+=over
+
+=item tube
+
+What tube to peek into. Defaults to default tube.
+
+=back
+
=cut
sub peek_ready {
- my ($self) = @_;
+ my ($self, $tube) = @_;
+ my $default_tube = Wing->config->get('wingman/beanstalkd/default_tube');
+ if (defined $tube && $tube ne $default_tube) {
+ $self->use($tube);
+ }
my $beanstalk_job = $self->beanstalk->peek_ready;
+ if (defined $tube && $tube ne $default_tube) {
+ $self->use($default_tube);
+ }
if (defined $beanstalk_job) {
return $self->_instantiate_job($beanstalk_job);
}
return undef;
}
-=head2 peek_delayed ( )
+=head2 peek_delayed ( [ tube ] )
Fetch the next delayed job without reserving it.
+=over
+
+=item tube
+
+What tube to peek into. Defaults to default tube.
+
+=back
+
=cut
sub peek_delayed {
- my ($self) = @_;
+ my ($self, $tube) = @_;
+ my $default_tube = Wing->config->get('wingman/beanstalkd/default_tube');
+ if (defined $tube && $tube ne $default_tube) {
+ $self->use($tube);
+ }
my $beanstalk_job = $self->beanstalk->peek_delayed;
+ if (defined $tube && $tube ne $default_tube) {
+ $self->use($default_tube);
+ }
if (defined $beanstalk_job) {
return $self->_instantiate_job($beanstalk_job);
}
return undef;
}
-=head2 peek_buried ( )
+=head2 peek_buried ( [ tube ] )
Fetch the next buried job without reserving it.
+=over
+
+=item tube
+
+What tube to peek into. Defaults to default tube.
+
+=back
+
=cut
sub peek_buried {
- my ($self) = @_;
+ my ($self, $tube) = @_;
+ my $default_tube = Wing->config->get('wingman/beanstalkd/default_tube');
+ if (defined $tube && $tube ne $default_tube) {
+ $self->use($tube);
+ }
my $beanstalk_job = $self->beanstalk->peek_buried;
+ if (defined $tube && $tube ne $default_tube) {
+ $self->use($default_tube);
+ }
if (defined $beanstalk_job) {
return $self->_instantiate_job($beanstalk_job);
}
View
6 public/wing.js
@@ -15,6 +15,12 @@ wing.info = function(message) {
});
};
+wing.dump_keys = function(object) {
+ var keys = [];
+ for(var k in object) keys.push(k);
+ wing.info(keys.join(' '));
+};
+
wing.warn = function(message) {
$.pnotify({
title: 'Warning',
View
9 var/init/views/admin/wingman_tube.tt
@@ -15,6 +15,9 @@
<th># Kicks</th>
</tr>
</table>
+<button class="btn btn-primary" onclick="return peek('ready');">Peek Ready</button>
+<button class="btn btn-primary" onclick="return peek('delayed');">Peek Delayed</button>
+<button class="btn btn-primary" onclick="return peek('buried');">Peek Buried</button>
<h3>Actions</h3>
<div class="row">
@@ -138,6 +141,12 @@ function add_job() {
});
return false;
}
+
+function peek(type) {
+ wing.ajax('GET', 'wingman/tubes/[% tube_name %]/jobs/' + type, {}, function(data) {
+ window.location = '/admin/wingman/jobs/' + data.result.id;
+ });
+}
</script>
[% END %]
[% INCLUDE admin/footer_include.tt %]

0 comments on commit 36810a6

Please sign in to comment.
Something went wrong with that request. Please try again.