承接 keboola/job-queue-api-php-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

keboola/job-queue-api-php-client

Composer 安装命令:

composer require keboola/job-queue-api-php-client

包简介

Client for Job queue API

README 文档

README

PHP client for the Job Queue API (API docs).

Usage

composer require keboola/job-queue-api-php-client
use Keboola\JobQueueClient\JobData;
use Keboola\JobQueueClient\JobQueueClient;

$client = new JobQueueClient(
    'https://queue.connection.keboola.com/',
    'xxx-xxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);
$job = $client->createJob(new JobData(
    'keboola.ex-db-snowflake',
    '123',
    [],
    'run',
));
echo $job->id;

Development

  • Create a service principal to download the required images and login:

        SERVICE_PRINCIPAL_NAME=[USERNAME]-job-queue-public-api-pull
        ACR_REGISTRY_ID=$(az acr show --name keboolapes --query id --output tsv --subscription c5182964-8dca-42c8-a77a-fa2a3c6946ea)
        SP_PASSWORD=$(az ad sp create-for-rbac --name http://$SERVICE_PRINCIPAL_NAME --scopes $ACR_REGISTRY_ID --role acrpull --query password --output tsv)
        SP_APP_ID=$(az ad sp show --id http://$SERVICE_PRINCIPAL_NAME --query appId --output tsv)    
  • Login and check that you can pull the image:

        docker login keboolapes.azurecr.io --username $SP_APP_ID --password $SP_PASSWORD
        docker pull keboolapes.azurecr.io/job-queue-internal-api:latest
        docker pull keboolapes.azurecr.io/job-queue-api:latest
  • Add the credentials to the k8s cluster:

        kubectl create secret docker-registry regcred --docker-server="https://keboolapes.azurecr.io" --docker-username="$SP_APP_ID" --docker-password="$SP_PASSWORD" --namespace dev-job-queue-api-php-client
        kubectl patch serviceaccount default -p "{\"imagePullSecrets\":[{\"name\":\"regcred\"}]}" --namespace dev-job-queue-api-php-client
  • Set the following environment variables in set-env.sh file (use set-env.template.sh as sample):

    • test_storage_api_url - Keboola Connection URL.
    • test_storage_api_token - Token to a test project.
  • Set one of Azure or AWS resources (or both, but only one is needed).

AWS Setup

  • Create a user (JobQueueApiPhpClient) for local development using the provisioning/aws.json CF template.
    • Create AWS key for the created user.
    • Set the following environment variables in set-env.sh file (use set-env.template.sh as sample):
      • test_aws_access_key_id - The created security credentials for the JobQueueApiPhpClient user.
      • test_aws_secret_access_key - The created security credentials for the JobQueueApiPhpClient user.
      • test_kms_region - Region output of the above stack.
      • test_kms_key_id - KmsKey output of the above stack.

Azure Setup

  • Create a resource group:

    az account set --subscription "Keboola DEV PS Team CI"
    az group create --name testing-job-queue-api-php-client --location "East US"
  • Create a service principal:

    az ad sp create-for-rbac --name testing-job-queue-api-php-client
  • Use the response to set values test_azure_client_id, test_azure_client_secret and test_azure_tenant_id in the set-env.sh file:

    {
      "appId": "268a6f05-xxxxxxxxxxxxxxxxxxxxxxxxxxx", //-> test_azure_client_id
      "displayName": "testing-job-queue-internal-api-php-client",
      "name": "http://testing-job-queue-internal-api-php-client",
      "password": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", //-> test_azure_client_secret
      "tenant": "9b85ee6f-xxxxxxxxxxxxxxxxxxxxxxxxxxx" //-> test_azure_tenant_id
    }
  • Get ID of the service principal:

    SERVICE_PRINCIPAL_ID=$(az ad sp list --display-name testing-job-queue-api-php-client --query "[0].objectId" --output tsv)
  • Deploy the key vault, provide tenant ID, service principal ID and group ID from the previous commands:

    ./set-env.sh # set $test_azure_tenant_id env
    az deployment group create --resource-group testing-job-queue-api-php-client --template-file provisioning/azure.json --parameters vault_name=test-job-queue-client tenant_id=$test_azure_tenant_id service_principal_object_id=$SERVICE_PRINCIPAL_ID
  • Show Key Vault URL

    az keyvault show --name test-job-queue-client --query "properties.vaultUri" --output tsv

returns e.g. https://test-job-queue-client.vault.azure.net/, use this to set values in set-env.sh file: - test_azure_key_vault_url - https://test-job-queue-client.vault.azure.net/

Generate environment configuration

export db_password="cm9vdA==" #root
export db_password_urlencoded="cm9vdA=="
export test_azure_client_secret_base64=$(printf "%s" "$test_azure_client_secret"| base64 --wrap=0)
export test_aws_secret_access_key_base64=$(printf "%s" "$test_aws_secret_access_key"| base64 --wrap=0)

./set-env.sh
envsubst < provisioning/environments.yaml.template > provisioning/environments.yaml
kubectl apply -f ./provisioning/environments.yaml
kubectl apply -f ./provisioning/public-api.yaml
queue_public_api_ip=`kubectl get svc --output jsonpath --template "{.items[?(@.metadata.name==\"dev-job-queue-api-service\")].status.loadBalancer.ingress[].ip}" --namespace=dev-job-queue-api-php-client`

echo "queue_public_api_url: http://$(queue_public_api_ip):94"

Store the result queue_public_api_ip in set-env.sh.

Run tests

  • With the above setup, you can run tests:

    docker compose build
    source ./set-env.sh && docker compose run tests
  • To run tests with local code use:

    docker compose run tests-local composer install
    source ./set-env.sh && docker compose run tests-local

License

MIT licensed, see LICENSE file.

keboola/job-queue-api-php-client 适用场景与选型建议

keboola/job-queue-api-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.84k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「queue」 「client」 「job」 「keboola」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 keboola/job-queue-api-php-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 keboola/job-queue-api-php-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 keboola/job-queue-api-php-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-09