keboola / job-queue-internal-api-php-client
Client for internal job queue API
Package info
github.com/keboola/job-queue-internal-api-php-client
pkg:composer/keboola/job-queue-internal-api-php-client
Requires
- php: ^8.2
- ext-json: *
- guzzlehttp/guzzle: ^6.3|^7.0
- keboola/job-queue-artifacts: ^4.0.3|*@dev
- keboola/kbc-manage-api-php-client: ^5.2|^6.0|^7.0|^8.0|^9.0
- keboola/object-encryptor: ^2.12
- keboola/permission-checker: ^2.0
- keboola/retry: ^0.5.1
- keboola/storage-api-client: ^15.2|^16.0|^17.0|^18.0
- keboola/storage-api-php-client-branch-wrapper: ^6.0
- monolog/monolog: ^2.6|^3.0
- psr/log: ^1.1|^2.0|^3.0
- symfony/config: ^5.4|^6.0|^7.0
- symfony/uid: ^5.4|^6.2|^7.0
- symfony/validator: ^5.4|^6.0|^7.0
Requires (Dev)
- infection/infection: ^0.27
- keboola/coding-standard: >=14.0
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^9.5
- sempro/phpunit-pretty-print: ^1.4
- symfony/dotenv: ^6.3|^7.0
This package is auto-updated.
Last update: 2026-06-29 19:24:24 UTC
README
PHP client for the Internal Job Queue API (API docs).
Usage
composer require keboola/job-queue-internal-api-php-client
use Keboola\JobQueueInternalClient\Client; $storageClientFactory = new JobFactory\StorageClientFactory('http://connetion.keboola.com/'); $objectEncryptorFactory = new ObjectEncryptorFactory('key-id', 'us-east-1', '', ''); $jobFactory = new JobFactory($storageClientFactory, $objectEncryptorFactory); $client = new Client( new NullLogger(), $jobFactory, 'http://internal.queue.api/', 'testQueueToken' ); $client->getJobData('123'); $client->postJobResult('123', 'success', ['images' => ['digests' => []]]);
Atomic job result updates
patchJobResultAtomically() performs an optimistic-locking read-modify-write of a job's
result document. It reads the current result and its resultVersion, runs your mutator,
and writes it back guarded by that version. The versioned write merges the returned keys
into the current server-side result (the same array_merge semantics as the non-versioned
write), only made atomic by the version check. On a version conflict (HTTP 409, i.e. a
concurrent writer changed the result in between) it automatically re-reads and retries a
bounded number of times; if the conflict still cannot be resolved within the retry budget it
throws a ResultVersionConflictException rather than overwriting the concurrent change.
The mutator receives the current result array and must return a \JsonSerializable whose
jsonSerialize() yields an array. The returned keys are merged into the current result — it is
not a full replace, so keys you omit are preserved (you cannot delete a key this way):
use Keboola\JobQueueInternalClient\Result\GenericJobResult; $job = $client->patchJobResultAtomically('123', function (array $current): GenericJobResult { $current['processedRows'] = ($current['processedRows'] ?? 0) + 1; return new GenericJobResult($current); });
GenericJobResult is a trivial \JsonSerializable wrapper for callers that do not have their
own result value object.
Development
Prerequisites:
- configured
azandawsCLI tools (runaz loginandaws configure --profile keboola-dev-platform-services) - installed GCP CLI
gcloud(and rungcloud auth loginorgcloud auth application-default login) - installed
terraform(https://www.terraform.io) andjq(https://stedolan.github.io/jq) to setup local env - intalled
dockeranddocker composeto run & develop the app
TL;DR:
export NAME_PREFIX= # your name/nickname to make your resource unique & recognizable
cat <<EOF > ./provisioning/local/terraform.tfvars
name_prefix = "${NAME_PREFIX}"
EOF
cat <<EOF > .env.local
TEST_HOSTNAME_SUFFIX=keboola.com
TEST_STORAGE_API_URL=https://connection.keboola.com
TEST_STORAGE_API_TOKEN=
TEST_STORAGE_API_TOKEN_MASTER=
EOF
terraform -chdir=./provisioning/local init -backend-config="key=job-queue-internal-api-php-client/${NAME_PREFIX}.tfstate"
terraform -chdir=./provisioning/local apply
./provisioning/local/update-env.sh azure # or aws
License
MIT licensed, see LICENSE file.