Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

Commit 88b3406

Browse files
committed
changes
1 parent 7e025b4 commit 88b3406

File tree

17 files changed

+75
-20
lines changed

17 files changed

+75
-20
lines changed

.gitignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
/app/logs/*
44
!app/cache/.gitkeep
55
!app/logs/.gitkeep
6-
!bin/sidekiq
7-
!bin/sidekiq-web
86

97
# Cache and logs (Symfony3)
108
/var/cache/*
@@ -24,6 +22,10 @@
2422
/bin/*
2523
!bin/console
2624
!bin/symfony_requirements
25+
!bin/sidekiq
26+
!bin/sidekiq-web
27+
!bin/sidekiq-enterprise
28+
!bin/sidekiq-web-enterprise
2729
/vendor/
2830

2931
# Assets and user uploads

app/config/routing_dev.yml

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ _profiler:
66
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
77
prefix: /_profiler
88

9-
_configurator:
10-
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
11-
prefix: /_configurator
12-
139
_errors:
1410
resource: "@TwigBundle/Resources/config/routing/errors.xml"
1511
prefix: /_error

app/workers/user_tracker_process.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class UserTrackerProcess
2+
include Sidekiq::Worker
3+
4+
def perform(*arguments)
5+
return true
6+
end
7+
end

bin/sidekiq

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
bundle exec sidekiq -r ./sidekiq.rb -C ./sidekiq.yml

bin/sidekiq-enterprise

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
bundle exec sidekiq -r ./sidekiq-enterprise.rb -C ./sidekiq.yml

bin/sidekiq-web

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
bundle exec rackup -o 0.0.0.0 ./config.ru

bin/sidekiq-web-enterprise

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
bundle exec rackup -o 0.0.0.0 ./config-enterprise.ru

sidekiq.rb

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
ENV['RAILS_ENV'] = ENV['RAILS_ENV'] != "development" ? ENV['RAILS_ENV'] : "devbox"
1919

20-
2120
# Redis connection
2221
if ENV['RAILS_ENV'] == 'production'
2322
rediscfg = { url: 'redis://127.0.0.1:6379/0' }

src/DLabs/UserBundle/Command/UserQueuePushCommand.php renamed to src/DLabs/UserBundle/Command/UserEnqueueCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
use Symfony\Component\Console\Input\InputOption;
1010

1111

12-
class UserQueuePushCommand extends ContainerAwareCommand
12+
class UserEnqueueCommand extends ContainerAwareCommand
1313
{
1414
protected function configure()
1515
{
1616
$this
17-
->setName('user:queue:push')
17+
->setName('user:enqueue')
1818
->setDescription('Push tasks to queeue')
1919
->addOption('num', null, InputOption::VALUE_OPTIONAL, 'Number of tasks', 100);
2020
;
@@ -25,7 +25,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
2525
$numTasks = $input->getOption('num'); // add this many
2626

2727
$container = $this->getContainer();
28-
$pushService = $container->get('dlabs.worker.push_user');
28+
$pushService = $container->get('dlabs.worker.enqueue_user');
2929
$progress = new ProgressBar($output, $numTasks);
3030

3131
for($i = 0; $i < $numTasks; $i++){
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace DLabs\UserBundle\Command;
4+
5+
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
use Symfony\Component\Console\Helper\ProgressBar;
9+
use Symfony\Component\Console\Input\InputOption;
10+
11+
12+
class UserTrackerEnqueueCommand extends ContainerAwareCommand
13+
{
14+
protected function configure()
15+
{
16+
$this
17+
->setName('user:tracker:enqueue')
18+
->setDescription('Push tasks to queeue')
19+
->addOption('num', null, InputOption::VALUE_OPTIONAL, 'Number of tasks', 100);
20+
;
21+
}
22+
23+
protected function execute(InputInterface $input, OutputInterface $output)
24+
{
25+
$numTasks = $input->getOption('num'); // add this many
26+
27+
$container = $this->getContainer();
28+
$pushService = $container->get('dlabs.worker.enqueue_user');
29+
$progress = new ProgressBar($output, $numTasks);
30+
31+
for($i = 0; $i < $numTasks; $i++){
32+
$pushService->execute('user.tracker_process',[rand()]);
33+
$progress->advance();
34+
}
35+
}
36+
}

src/DLabs/UserBundle/DependencyInjection/DLabsUserExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ public function load(array $configs, ContainerBuilder $container)
2323
$config = $this->processConfiguration($configuration, $configs);
2424

2525
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
26-
$loader->load('services.yml');
26+
$loader->load('queue_handler.yml');
2727
}
2828
}

src/DLabs/UserBundle/Resources/config/queue_handler.yml

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ services:
22
dlabs.user.queue_handler.do_nothing:
33
class: DLabs\UserBundle\Service\QueueHandler\DoNothingQueueHandler
44

5+
dlabs.user.queue_handler.tracker_process__dummy:
6+
class: DLabs\UserBundle\Service\QueueHandler\DoNothingQueueHandler
7+

src/DLabs/UserBundle/Resources/config/services.yml

-3
This file was deleted.

src/DLabs/UserBundle/Service/QueueHandler/DoNothingQueueHandler.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class DoNothingQueueHandler implements QueueHandlerInterface
88
{
99
public function execute()
1010
{
11-
// Does nothing
11+
if (time() % 4 === 0){
12+
throw new \Exception("That's really unlucky. ");
13+
}
1214
}
1315
}

src/DLabs/WorkerBundle/Command/WorkerGenerateCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5757

5858
$output->writeln(sprintf('Generated <info>%s</info>', "app/workers/{$filename}"));
5959
}else{
60+
$filename = str_replace('__dummy','', $filename);
6061
$output->writeln(sprintf('Skipping <info>%s</info>', "app/workers/{$filename}"));
6162
}
6263
}

src/DLabs/WorkerBundle/Resources/config/worker.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ services:
22
# ----------------------------------------
33
# Push to queue tasks
44
# ----------------------------------------
5-
dlabs.worker.push:
6-
class: DLabs\WorkerBundle\Service\Queue\PushToQueue
5+
dlabs.worker.enqueue:
6+
class: DLabs\WorkerBundle\Service\Queue\Enqueue
77
arguments:
88
- '@dlabs.worker.sidekiq_client.default'
99
- default
1010
- '@dlabs.worker.generator.sidekiq_worker_name'
1111

12-
dlabs.worker.push_user:
13-
class: DLabs\WorkerBundle\Service\Queue\PushToQueue
12+
dlabs.worker.enqueue_user:
13+
class: DLabs\WorkerBundle\Service\Queue\Enqueue
1414
arguments:
1515
- '@dlabs.worker.sidekiq_client.user'
1616
- user

src/DLabs/WorkerBundle/Service/Queue/PushToQueue.php renamed to src/DLabs/WorkerBundle/Service/Queue/Enqueue.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/**
99
*/
10-
class PushToQueue
10+
class Enqueue
1111
{
1212
/** @var Client */
1313
protected $client;

0 commit comments

Comments
 (0)