Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #11

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Data/VariableCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function toArray(): array
default => StringType::class,
};

$variables[$key] = (new $typeClass())($value);
$variables[$key] = (new $typeClass)($value);
}

return $variables;
Expand Down
20 changes: 12 additions & 8 deletions src/Http/ExternalTaskClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,20 @@ public static function getTaskLocked(): array
public static function fetchAndLock(string $workerId, array $topics, int $maxTasks = 10): array
{
$payload = ['workerId' => $workerId, 'maxTasks' => $maxTasks, 'topics' => $topics];
$response = self::make()->post('external-task/fetchAndLock', $payload);
$url = 'external-task/fetchAndLock';
$response = self::make()->post($url, $payload);

$data = [];
if ($response->successful()) {
/** @var array<array> */
if (! $response->successful()) {
/** @var array */
$array = $response->json();
foreach ($array as $task) {
$data[] = ExternalTaskData::fromArray($task);
}
throw (new UnexpectedResponseException)->for($url, $payload, $array);
}

$data = [];
/** @var array<array> */
$array = $response->json();
foreach ($array as $task) {
$data[] = ExternalTaskData::fromArray($task);
}

return $data;
Expand Down Expand Up @@ -113,7 +118,6 @@ public static function fail(
string $errorMessage = 'Does not compute',
int $retryTimeout = 60000,
): bool {

$payload = compact('workerId', 'errorMessage', 'retryTimeout');
$url = "external-task/$id/failure";
$response = self::make()->post($url, $payload);
Expand Down
3 changes: 1 addition & 2 deletions src/Http/TaskHistoryClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public static function find(string $id): TaskHistoryData
}

/** @var string */
$message = $response->json('message');

$message = $response->json('message') ?? $response->body();
throw new CamundaException($message);
}

Expand Down