Final Class Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner
| Inheritance | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner » Yiisoft\Yii\Runner\ApplicationRunner |
|---|
RoadRunnerGrpcApplicationRunner runs the Yii gRPC application using RoadRunner.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner | |
| getInvoker() | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner | |
| getServices() | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner | |
| getWorker() | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner | |
| run() | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner | |
| setServices() | Transmitted services for registration gRPC server | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner |
| withTemporaryErrorHandler() | Returns a new instance with the specified temporary error handler instance {@see ErrorHandler}. | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner |
| withWorker() | Returns a new instance with the specified gRPC worker instance | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerGrpcApplicationRunner |
Method Details
| public mixed __construct ( string $rootPath, boolean $debug = false, boolean $checkEvents = false, string|null $environment = null, string $bootstrapGroup = 'bootstrap-web', string $eventsGroup = 'events-web', string $diGroup = 'di-web', string $diProvidersGroup = 'di-providers-web', string $diDelegatesGroup = 'di-delegates-web', string $diTagsGroup = 'di-tags-web', string $paramsGroup = 'params-web', array $nestedParamsGroups = ['params'], array $nestedEventsGroups = ['events'], \Psr\Log\LoggerInterface|null $logger = null, \Yiisoft\ErrorHandler\ErrorHandler|null $temporaryErrorHandler = null ) | ||
| $rootPath | string |
The absolute path to the project root. |
| $debug | boolean |
Whether the debug mode is enabled. |
| $checkEvents | boolean |
Whether to check events' configuration. |
| $environment | string|null |
The environment name. |
| $bootstrapGroup | string |
The bootstrap configuration group name. |
| $eventsGroup | string |
The events' configuration group name. |
| $diGroup | string |
The container definitions' configuration group name. |
| $diProvidersGroup | string |
The container providers' configuration group name. |
| $diDelegatesGroup | string |
The container delegates' configuration group name. |
| $diTagsGroup | string |
The container tags' configuration group name. |
| $paramsGroup | string |
The configuration parameters group name. |
| $nestedParamsGroups | array |
Configuration group names that are included into configuration parameters group. This is needed for recursive merging of parameters. |
| $nestedEventsGroups | array |
Configuration group names that are included into events' configuration group. This is needed for reverse and recursive merge of events' configurations. |
| $logger | \Psr\Log\LoggerInterface|null | |
| $temporaryErrorHandler | \Yiisoft\ErrorHandler\ErrorHandler|null | |
public function __construct(
string $rootPath,
bool $debug = false,
bool $checkEvents = false,
?string $environment = null,
string $bootstrapGroup = 'bootstrap-web',
string $eventsGroup = 'events-web',
string $diGroup = 'di-web',
string $diProvidersGroup = 'di-providers-web',
string $diDelegatesGroup = 'di-delegates-web',
string $diTagsGroup = 'di-tags-web',
string $paramsGroup = 'params-web',
array $nestedParamsGroups = ['params'],
array $nestedEventsGroups = ['events'],
private readonly ?LoggerInterface $logger = null,
private ?ErrorHandler $temporaryErrorHandler = null
) {
parent::__construct(
$rootPath,
$debug,
$checkEvents,
$environment,
$bootstrapGroup,
$eventsGroup,
$diGroup,
$diProvidersGroup,
$diDelegatesGroup,
$diTagsGroup,
$paramsGroup,
$nestedParamsGroups,
$nestedEventsGroups,
);
}
| public \Spiral\RoadRunner\GRPC\InvokerInterface getInvoker ( ) |
public function getInvoker(): InvokerInterface
{
return $this->invoker ?? new Invoker();
}
| public \Spiral\RoadRunner\Worker getWorker ( ) |
public function getWorker(): Worker
{
return $this->worker ?? Worker::create();
}
| public void run ( ) | ||
| throws | \Psr\Container\ContainerExceptionInterface | |
|---|---|---|
| throws | \Yiisoft\ErrorHandler\Exception\ErrorException | |
| throws | \Psr\Container\NotFoundExceptionInterface | |
| throws | ErrorException | |
| throws | \Yiisoft\Definitions\Exception\InvalidConfigException | |
public function run(): void
{
// Register temporary error handler to catch error while container is building.
$temporaryErrorHandler = $this->createTemporaryErrorHandler();
$this->registerErrorHandler($temporaryErrorHandler);
$container = $this->getContainer();
// Register error handler with real container-configured dependencies.
/** @var ErrorHandler $actualErrorHandler */
$actualErrorHandler = $container->get(ErrorHandler::class);
$this->registerErrorHandler($actualErrorHandler, $temporaryErrorHandler);
$this->runBootstrap();
$this->checkEvents();
$server = new Server($this->getInvoker(), ['debug' => $this->debug]);
/**
* @var class-string<ServiceInterface> $interface
*/
foreach ($this->getServices() as $interface) {
/** @var ServiceInterface $service */
$service = $container->get($interface);
$server->registerService($interface, $service);
}
$server->serve($this->getWorker(), finalize: function () use ($container) {
$this->afterRespond($container);
});
}
Transmitted services for registration gRPC server
| public $this setServices ( array $services ) | ||
| $services | array |
Services array (key-value pairs)
]
|
public function setServices(array $services): self
{
$this->services = $services;
return $this;
}
Returns a new instance with the specified temporary error handler instance {@see ErrorHandler}.
A temporary error handler is needed to handle the creation of configuration and container instances, then the error handler configured in your application configuration will be used.
| public self withTemporaryErrorHandler ( \Yiisoft\ErrorHandler\ErrorHandler $temporaryErrorHandler ) | ||
| $temporaryErrorHandler | \Yiisoft\ErrorHandler\ErrorHandler |
The temporary error handler instance. |
public function withTemporaryErrorHandler(ErrorHandler $temporaryErrorHandler): self
{
$new = clone $this;
$new->temporaryErrorHandler = $temporaryErrorHandler;
return $new;
}
Returns a new instance with the specified gRPC worker instance
| public $this withWorker ( \Spiral\RoadRunner\Worker $worker ) | ||
| $worker | \Spiral\RoadRunner\Worker | |
public function withWorker(Worker $worker): self
{
$instance = clone $this;
$instance->worker = $worker;
return $instance;
}
Signup or Login in order to comment.