You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
namespace App\Controller;
|
|
|
|
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
use Hyperf\HttpServer\Annotation\AutoController;
|
|
use Hyperf\Utils\Coroutine;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
use Hyperf\Task\TaskExecutor;
|
|
use Hyperf\Task\Task;
|
|
use App\TaskWorker\SSDBTask;
|
|
|
|
/**
|
|
* @AutoController()
|
|
* Class TestController
|
|
* @package App\Controller
|
|
*/
|
|
class TestController extends AbstractController
|
|
{
|
|
private $name = 'default action';
|
|
|
|
|
|
public function index1(RequestInterface $request)
|
|
{
|
|
// $container = ApplicationContext::getContainer();
|
|
// $exec = $container->get(TaskExecutor::class);
|
|
// $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id()]));
|
|
|
|
$client = ApplicationContext::getContainer()->get(SSDBTask::class);
|
|
$result = $client->exec("set","bar","1234");
|
|
$result = $client->exec("get","bar");
|
|
|
|
// $client = ApplicationContext::getContainer()->get(MethodTask::class);
|
|
// $result = $client->handle("set");
|
|
|
|
$this->name = 'index1 action '. $result;
|
|
return $this->name;
|
|
}
|
|
|
|
public function index2(RequestInterface $request)
|
|
{
|
|
$this->name = 'index2 action';
|
|
return $this->name;
|
|
}
|
|
|
|
public function index3(RequestInterface $request)
|
|
{
|
|
return $this->name;
|
|
}
|
|
}
|