Skip to content

Commit

Permalink
Merge pull request #366: polishing and improvements interceptors
Browse files Browse the repository at this point in the history
Update Interceptors: polishing and improvements
  • Loading branch information
roxblnfk authored Oct 23, 2023
2 parents 0f63cd2 + 5ef06ca commit b5a52f0
Show file tree
Hide file tree
Showing 38 changed files with 410 additions and 251 deletions.
8 changes: 2 additions & 6 deletions src/Interceptor/ActivityInbound/ActivityInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@

namespace Temporal\Interceptor\ActivityInbound;

use JetBrains\PhpStorm\Immutable;
use Temporal\DataConverter\ValuesInterface;
use Temporal\Interceptor\HeaderInterface;

/**
* @psalm-immutable
*/
#[Immutable]
class ActivityInput
{
/**
* @no-named-arguments
* @internal Don't use the constructor. Use {@see self::with()} instead.
*/
public function __construct(
#[Immutable]
public ValuesInterface $arguments,
#[Immutable]
public HeaderInterface $header,
public readonly ValuesInterface $arguments,
public readonly HeaderInterface $header,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

/**
* Implements {@see WorkflowClientCallsInterceptor}
* @psalm-immutable
*/
trait WorkflowClientCallsInterceptorTrait
{
Expand Down
149 changes: 149 additions & 0 deletions src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?php

/**
* This file is part of Temporal package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Temporal\Interceptor\Trait;

use React\Promise\PromiseInterface;
use Temporal\Interceptor\WorkflowOutboundCalls\AwaitInput;
use Temporal\Interceptor\WorkflowOutboundCalls\AwaitWithTimeoutInput;
use Temporal\Interceptor\WorkflowOutboundCalls\CancelExternalWorkflowInput;
use Temporal\Interceptor\WorkflowOutboundCalls\CompleteInput;
use Temporal\Interceptor\WorkflowOutboundCalls\ContinueAsNewInput;
use Temporal\Interceptor\WorkflowOutboundCalls\ExecuteActivityInput;
use Temporal\Interceptor\WorkflowOutboundCalls\ExecuteChildWorkflowInput;
use Temporal\Interceptor\WorkflowOutboundCalls\ExecuteLocalActivityInput;
use Temporal\Interceptor\WorkflowOutboundCalls\GetVersionInput;
use Temporal\Interceptor\WorkflowOutboundCalls\PanicInput;
use Temporal\Interceptor\WorkflowOutboundCalls\SideEffectInput;
use Temporal\Interceptor\WorkflowOutboundCalls\SignalExternalWorkflowInput;
use Temporal\Interceptor\WorkflowOutboundCalls\TimerInput;
use Temporal\Interceptor\WorkflowOutboundCalls\UpsertSearchAttributesInput;
use Temporal\Interceptor\WorkflowOutboundCallsInterceptor;

/**
* Implements {@see WorkflowOutboundCallsInterceptor}
*/
trait WorkflowOutboundCallsInterceptorTrait
{
/**
* @see WorkflowOutboundCallsInterceptor::executeActivity()
*/
public function executeActivity(
ExecuteActivityInput $input,
callable $next,
): PromiseInterface {
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::executeLocalActivity()
*/
public function executeLocalActivity(ExecuteLocalActivityInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::executeChildWorkflow()
*/
public function executeChildWorkflow(ExecuteChildWorkflowInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::signalExternalWorkflow()
*/
public function signalExternalWorkflow(SignalExternalWorkflowInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::cancelExternalWorkflow()
*/
public function cancelExternalWorkflow(CancelExternalWorkflowInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::sideEffect()
*/
public function sideEffect(SideEffectInput $input, callable $next): mixed
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::timer()
*/
public function timer(TimerInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::panic()
*/
public function panic(PanicInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::complete()
*/
public function complete(CompleteInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::continueAsNew()
*/
public function continueAsNew(ContinueAsNewInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::getVersion()
*/
public function getVersion(GetVersionInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::upsertSearchAttributes()
*/
public function upsertSearchAttributes(UpsertSearchAttributesInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::await()
*/
public function await(AwaitInput $input, callable $next): PromiseInterface
{
return $next($input);
}

/**
* @see WorkflowOutboundCallsInterceptor::awaitWithTimeout()
*/
public function awaitWithTimeout(AwaitWithTimeoutInput $input, callable $next): PromiseInterface
{
return $next($input);
}
}
5 changes: 1 addition & 4 deletions src/Interceptor/WorkflowClient/CancelInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@

namespace Temporal\Interceptor\WorkflowClient;

use JetBrains\PhpStorm\Immutable;
use Temporal\Workflow\WorkflowExecution;

/**
* @psalm-immutable
*/
#[Immutable]
class CancelInput
{
/**
* @no-named-arguments
* @internal Don't use the constructor. Use {@see self::with()} instead.
*/
public function __construct(
#[Immutable]
public WorkflowExecution $workflowExecution,
public readonly WorkflowExecution $workflowExecution,
) {
}

Expand Down
14 changes: 4 additions & 10 deletions src/Interceptor/WorkflowClient/GetResultInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,22 @@

namespace Temporal\Interceptor\WorkflowClient;

use JetBrains\PhpStorm\Immutable;
use Temporal\Workflow\WorkflowExecution;

/**
* @psalm-immutable
*/
#[Immutable]
class GetResultInput
{
/**
* @no-named-arguments
* @internal Don't use the constructor. Use {@see self::with()} instead.
*/
public function __construct(
#[Immutable]
public WorkflowExecution $workflowExecution,
#[Immutable]
public ?string $workflowType,
#[Immutable]
public ?int $timeout,
#[Immutable]
public mixed $type,
public readonly WorkflowExecution $workflowExecution,
public readonly ?string $workflowType,
public readonly ?int $timeout,
public readonly mixed $type,
) {
}

Expand Down
14 changes: 4 additions & 10 deletions src/Interceptor/WorkflowClient/QueryInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,23 @@

namespace Temporal\Interceptor\WorkflowClient;

use JetBrains\PhpStorm\Immutable;
use Temporal\DataConverter\ValuesInterface;
use Temporal\Workflow\WorkflowExecution;

/**
* @psalm-immutable
*/
#[Immutable]
class QueryInput
{
/**
* @no-named-arguments
* @internal Don't use the constructor. Use {@see self::with()} instead.
*/
public function __construct(
#[Immutable]
public WorkflowExecution $workflowExecution,
#[Immutable]
public ?string $workflowType,
#[Immutable]
public string $queryType,
#[Immutable]
public ValuesInterface $arguments,
public readonly WorkflowExecution $workflowExecution,
public readonly ?string $workflowType,
public readonly string $queryType,
public readonly ValuesInterface $arguments,
) {
}

Expand Down
14 changes: 4 additions & 10 deletions src/Interceptor/WorkflowClient/SignalInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,23 @@

namespace Temporal\Interceptor\WorkflowClient;

use JetBrains\PhpStorm\Immutable;
use Temporal\DataConverter\ValuesInterface;
use Temporal\Workflow\WorkflowExecution;

/**
* @psalm-immutable
*/
#[Immutable]
class SignalInput
{
/**
* @no-named-arguments
* @internal Don't use the constructor. Use {@see self::with()} instead.
*/
public function __construct(
#[Immutable]
public WorkflowExecution $workflowExecution,
#[Immutable]
public ?string $workflowType,
#[Immutable]
public string $signalName,
#[Immutable]
public ValuesInterface $arguments,
public readonly WorkflowExecution $workflowExecution,
public readonly ?string $workflowType,
public readonly string $signalName,
public readonly ValuesInterface $arguments,
) {
}

Expand Down
11 changes: 3 additions & 8 deletions src/Interceptor/WorkflowClient/SignalWithStartInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@

namespace Temporal\Interceptor\WorkflowClient;

use JetBrains\PhpStorm\Immutable;
use Temporal\DataConverter\ValuesInterface;

/**
* @psalm-immutable
*/
#[Immutable]
class SignalWithStartInput
{
/**
* @no-named-arguments
* @internal Don't use the constructor. Use {@see self::with()} instead.
*/
public function __construct(
#[Immutable]
public StartInput $workflowStartInput,
#[Immutable]
public string $signalName,
#[Immutable]
public ValuesInterface $signalArguments,
public readonly StartInput $workflowStartInput,
public readonly string $signalName,
public readonly ValuesInterface $signalArguments,
) {
}

Expand Down
17 changes: 5 additions & 12 deletions src/Interceptor/WorkflowClient/StartInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,25 @@

namespace Temporal\Interceptor\WorkflowClient;

use JetBrains\PhpStorm\Immutable;
use Temporal\Client\WorkflowOptions;
use Temporal\DataConverter\ValuesInterface;
use Temporal\Interceptor\HeaderInterface;

/**
* @psalm-immutable
*/
#[Immutable]
class StartInput
{
/**
* @no-named-arguments
* @internal Don't use the constructor. Use {@see self::with()} instead.
*/
public function __construct(
#[Immutable]
public string $workflowId,
#[Immutable]
public string $workflowType,
#[Immutable]
public HeaderInterface $header,
#[Immutable]
public ValuesInterface $arguments,
#[Immutable]
public WorkflowOptions $options,
public readonly string $workflowId,
public readonly string $workflowType,
public readonly HeaderInterface $header,
public readonly ValuesInterface $arguments,
public readonly WorkflowOptions $options,
) {
}

Expand Down
Loading

0 comments on commit b5a52f0

Please sign in to comment.