Repository navigation
Integration branch for ably/pubsub-server v2 package #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ttypic
wants to merge
17
commits into
main
Choose a base branch
from
integration/v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e917e51
Add PubSub package split plan (PDR-091b)
umair-ably 68f5acf
plan: record the PR numbers of the split stack (#223, #225, #226, #224)
umair-ably d5cf09e
Re-identify the package as ably/pubsub-server
umair-ably 87cad08
Move the namespace Ably\ -> Ably\PubSub\ (pure move, no behaviour cha…
umair-ably 0a34b50
Remove the hand-rolled autoloader, the Heroku demo and its Procfile
umair-ably 5890766
Make the agent header per-client and rename the SDK identifier
umair-ably 5929677
Add the factory door Ably\PubSub\Server::createHttpClient()
umair-ably 0df4818
Assert the agent header and the packaging invariants
umair-ably 336de73
CI: test 8.1-8.5, cover integration/v2, validate strictly
umair-ably 727256f
tests: drop the deprecated curl_close() from the sandbox fixture
umair-ably ff09ec3
Rewrite the README for ably/pubsub-server
umair-ably 9d82492
Add UPDATING.md with the 1.x -> 2.0.0 migration guide
umair-ably 389ff12
Fill in the 2.0.0 CHANGELOG entry
umair-ably e79c2a9
Rename AblyRest to PubSubHttpClient
ttypic a3a06d1
Merge pull request #228 from ably/pubsub-split/renaming
ttypic 7b72fbc
Replace environment and restHost with endpoint
ttypic fef205e
Merge pull request #229 from ably/integration/endpoint-option
ttypic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Keep the Packagist dist archive to what a consumer actually installs. | ||
| # GitHub zipballs honour export-ignore, so this trims the test suite, the | ||
| # ably-common fixture submodule and the CI/planning files from every release. | ||
| /tests export-ignore | ||
| /ably-common export-ignore | ||
| /.github export-ignore | ||
| /phpunit.xml export-ignore | ||
| /plan.md export-ignore | ||
| /.ably export-ignore | ||
| /.gitmodules export-ignore | ||
| /.gitattributes export-ignore |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ on: | |
| push: | ||
| branches: | ||
| - main | ||
| - integration/v2 | ||
|
|
||
| permissions: {} | ||
|
|
||
|
|
||
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
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
This file was deleted.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # Upgrade / Migration Guide | ||
|
|
||
| ## 1.x (`ably/ably-php`) → 2.0.0 (`ably/pubsub-server`) | ||
|
|
||
| Version 2.0.0 ships from a new package, `ably/pubsub-server`, under a new namespace, `Ably\PubSub\`. `ably/ably-php` is superseded: it receives security and critical-bug fixes only for one year from the 2.0.0 release date, and is then end-of-life. | ||
|
|
||
| Under monthly-active-user pricing the platform has to classify every connection as device-side or server-side. The new package declares that automatically, on every request, in the `Ably-Agent` header; the old constructor cannot declare anything. That is the forcing function for this migration: once monthly-active-user pricing is live, `new Ably\AblyRest(...)` from `ably/ably-php` is rejected on accounts where it is enabled. | ||
|
|
||
| The client `Server::createHttpClient()` returns is the same REST client as before, renamed from `AblyRest` to `PubSubHttpClient`. Channels, message publishing, history, presence, authentication, push admin and crypto behave exactly as they did in 1.x. The one change to `ClientOptions` is how the client chooses where to connect: the `endpoint` option replaces `environment` and `restHost` (see [Endpoint](#endpoint-replaces-environment-and-resthost)). For most applications the migration is confined to the `composer require` line, the `use` statements, the constructor call, and any host options. | ||
|
|
||
| ### Mapping | ||
|
|
||
| | 1.x (`ably/ably-php`) | 2.0 (`ably/pubsub-server`) | | ||
| | --- | --- | | ||
| | `composer require ably/ably-php` | `composer require ably/pubsub-server` | | ||
| | `use Ably\AblyRest;` / `new AblyRest($opts)` | `use Ably\PubSub\Server;` / `Server::createHttpClient($opts)` | | ||
| | `use Ably\Models\Message;` (any `Ably\X` type) | `use Ably\PubSub\Models\Message;` (`Ably\PubSub\X`) | | ||
| | `AblyRest::setAblyAgentHeader('x', 'v')` | `Server::createHttpClient(['agents' => ['x' => 'v'], …])` | | ||
| | `AblyRest::setLibraryFlavourString('x')` | removed — use the `agents` option | | ||
| | `require 'ably-loader.php';` | removed — use Composer's autoloader (`vendor/autoload.php`) | | ||
| | PHP 7.2 – 8.0 | PHP `^8.1` (tested on 8.1 – 8.5) | | ||
| | `\Ably\AblyRest` type hints | `\Ably\PubSub\PubSubHttpClient` ([091d](https://ably.atlassian.net/wiki/spaces/product/pages/5363957781)) | | ||
| | `'environment' => 'sandbox'` / `'restHost' => '…'` | `'endpoint' => …` (see [Endpoint](#endpoint-replaces-environment-and-resthost)) | | ||
|
|
||
| Every class moves namespace, and `AblyRest` is the only one that also changes name, so the rename is mechanical: replace the prefix `Ably\` with `Ably\PubSub\` throughout — including in type hints, `catch` blocks and fully-qualified string class names — and then `AblyRest` with `PubSubHttpClient`. | ||
|
|
||
| ### Example | ||
|
|
||
| ```php | ||
| // 1.x | ||
| use Ably\AblyRest; | ||
|
|
||
| $ably = new AblyRest(['key' => getenv('ABLY_API_KEY'), 'clientId' => 'me']); | ||
| $ably->channel('test-channel')->publish('test-event', 'hello world'); | ||
|
|
||
| // 2.0 | ||
| use Ably\PubSub\Server; | ||
|
|
||
| $ably = Server::createHttpClient(['key' => getenv('ABLY_API_KEY'), 'clientId' => 'me']); | ||
| $ably->channel('test-channel')->publish('test-event', 'hello world'); | ||
| ``` | ||
|
|
||
| `createHttpClient()` accepts everything the 1.x constructor accepted: an options array, an API key string, a token string, or a `ClientOptions` instance. A `ClientOptions` instance you pass in is copied rather than mutated. | ||
|
|
||
| ### Endpoint replaces environment and restHost | ||
|
|
||
| The `endpoint` client option is now the only way to choose where the client connects. `environment` and `restHost` are removed. Like any other unknown key, they are now ignored, so a client still passing `'environment' => 'sandbox'` connects to production: replace them before upgrading. | ||
|
|
||
| | 1.x | 2.0 | | ||
| | --- | --- | | ||
| | no host options | no change; traffic moves from `rest.ably.io` to `main.realtime.ably.net` | | ||
| | `'environment' => 'sandbox'` | `'endpoint' => 'nonprod:sandbox'` | | ||
| | `'environment' => 'acme'` (dedicated cluster) | `'endpoint' => 'acme'` | | ||
| | `'restHost' => 'localhost'` | `'endpoint' => 'localhost'` | | ||
| | `'restHost' => 'rest.example.com'` | `'endpoint' => 'rest.example.com'` | | ||
| | custom `'fallbackHosts' => […]` | unchanged | | ||
|
|
||
| How `endpoint` resolves: | ||
|
|
||
| | `endpoint` | Primary domain | Default fallback hosts | | ||
| | --- | --- | --- | | ||
| | unset (`main`) | `main.realtime.ably.net` | `main.[a-e].fallback.ably-realtime.com` | | ||
| | `[id]`, e.g. `acme` | `[id].realtime.ably.net` | `[id].[a-e].fallback.ably-realtime.com` | | ||
| | `nonprod:[id]`, e.g. `nonprod:sandbox` | `[id].realtime.ably-nonprod.net` | `[id].[a-e].fallback.ably-realtime-nonprod.com` | | ||
| | a hostname: contains `.` or `::`, or is `localhost` | the value as given | none | | ||
|
|
||
| A non-empty `fallbackHosts` still replaces the default fallback hosts. Setting `port` or `tlsPort` no longer disables the default fallback hosts; only a hostname `endpoint` does. | ||
|
|
||
| ```php | ||
| // 1.x | ||
| $ably = new AblyRest(['key' => getenv('ABLY_API_KEY'), 'environment' => 'sandbox']); | ||
|
|
||
| // 2.0 | ||
| $ably = Server::createHttpClient(['key' => getenv('ABLY_API_KEY'), 'endpoint' => 'nonprod:sandbox']); | ||
| ``` | ||
|
|
||
| `ClientOptions::getPrimaryRestHost()` is renamed `getPrimaryDomain()`, and `Defaults::$restHost`, `Defaults::$realtimeHost` and `Defaults::getEnvironmentFallbackHosts()` are replaced by `Defaults::$endpoint`, `Defaults::getPrimaryDomain()` and `Defaults::getEndpointFallbackHosts()`. | ||
|
|
||
| Firewall allowlists and outbound proxies must allow `*.realtime.ably.net` and `*.fallback.ably-realtime.com` in place of `rest.ably.io` and `*.ably-realtime.com`. | ||
|
|
||
| ### Declaring the side | ||
|
|
||
| Construct through the door. `new Ably\PubSub\PubSubHttpClient(...)` still works — the library and its own tests use it — but it declares no side, and will be rejected on monthly-active-user-enabled accounts just as the 1.x constructor is. The door produces: | ||
|
|
||
| ``` | ||
| Ably-Agent: ably-pubsub-php/2.0.0 php/8.3.4 ably-pubsub-server | ||
| ``` | ||
|
|
||
| If you are building an SDK or framework on top of this package, name it through the `agents` option instead of the removed static setters. Your entries are preserved, in order, ahead of the side entry: | ||
|
|
||
| ```php | ||
| $ably = Server::createHttpClient([ | ||
| 'key' => getenv('ABLY_API_KEY'), | ||
| 'agents' => ['laravel' => '11.0.0', 'laravel-broadcaster' => '1.0.4'], | ||
| ]); | ||
|
|
||
| // Ably-Agent: ably-pubsub-php/2.0.0 php/8.3.4 laravel/11.0.0 laravel-broadcaster/1.0.4 ably-pubsub-server | ||
| ``` | ||
|
|
||
| The `agents` option is per-client, unlike the process-global static setters it replaces, so two clients in one process can carry different attribution. | ||
|
|
||
| ### Removed in 2.0.0 | ||
|
|
||
| * `AblyRest::setAblyAgentHeader()` and `AblyRest::$agents` — replaced by the per-client `agents` option. | ||
| * `AblyRest::setLibraryFlavourString()` — already deprecated in 1.x; replaced by the same option. | ||
| * `ably-loader.php`, the hand-rolled autoloader — Composer is the only supported install path. | ||
| * The `environment` and `restHost` client options — replaced by `endpoint`. They are ignored if passed. | ||
| * The `demo/` Heroku application and its `Procfile`. | ||
| * PHP 7.2 – 8.0 support. | ||
|
|
||
| `Auth::authorise()`, the British-spelling alias deprecated in favour of `Auth::authorize()`, is still present in 2.0.0. | ||
|
|
||
| ### Unchanged | ||
|
|
||
| * The REST client and its whole surface: `channel()`, `channels`, publishing, message history, presence and presence history, `auth`, token requests and token issuing, `push` admin, `stats`, `time()`, and crypto. | ||
| * Every `ClientOptions` key other than the host options above, and the array / key-string / token-string / `ClientOptions` forms of the constructor argument. | ||
| * Message and error semantics, including `AblyException` and its codes. | ||
| * Requirements: `ext-json`, `ext-curl`, `ext-openssl`, and `rybakit/msgpack` for the msgpack protocol. | ||
|
|
||
| ### Staying on 1.x | ||
|
|
||
| `ably/ably-php` 1.x is maintained on the `maintenance/1.x` branch of this repository. It gets security and critical-bug fixes for one year from the 2.0.0 release date and no new features, then reaches end-of-life. Both packages can be installed side by side during a migration: they declare different namespaces and different PSR-4 prefixes, so their autoloading does not collide. | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Include non-production domains in the firewall allowlist.
If an application uses
nonprod:sandbox, the listed allowlist does not permit its primary or fallback domains. A firewall configured from this instruction can block the application's requests. Add*.realtime.ably-nonprod.netand*.fallback.ably-realtime-nonprod.comfor non-production endpoints.🤖 Prompt for AI Agents