Introdução a
Worker ⚙
Faça parte da
comunidade que mais
cresce 🐘👊💯🆙💹
• Dê feedback
• Manifeste-se
• Interaja
• Faça amigos 👲👳👦👽+🍻
• Ajude!
phpsc.com.br
sergiors.com
Importar tabela de dados
Enviar emails
Reporting
Fatal error: Allowed memory size of
….
Worker ⚙⁉
Um processo que fica
rodando, esperando por
tarefas do usuário.
Seus workers, seus processos.
É necessário ter o controle
do servidor.
Message Queue
!=
Worker
Job
Message
Queue
Worker
Qualquer tarefa que você deseja
fazer.
Responsável por gerenciar suas
tarefas. Ex: Beanstalkd,
RabbitMQ, Gearman…
Executa (consome) as tarefas.
Job Message Queue Worker
Processos que podem
causar latência
• Mailing
• Reporting
• Web crawling
Processos diferentes,
workers diferentes⁉
https://github.com/sergiors/worker
Command Pattern
interface CommandInterface
{
public function setContainer(ArrayAccess $container);
public function execute();
}
* @var CommandInterface
*/
protected $command;
/**
* @param ArrayAccess $container
*/
public function __construct(ArrayAccess $container)
{
$this->container = $container;
}
/**
* @param CommandInterface $command
*/
public function setCommand(CommandInterface $command)
{
$this->command = $command;
$this->command->setContainer($this->container);
}
public function run()
{
$this->command->execute();
}
}
Hands on!
max_execution_time: The default setting is 30. When running
PHP from the command line the default setting is 0.
set_time_limit(0)
😤😤😤
Go beyond
• Supervisor
• Monolog
Go beyond
• Asynchronous
Dúvidas⁉
🍻Obrigado!
$beer = new BringMeBeerCommand();
$beer->setWho('Everyone');
$beer->execute();

Introdução a worker