Skip to content

Commit

Permalink
使用topic交换机
Browse files Browse the repository at this point in the history
添加token校验服务
add style ci config
  • Loading branch information
runphp committed Sep 19, 2017
1 parent 830257d commit 481d108
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .styleci.yml
@@ -0,0 +1,16 @@
preset: recommended

risky: true

enabled:
- ordered_class_elements
- declare_strict_types
- no_empty_comment
- no_null_property_initialization

disabled:
- phpdoc_var_without_name

finder:
name:
- "*.php"
2 changes: 1 addition & 1 deletion src/Events/Listener/AsyncAnnotationListener.php
Expand Up @@ -52,7 +52,7 @@ public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
'time' => microtime(true),
];
$producer = $this->queueFactory->createProducer();
$producer->setExchangeOptions(['name' => '_PHEX_'.$dispatcher->getModuleName(), 'type' => 'direct']);
$producer->setExchangeOptions(['name' => '_PHEX_'.$dispatcher->getModuleName(), 'type' => 'topic']);
$routingKey = $annotation->getNamedParameter('route') ?? $dispatcher->getModuleName();
$producer->publish(json_encode($msgBody), $routingKey);
if ($event->isCancelable()) {
Expand Down
7 changes: 7 additions & 0 deletions src/Mvc/AbstractModule.php
Expand Up @@ -15,6 +15,8 @@

use Eelly\Application\ApplicationConst;
use Eelly\Di\Injectable;
use Eelly\Events\Listener\ApiLoggerListener;
use Eelly\Events\Listener\ValidateAccessTokenListener;
use Eelly\SDK\EellyClient;
use Phalcon\Config;
use Phalcon\DiInterface as Di;
Expand Down Expand Up @@ -105,6 +107,11 @@ public function registerServices(Di $di): void
});
// register user services
$this->registerUserServices($di);
$eventsManager = $this->eventsManager;
// 日志记录
$eventsManager->enablePriorities(true);
// token 校验
$eventsManager->attach('dispatch', $di->getShared(ValidateAccessTokenListener::class), 10000);
// attach events
$this->attachUserEvents($di);
}
Expand Down

0 comments on commit 481d108

Please sign in to comment.