Class: Chimp::ChimpDaemon::GroupServlet
- Inherits:
-
GenericServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- GenericServlet
- Chimp::ChimpDaemon::GroupServlet
- Defined in:
- lib/right_chimp/daemon/ChimpDaemon.rb
Overview
GroupServlet - group information and control
Instance Method Summary collapse
-
#do_GET(req, resp) ⇒ Object
GET a group by name and status /group/<name>/<status>.
-
#do_POST(req, resp) ⇒ Object
POST to a group to trigger a group action /group/<name>/<action>.
Methods inherited from GenericServlet
#get_id, #get_payload, #get_verb
Instance Method Details
#do_GET(req, resp) ⇒ Object
GET a group by name and status /group/<name>/<status>
276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/right_chimp/daemon/ChimpDaemon.rb', line 276 def do_GET(req, resp) jobs = {} group_name = req.request_uri.path.split('/')[-2] filter = req.request_uri.path.split('/')[-1] g = ChimpQueue[group_name.to_sym] raise WEBrick::HTTPStatus::NotFound, "Group not found" unless g jobs = g.get_jobs_by_status(filter) resp.body = jobs.to_yaml raise WEBrick::HTTPStatus::OK end |
#do_POST(req, resp) ⇒ Object
POST to a group to trigger a group action /group/<name>/<action>
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/right_chimp/daemon/ChimpDaemon.rb', line 293 def do_POST(req, resp) group_name = req.request_uri.path.split('/')[-2] filter = req.request_uri.path.split('/')[-1] payload = self.get_payload(req) if filter == 'create' ChimpQueue.instance.create_group(group_name, payload['type'], payload['concurrency']) elsif filter == 'retry' group = ChimpQueue[group_name.to_sym] raise WEBrick::HTTPStatus::NotFound, "Group not found" unless group group.requeue_failed_jobs! raise WEBrick::HTTPStatus::OK else raise WEBrick::HTTPStatus::PreconditionFailed.new("invalid action") end end |