mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 12:47:55 +08:00
Fixed bug.
This commit is contained in:
parent
e297726da6
commit
94746088d7
@ -52,14 +52,17 @@ class Message implements MessageInterface, Serializable
|
||||
$this->job = $this->job->generate();
|
||||
}
|
||||
|
||||
return serialize($this->job);
|
||||
return serialize([$this->job, $this->attempts]);
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$this->job = unserialize($serialized);
|
||||
if ($this->job instanceof CodeDegenerateInterface) {
|
||||
$this->job = $this->job->degenerate();
|
||||
[$job, $attempts] = unserialize($serialized);
|
||||
if ($job instanceof CodeDegenerateInterface) {
|
||||
$job = $job->degenerate();
|
||||
}
|
||||
|
||||
$this->job = $job;
|
||||
$this->attempts = $attempts;
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class RedisDriverTest extends TestCase
|
||||
$driver->push(new DemoJob($id, $model));
|
||||
|
||||
$serialized = (string) Context::get('test.async-queue.lpush.value');
|
||||
$this->assertSame(218, strlen($serialized));
|
||||
$this->assertSame(236, strlen($serialized));
|
||||
|
||||
/** @var Message $class */
|
||||
$class = $packer->unpack($serialized);
|
||||
@ -105,6 +105,9 @@ class RedisDriverTest extends TestCase
|
||||
|
||||
$key = Context::get('test.async-queue.lpush.key');
|
||||
$this->assertSame('test:waiting', $key);
|
||||
|
||||
$this->assertSame(true, $class->attempts());
|
||||
$this->assertSame(false, $class->attempts());
|
||||
}
|
||||
|
||||
protected function getContainer()
|
||||
|
@ -20,6 +20,8 @@ class DemoJob extends Job
|
||||
|
||||
public $model;
|
||||
|
||||
protected $maxAttempts = 1;
|
||||
|
||||
public function __construct($id, $model = null)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
Loading…
Reference in New Issue
Block a user