keepsuit / laravel-temporal Goto Github PK
View Code? Open in Web Editor NEWLaravel integration with temporal.io workflow engine
License: MIT License
Laravel integration with temporal.io workflow engine
License: MIT License
Hi @cappuc!
Tests are randomly failing with the following error:
Error 'rpc: can't find service kv.Clear' on tcp://127.0.0.1:6001
Tried to bootstrap the server/workers after each test, but it didn't help.
Do you have any idea why this happen?
I have a fresh Laravel 10 & Sail dev environment with an additional GRPC extension installed.
Hi There Community,
I am running the latest Laravel version with the latest version of the package on an Apple M1 using Laravel Sail.
I wanted to use the Temporal server built-in on this package for testing purposes so I imported the trait WithTemporal
into the testing and added the Temporal::fake();
at the top. However, when running the test, I found the following error:
Failed to start Temporal test server: qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
I have been reading about the issue and it seems that the docker image needs to be from a specific Linux version that is not what the Sail team is currently using.
Does this mean the testing server will not run on the Sail Docker environment running on Mac?
Thanks
Here is a copy of the full test:
class PayOutWorkflowTest extends TestCase
{
use WithTemporal;
/**
* @test
*/
public function it_can_run_payout_workflow()
{
Temporal::fake();
$workflowMock = Temporal::mockWorkflow(PayOutWorkflowInterface::class)
->onTaskQueue('default')
->andReturn('result');
$workflowMock->assertDispatched();
}
}
WorkerFactory::class allows to define many configurations in the Temporal workflow, it's important when using this package that a user can easily extend the WorkerFactory class and make changes as necessary.
Another option is to allow to change the default Worker command in WorkCommand:
...['-o', sprintf('server.command=%s ./vendor/bin/roadrunner-temporal-worker', (new PhpExecutableFinder())->find())],
add here an option to override the roadrunner-temportal-worker path.
Currently there is no way to add logic for an exception that happened, for example logging it into laravel.log file.
I try to mock a workflow and test it with test utility. However, the mock workflow seems to be not being picked up.
My test file:
use WithTemporal;
public function setUp(): void
{
parent::setUp();
}
/**
* @test
* /
public function test_function():
{
Temporal::fake();
$myWorkflowMock = Temporal::mockWorkflow(MyWorkflowInterface::class)
->onTaskQueue('default')
->andReturn('result');
$myService = app(MyServiceInterface::class);
$myService->start();
$myWorkflowMock->assertDispatched();
}
My service function:
public function start(): string
{
$workflowStub = Temporal::newWorkflow()
->withRetryOptions(
RetryOptions::new()->withMaximumAttempts(1)
)
->build(MyWorkflowInterface::class);
$workflow = app(WorkflowClient::class)
->start($workflowStub);
return $workflow->getExecution()->getID();
}
When I dump $workflow->getExecution()
in my service function, I am able to get an execution ID and workflow ID. However, my test is failing and saying the workflow is not dispatched. Looks like the original workflow is still getting dispatched.
Is there anyway to debug this?
never mind, please close :)
This is the full error:
Comand:
sail artisan temporal:work --watch
Watcher process has terminated. Please ensure Node and chokidar are installed.
file:///var/www/html/vendor/keepsuit/laravel-temporal/bin/file-watcher.js:1
const chokidar = require('chokidar');
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/var/www/html/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///var/www/html/vendor/keepsuit/laravel-temporal/bin/file-watcher.js:1:18
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
The solution in file-watcher.js
file change: this: const chokidar = require('chokidar');
for this: import chokidar from "chokidar";
Trying to start temporal:work
I'm getting the warning
"Your RoadRunner binary version may be incompatible with laravel temporal."
And then the worker exits. Tracking it down a bit it seems that its unable to find the rr binary.
I've checked and it does exist in vender/bin
is there a permission error or something I'm missing?
Hi @cappuc
Wouldn't it be better to have Workflows
and Activities
registered automatically/placed by artisan commands in the app/Temporal
folder instead of the root? In bigger projects that's a good separation because you can instantly see it's Temporal-related, especially if you have Actions
and other Laravel layers in the root.
Currently:
It could have been:
Hi, a function like
function activityMethod(): FooData|false
returns an strObject instead of FooData object.
(FooData is Spatie Data)
The model -
class SmsCampaignSend extends Model implements TemporalSerializable
{
use HasMeta;
use SoftDeletes;
use TemporalEloquentSerialize;
use HasUuids;
protected $fillable = [
'id',
'sms_campaign_id',
'status',
'meta',
];
public function campaign(): BelongsTo
{
return $this->belongsTo(SmsCampaign::class);
}
}
doesn't work when calling the $campaignSend->campaign relation in an activity after doing the serialize
Hi, after creating child workflows with
$smsWorkflow = Temporal::newChildWorkflow()
->build(SendSmsWorkflow::class);
$res = $smsWorkflow->handle($data);
Child workflow class -
#[WorkflowInterface]
class SendSmsWorkflow
{
public function __construct()
{
//..
}
#[WorkflowMethod]
public function handle(CampaignSendToBuildSmsData $data): \Generator
{
//..
}
}
The child workflows don't get picked up by the worker -
artisan temporal:work
But when creating it as a new workflow it does get picked up. Am I missing something?
hi,
is there a way to change the settings in the worker option without rewriting the worker roadrunner-temporal-worker process?
https://github.com/temporalio/sdk-php/blob/8cdcc1819be60e838d5e1f92b69f913aac61a58e/src/Worker/WorkerOptions.php#L31
couldn't find a way to do it in the code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.