Skip to content

Commit

Permalink
Merge pull request #12 from pmatseykanets/laravel7
Browse files Browse the repository at this point in the history
Add Laravel 7 + Pheanstalk 4 support
  • Loading branch information
pmatseykanets authored Apr 25, 2020
2 parents d90f789 + 6ec2c68 commit c739197
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [4.0.0](https://github.com/pmatseykanets/artisan-beans/releases/tag/v4.0.0) - 2020-04-25

### Changed

- Added Laravel 7 + Pheanstalk 4 support

## [3.0.0](https://github.com/pmatseykanets/artisan-beans/releases/tag/v3.0.0) - 2019-10-25

### Changed
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# artisan-beans

[![Laravel 5.x](https://img.shields.io/badge/Laravel-5.x-orange.svg)](http://laravel.com)
[![StyleCI](https://styleci.io/repos/41767069/shield)](https://styleci.io/repos/41767069)
[![Latest Stable Version](https://poser.pugx.org/pmatseykanets/artisan-beans/v/stable)](https://packagist.org/packages/pmatseykanets/artisan-beans)
[![Total Downloads](https://img.shields.io/packagist/dt/pmatseykanets/artisan-beans.svg?style=flat-square)](https://packagist.org/packages/pmatseykanets/artisan-beans)
Expand All @@ -22,12 +21,18 @@ This package brings a set of artisan commands that allows you manage your [Beans

You can install the package via composer:

### Laravel 5.6+, Laravel 6
### Laravel 6,7 (Pheanstalk 4)

```bash
composer require pmatseykanets/artisan-beans
```

### Laravel 5.6+, Laravel 6

```bash
composer require pmatseykanets/artisan-beans:3.0.0
```

### Laravel <= 5.5

```bash
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
],
"require": {
"php": "^7.2",
"illuminate/console": "~5.6|~6.0",
"illuminate/support": "~5.6|~6.0",
"pda/pheanstalk": "~3.2"
"illuminate/console": "~6.0|~7.0",
"illuminate/support": "~6.0|~7.0",
"pda/pheanstalk": "~4.0"
},
"autoload": {
"psr-4": {
Expand Down
17 changes: 8 additions & 9 deletions src/Console/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Pvm\ArtisanBeans\Console;

use Pheanstalk\Response;
use Pheanstalk\Pheanstalk;
use Illuminate\Console\Command;
use Pheanstalk\Exception\ServerException;
use Pheanstalk\Pheanstalk;
use Pheanstalk\Response;

abstract class BaseCommand extends Command
{
Expand Down Expand Up @@ -55,7 +55,7 @@ protected function peekJob($tube, $state)
$peekMethod = 'peek'.ucfirst($state);

try {
return $this->getPheanstalk()->$peekMethod($tube);
return $this->getPheanstalk()->useTube($tube)->$peekMethod($tube);
} catch (ServerException $e) {
if ($this->isNotFoundException($e)) {
return;
Expand All @@ -78,7 +78,7 @@ protected function peekJob($tube, $state)
protected function reserveJob($tube)
{
try {
return $this->getPheanstalk()->reserveFromTube($tube, 0);
return $this->getPheanstalk()->useTube($tube)->reserveWithTimeout(0);
} catch (ServerException $e) {
if ($this->isNotFoundException($e)) {
return;
Expand Down Expand Up @@ -164,10 +164,9 @@ protected function kickJob($tube, $count = 1)
*/
protected function putJob($tube, $body, $priority, $delay, $ttr)
{
$id = $this->getPheanstalk()
->putInTube($tube, $body, $priority, $delay, $ttr);

return $id;
return $this->getPheanstalk()
->useTube($tube)
->put($body, $priority, $delay, $ttr);
}

/**
Expand All @@ -178,7 +177,7 @@ protected function putJob($tube, $body, $priority, $delay, $ttr)
public function getPheanstalk()
{
if (! $this->pheanstalk) {
$this->pheanstalk = new Pheanstalk($this->host, $this->port);
$this->pheanstalk = Pheanstalk::create($this->host, $this->port);
}

return $this->pheanstalk;
Expand Down
4 changes: 2 additions & 2 deletions src/Console/PutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function handle()

$tube = $this->argument('tube') ?: $this->defaultTube;

$id = $this->putJob($tube, $this->body, $this->priority, $this->delay, $this->ttr);
$job = $this->putJob($tube, $this->body, $this->priority, $this->delay, $this->ttr);

$this->info("Added job with id $id to '$tube' with priority $this->priority, delay $this->delay, TTR $this->ttr");
$this->info("Added job with id {$job->getId()} to '$tube' with priority $this->priority, delay $this->delay, TTR $this->ttr");
}

/**
Expand Down

0 comments on commit c739197

Please sign in to comment.