定制 mrfelipemartins/oxide-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

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
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-22