Skip to content

Commit

Permalink
Merge pull request #11 from myLocalInfluence/feat/add-attributes-in-r…
Browse files Browse the repository at this point in the history
…aw-body

feat: Add Uuid Attribute
  • Loading branch information
kangoo13 authored Nov 25, 2020
2 parents a76d9db + eca2bf2 commit 17617bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"illuminate/queue": "5.7.* | 5.8.* | ^6.0 | ^7.0 | ^8.0",
"illuminate/bus": "5.7.* | 5.8.* | ^6.0 | ^7.0 | ^8.0",
"google/cloud-pubsub": "^1.1",
"ext-json": "*"
"ext-json": "*",
"ramsey/uuid": "^4.1"
},
"require-dev": {
"phpspec/phpspec": "^5.1|^6.1"
Expand Down
11 changes: 7 additions & 4 deletions src/PubSub/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Myli\PlainJobs\PubSub;

use Illuminate\Queue\Jobs\Job as IlluminateJob;
use Google\Cloud\PubSub\Message;
use Illuminate\Container\Container;
use Illuminate\Contracts\Queue\Job as JobContract;
use Illuminate\Queue\Jobs\Job as IlluminateJob;
use Ramsey\Uuid\Uuid;

class Job extends IlluminateJob implements JobContract
{
Expand Down Expand Up @@ -72,12 +73,13 @@ public function getJobId()
public function getRawBody()
{
$fullData = [
'data' => json_decode(base64_decode($this->job->data()), true),
'attributes' => $this->job->attributes()
'data' => json_decode(base64_decode($this->job->data()), true) ?? [],
'attributes' => $this->job->attributes() ?? []
];
$newArray = [
'job' => $this->classHandler . '@handle',
'data' => $fullData,
'uuid' => Uuid::uuid4()
];

return json_encode($newArray);
Expand Down Expand Up @@ -108,7 +110,8 @@ public function attempts()
/**
* Release the job back into the queue.
*
* @param int $delay
* @param int $delay
*
* @return void
*/
public function release($delay = 0)
Expand Down

0 comments on commit 17617bf

Please sign in to comment.