Extend HTTP API methods to match current proto and clean up Client#70
Merged
Extend HTTP API methods to match current proto and clean up Client#70
Conversation
Extend existing methods with optional parameters introduced in Centrifugo's HTTP API since this client was last updated: * publish/broadcast: tags, idempotency_key, delta, version, version_epoch * subscribe: expire_at, info, data, recover_since, override, session * unsubscribe: session * disconnect: disconnect (code/reason), whitelist, session New parameters are positional optional arguments at the end and only included in the JSON payload when set, so existing callers see byte-identical request bodies. Drive-by fixes: * setSafety docblock: @param was incorrectly named caPath * _json_last_error_msg: drop dead PHP < 5.5 fallback (composer requires >= 7.0); public signature preserved for BC * request(): replace pointless elseif (\$this->safety) with else * getUrl(): rtrim(\$this->url, '/') so a trailing slash on the constructor URL doesn't produce a double slash in the request URL * README: API methods list was missing subscribe and batch
The flag was renamed in Centrifugo and centrifugo/centrifugo:latest now exits immediately with "unknown flag: --api_insecure", which made the "Wait for server to be ready" step hang indefinitely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bring
Client.phpin line with Centrifugo's current HTTP API and clean up a few small issues ahead of v6.0.3.Extended existing methods with new optional parameters from the proto
publish/broadcast:tags,idempotency_key,delta,version,version_epochsubscribe:expire_at,info,data,recover_since,override,sessionunsubscribe:sessiondisconnect:disconnect(code/reason),whitelist,sessionAll new parameters are positional optional arguments at the end with sensible defaults, and are only included in the JSON payload when set to a non-default value — so existing callers see byte-identical request bodies.
Out of scope (deliberately): adding entirely new RPCs not previously exposed (
rpc,refresh,connections, push/device/user-status/etc.). Worth a follow-up.Drive-by fixes
setSafetydocblock —@paramwas incorrectly labelled$caPath._json_last_error_msg— thefunction_exists('json_last_error_msg')fallback table was dead code on any PHP version this library supports (composer requires>= 7.0;json_last_error_msgexists since PHP 5.5). Body shrunk to a one-liner; public signature preserved for BC.request()—if (!$this->safety) { ... } elseif ($this->safety) { ... }collapsed to plainelse.getUrl()—rtrim($this->url, '/')so passing a trailing-slash URL likehttp://host/api/no longer yieldshttp://host/api//publish.subscribeandbatch.Test plan
tests/ClientTest.phpstill passes against latest Centrifugo (no call sites changed; new params are optional).publish/broadcast/subscribe/unsubscribe/disconnectare byte-identical to v6.0.2.tagson publish,sessionon disconnect).🤖 Generated with Claude Code