This commit is contained in:
2021-04-22 11:56:33 +08:00
parent e9ba5ced39
commit 978cc92dad
2 changed files with 254 additions and 245 deletions
+4 -5
View File
@@ -11,6 +11,7 @@ use ReflectionException;
use Snowflake\Abstracts\Component;
use Snowflake\Abstracts\Config;
use Snowflake\Event;
use Snowflake\Exception\ConfigException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake;
@@ -147,9 +148,8 @@ class Producer extends Component
/**
* @param $topic
* @param $groupId
* @param $brokers
* @return ProducerTopic
* @throws \Snowflake\Exception\ConfigException
* @throws ConfigException
* @throws Exception
*/
private function beforePushMessage($topic, $groupId): void
{
@@ -172,7 +172,6 @@ class Producer extends Component
/**
* @param TopicConf $topicConf
* @param string $topic
* @param array $message
* @param string $key
@@ -205,8 +204,8 @@ class Producer extends Component
}
/**
* @param string $topic
* @param \RdKafka\Producer $producer
* @param ProducerTopic $producerTopic
* @throws Exception
+12 -2
View File
@@ -187,7 +187,7 @@ abstract class Crontab extends BaseObject
$redis->del('crontab:' . $this->getName());
$redis->del('stop:crontab:' . $this->getName());
} else {
$redis->set('crontab:' . ($name = $this->getName()), swoole_serialize($this));
$redis->set('crontab:' . ($name = $this->getName()), static::getSerialize($this));
$tickTime = time() + $this->getTickTime();
$redis->zAdd(Producer::CRONTAB_KEY, $tickTime, $name);
}
@@ -241,6 +241,16 @@ abstract class Crontab extends BaseObject
}
/**
* @param $class
* @return string
*/
public static function getSerialize($class): string
{
return serialize($class);
}
/**
* @throws Exception
*/
@@ -251,7 +261,7 @@ abstract class Crontab extends BaseObject
$name_md5 = $this->getName();
$redis->hSet(self::WAIT_END, $name_md5, serialize($this));
$redis->hSet(self::WAIT_END, $name_md5, static::getSerialize($this));
$params = call_user_func([$this, 'process'], ...$this->params);
$redis->hDel(self::WAIT_END, $name_md5);