Skip to content

Commit

Permalink
Add WorkflowClientCallsInterceptorTrait; fix signature of WorkflowOut…
Browse files Browse the repository at this point in the history
…boundCallsInterceptor interface
  • Loading branch information
roxblnfk committed Oct 16, 2023
1 parent 0f63cd2 commit f3c0a33
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 23 deletions.
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);
}
}
45 changes: 23 additions & 22 deletions src/Interceptor/WorkflowOutboundCallsInterceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Temporal\Interceptor;

use React\Promise\PromiseInterface;
use Temporal\Interceptor\Trait\WorkflowOutboundCallsInterceptorTrait;
use Temporal\Interceptor\WorkflowOutboundCalls\AwaitInput;
use Temporal\Interceptor\WorkflowOutboundCalls\AwaitWithTimeoutInput;
use Temporal\Interceptor\WorkflowOutboundCalls\CancelExternalWorkflowInput;
Expand Down Expand Up @@ -50,36 +51,36 @@ public function executeActivity(
): PromiseInterface;

/**
* @param ExecuteLocalActivityInput $request
* @param ExecuteLocalActivityInput $input
* @param callable(ExecuteLocalActivityInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function executeLocalActivity(ExecuteLocalActivityInput $request, callable $next): PromiseInterface;
public function executeLocalActivity(ExecuteLocalActivityInput $input, callable $next): PromiseInterface;

/**
* @param ExecuteChildWorkflowInput $request
* @param ExecuteChildWorkflowInput $input
* @param callable(ExecuteChildWorkflowInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function executeChildWorkflow(ExecuteChildWorkflowInput $request, callable $next): PromiseInterface;
public function executeChildWorkflow(ExecuteChildWorkflowInput $input, callable $next): PromiseInterface;

/**
* @param SignalExternalWorkflowInput $request
* @param SignalExternalWorkflowInput $input
* @param callable(SignalExternalWorkflowInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function signalExternalWorkflow(SignalExternalWorkflowInput $request, callable $next): PromiseInterface;
public function signalExternalWorkflow(SignalExternalWorkflowInput $input, callable $next): PromiseInterface;

/**
* @param CancelExternalWorkflowInput $request
* @param CancelExternalWorkflowInput $input
* @param callable(CancelExternalWorkflowInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function cancelExternalWorkflow(CancelExternalWorkflowInput $request, callable $next): PromiseInterface;
public function cancelExternalWorkflow(CancelExternalWorkflowInput $input, callable $next): PromiseInterface;

/**
* Intercept {@see SideEffectInput::$callable} execution.
Expand All @@ -100,58 +101,58 @@ public function sideEffect(SideEffectInput $input, callable $next): mixed;
public function timer(TimerInput $input, callable $next): PromiseInterface;

/**
* @param PanicInput $request
* @param PanicInput $input
* @param callable(PanicInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function panic(PanicInput $request, callable $next): PromiseInterface;
public function panic(PanicInput $input, callable $next): PromiseInterface;

/**
* @param CompleteInput $request
* @param CompleteInput $input
* @param callable(CompleteInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function complete(CompleteInput $request, callable $next): PromiseInterface;
public function complete(CompleteInput $input, callable $next): PromiseInterface;

/**
* @param ContinueAsNewInput $request
* @param ContinueAsNewInput $input
* @param callable(ContinueAsNewInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function continueAsNew(ContinueAsNewInput $request, callable $next): PromiseInterface;
public function continueAsNew(ContinueAsNewInput $input, callable $next): PromiseInterface;

/**
* @param GetVersionInput $request
* @param GetVersionInput $input
* @param callable(GetVersionInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function getVersion(GetVersionInput $request, callable $next): PromiseInterface;
public function getVersion(GetVersionInput $input, callable $next): PromiseInterface;

/**
* @param UpsertSearchAttributesInput $request
* @param UpsertSearchAttributesInput $input
* @param callable(UpsertSearchAttributesInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function upsertSearchAttributes(UpsertSearchAttributesInput $request, callable $next): PromiseInterface;
public function upsertSearchAttributes(UpsertSearchAttributesInput $input, callable $next): PromiseInterface;

/**
* @param AwaitInput $request
* @param AwaitInput $input
* @param callable(AwaitInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function await(AwaitInput $request, callable $next): PromiseInterface;
public function await(AwaitInput $input, callable $next): PromiseInterface;

/**
* @param AwaitWithTimeoutInput $request
* @param AwaitWithTimeoutInput $input
* @param callable(AwaitWithTimeoutInput): PromiseInterface $next
*
* @return PromiseInterface
*/
public function awaitWithTimeout(AwaitWithTimeoutInput $request, callable $next): PromiseInterface;
public function awaitWithTimeout(AwaitWithTimeoutInput $input, callable $next): PromiseInterface;
}

0 comments on commit f3c0a33

Please sign in to comment.