Skip to content

Commit

Permalink
Rename context scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Aug 30, 2024
1 parent d1cb4ee commit cc7441f
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Centrifugo/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function serve(CentrifugoWorkerInterface $worker): void
$services = $this->services;

$scope->runScope(
new Scope('centrifugo.request', [RequestInterface::class => $request]),
new Scope('centrifugo-request', [RequestInterface::class => $request]),
static fn(): mixed => $pipeline->handle(
new CallContext(
/** @see ServiceInterface::handle() */
Expand Down
2 changes: 1 addition & 1 deletion src/GRPC/Interceptor/Invoker.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function invoke(ServiceInterface $service, Method $method, ContextInterfa

/** @psalm-suppress InvalidArgument */
return $this->scope->runScope(
new Scope('grpc.request', [UnaryCallInterface::class => new UnaryCall($ctx, $method, $message)]),
new Scope('grpc-request', [UnaryCallInterface::class => new UnaryCall($ctx, $method, $message)]),
static fn(): string => self::resultToString($handler->handle(
new CallContext(Target::fromPair($service, $method->name), [
$ctx,
Expand Down
2 changes: 1 addition & 1 deletion src/Queue/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function serve(): void
try {
/** @psalm-suppress InvalidArgument */
$this->scope->runScope(
new Scope('queue.task', [TaskInterface::class => new Task(
new Scope('queue-task', [TaskInterface::class => new Task(
id: $task->getId(),
queue: $task->getQueue(),
name: $task->getName(),
Expand Down
2 changes: 1 addition & 1 deletion src/Tcp/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function serve(WorkerInterface $worker = null): void
* @var ResponseInterface $response
*/
$response = $scope->runScope(
new Scope('tcp.request', [RequestInterface::class => $request]),
new Scope('tcp-request', [RequestInterface::class => $request]),
static fn (): mixed => $pipeline->handle(new CallContext(
/** @see \Spiral\RoadRunnerBridge\Tcp\Service\ServiceInterface::handle() */
Target::fromPair($services->getService($server), 'handle'),
Expand Down
2 changes: 1 addition & 1 deletion tests/app/Centrifugo/ScopedTestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Spiral\Core\Internal\Introspector;
use Spiral\RoadRunnerBridge\Centrifugo\ServiceInterface;

#[Scope('centrifugo.request')]
#[Scope('centrifugo-request')]
final class ScopedTestService implements ServiceInterface
{
public static array $scopes = [];
Expand Down
2 changes: 1 addition & 1 deletion tests/app/Tcp/ScopedTestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Spiral\RoadRunnerBridge\Tcp\Response\ResponseInterface;
use Spiral\RoadRunnerBridge\Tcp\Service\ServiceInterface;

#[Scope('tcp.request')]
#[Scope('tcp-request')]
final class ScopedTestService implements ServiceInterface
{
public static array $scopes = [];
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Centrifugo/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testCentrifugoScope(): void

$worker = $this->mockContainer(CentrifugoWorker::class, CentrifugoWorkerInterface::class);
$this->getContainer()
->getBinder('centrifugo.request')
->getBinder('centrifugo-request')
->bindSingleton(ScopedTestService::class, ScopedTestService::class);

$request = new Publish($this->createMock(WorkerInterface::class), '', '', '', '', '', '', [], [], []);
Expand All @@ -130,6 +130,6 @@ public function testCentrifugoScope(): void

$this->getApp()->serve();

$this->assertEquals(['centrifugo.request', 'centrifugo', 'root'], ScopedTestService::$scopes);
$this->assertEquals(['centrifugo-request', 'centrifugo', 'root'], ScopedTestService::$scopes);
}
}
2 changes: 1 addition & 1 deletion tests/src/Queue/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testQueueScopes(): void

$this->getApp()->serve();

$this->assertEquals(['queue.task', 'queue', 'root'], ScopedJob::$scopes);
$this->assertEquals(['queue-task', 'queue', 'root'], ScopedJob::$scopes);
$this->assertEquals(new Task(
id: 'foo-id',
queue: 'default',
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Tcp/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function testTcpScope(): void

$worker = $this->mockContainer(WorkerInterface::class);
$this->getContainer()
->getBinder('tcp.request')
->getBinder('tcp-request')
->bindSingleton(ScopedTestService::class, ScopedTestService::class);

$this->getContainer()->bind(RoadRunnerMode::class, RoadRunnerMode::Tcp);
Expand Down Expand Up @@ -178,6 +178,6 @@ public function testTcpScope(): void

$this->getApp()->serve();

$this->assertEquals(['tcp.request', 'tcp', 'root'], ScopedTestService::$scopes);
$this->assertEquals(['tcp-request', 'tcp', 'root'], ScopedTestService::$scopes);
}
}

0 comments on commit cc7441f

Please sign in to comment.