mrfelipemartins/oxide-php
Composer 安装命令:
composer require mrfelipemartins/oxide-php
包简介
Framework-agnostic PHP client for Oxide Wire Protocol v1.
README 文档
README
Framework-agnostic PHP client for Oxide Wire Protocol v1.
composer require mrfelipemartins/oxide-php
Connect
use Oxide\Client; use Oxide\Config\ClientConfig; $client = new Client(new ClientConfig( host: '127.0.0.1', port: 7379, authToken: null, )); $health = $client->health();
With auth:
$client = new Client(new ClientConfig( authToken: 'secret', ));
The SDK sends authorization: Bearer <token> when an auth token is configured.
Streams
use Oxide\DTO\StreamConfig; $client->createStream(new StreamConfig('email')); $stats = $client->streamInfo('email'); $client->clearStream('email');
Submit Work
use Oxide\DTO\SubmitWork; $submitted = $client->submit(new SubmitWork( stream: 'email', payload: json_encode(['message' => 'hello'], JSON_THROW_ON_ERROR), idempotencyKey: 'job-1', laneKey: 'account-42', ));
Payloads are PHP strings. The SDK encodes them as byte arrays for Oxide's current JSON command schema.
Claim And Complete
use Oxide\DTO\ClaimRequest; use Oxide\DTO\CompleteRequest; $claimed = $client->claim(new ClaimRequest( stream: 'email', consumerGroup: 'workers', workerId: 'worker-1', max: 1, leaseMs: 90000, )); foreach ($claimed->items as $item) { $payload = $item->work->payload; $client->ack(new CompleteRequest( claimId: $item->claim->claimId, workId: $item->claim->workId, fenceToken: $item->claim->fenceToken, )); }
Release
use Oxide\DTO\ReleaseRequest; $client->release(new ReleaseRequest( claimId: $item->claim->claimId, workId: $item->claim->workId, fenceToken: $item->claim->fenceToken, delayMs: 30000, ));
Multi-stream Claim
use Oxide\DTO\ClaimManyRequest; $claimed = $client->claimMany(new ClaimManyRequest( streams: ['critical', 'default', 'low'], consumerGroup: 'workers', workerId: 'worker-1', max: 10, leaseMs: 90000, ));
Raw Commands
The high-level API covers common Oxide operations. Advanced users can call the protocol directly:
$response = $client->command('STREAM.INFO', headers: ['stream' => 'email']); $data = $response->json();
Tests
composer install
composer test
The v1 test suite is unit-only and does not require a running Oxide server.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-22