Add tests - #41
Conversation
Co-Authored-By: hzh <hzh@addcn.com> Co-Authored-By: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
* Split Arr and Str Co-Authored-By: Deeka Wong <8337659+huangdijia@users.noreply.github.com> * feat: Update path generation to handle namespaces with backslashes * feat: Fix backslash handling in path generation --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
* Optimized timeout of transporter Co-Authored-By: Deeka Wong <8337659+huangdijia@users.noreply.github.com> * chore: Remove unused timeout property in StreamSocketTransporter * feat: Update GuzzleHttpTransporter timeout handling The code changes in `GuzzleHttpTransporter.php` update the timeout handling in the constructor. The `timeout` value is now retrieved from the `$config` array and assigned to the transporter's `timeout` property. This change ensures that the timeout value is correctly set when creating a new instance of `GuzzleHttpTransporter`. Based on recent user commits and repository commits, it seems that there have been optimizations and fixes related to transporters and helper functions. However, these changes are not directly related to the current code changes in `GuzzleHttpTransporter.php`. Please note that the suggested commit message follows the format "feat: <summary of changes>". Feel free to modify it according to your repository's commit message conventions. * feat: Update GuzzleHttpTransporter timeout handling * feat: Update GuzzleHttpTransporter timeout handling * feat: Update GuzzleHttpTransporter timeout handling --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
* Optimize config of GuzzleHttpClient * feat: Update GuzzleHttpTransporter configuration handling The code changes in `GuzzleHttpTransporter.php` update the configuration handling in the constructor. The `$config` array is now merged with a default configuration array using `array_replace()`. This change ensures that the transporter has the correct configuration values when creating a new instance of `GuzzleHttpTransporter`. Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com> --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
The code changes in `GuzzleHttpTransporter.php` update the configuration handling in the constructor. The `$config` array is now merged with a default configuration array using `array_replace()`. This change ensures that the transporter has the correct configuration values when creating a new instance of `GuzzleHttpTransporter`.
…, setPathGenerator, setRegistry, setTries, and setTimeout methods in Metadata class Refactor the setProtocol, setTransporter, setPacker, setDataFormatter, setPathGenerator, setRegistry, setTries, and setTimeout methods in the Metadata class to include a return type annotation of $this. This change improves the code readability and maintainability by explicitly indicating that these methods return an instance of the Metadata class. Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
* Adds MetadataManager * feat: Refactor MetadataManager to use static methods for registration and retrieval The code changes in `MetadataManager.php` remove the unnecessary comments and update the `register` and `get` methods to be static. This refactor improves the code readability and maintainability by clearly indicating that these methods can be accessed directly on the class without needing an instance. Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com> * feat: Update MetadataManager to use static methods for registration and retrieval * feat: Update ClientTest to use service parameter in ClientFactory The code changes in `ClientTest.php` update the `ClientFactory::create()` method to pass the `this->service` parameter as the first argument instead of `'test'`. This change ensures that the correct service is used when creating a new instance of the client. --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Refactor the return type annotation in the `StreamSocketTransporter.php` file to use the `array{string, int}` type instead of `(int|string)[]`. This change improves the code readability and maintainability by explicitly indicating the expected return type.
Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Retry the connection in the `StreamSocketTransporter.php` file when establishing a stream socket client. This change improves the reliability of the connection by attempting to connect multiple times before throwing a connection exception. Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
…#39) * Fix: Ensure unpacked data is an array before using array_key_exists() * Add validation for unpacked data in Client Throws a RecvFailedException if the unpacked data is not an array, improving error handling for invalid responses. * Fix: Ensure unpacked data is treated as an array in Client * chore: Add allow-plugins configuration for composer-normalize * Fix: Ensure unpacked data is treated as an array and improve error handling in Client * Fix: Improve error message for invalid data in ServerException --------- Co-authored-by: 范冠登 <guandeng@addcn.com> Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (62)
📝 WalkthroughWalkthroughThis PR refactors ChangesMultiplexed RPC, Fluent Metadata, and Support Refactoring
Sequence Diagram(s)sequenceDiagram
participant CallerCode
participant ClientFactory
participant MetadataManager
participant ServiceManager
participant Metadata
participant Client
participant MultiplexRpcTransporter
participant JsonMultiplexPacker
CallerCode->>ClientFactory: create(name, transporter)
ClientFactory->>ServiceManager: get(name)
alt found in ServiceManager
ServiceManager-->>ClientFactory: Metadata
ClientFactory-->>CallerCode: new Client(metadata)
else string transporter → MetadataManager lookup
ClientFactory->>MetadataManager: get(transporter)
MetadataManager-->>ClientFactory: cloned Metadata (renamed)
ClientFactory-->>CallerCode: new Client(metadata)
else build from options
ClientFactory->>Metadata: new Metadata(name) + withTransporter/withRegistry/...
Metadata-->>ClientFactory: configured Metadata
ClientFactory-->>CallerCode: new Client(metadata)
end
CallerCode->>Client: __call("add", [1, 2])
Client->>JsonMultiplexPacker: pack(request)
JsonMultiplexPacker-->>Client: binary frame (8-byte header + JSON)
Client->>MultiplexRpcTransporter: send(binary frame)
MultiplexRpcTransporter-->>Client: recv → header+body bytes
Client->>JsonMultiplexPacker: unpack(bytes)
JsonMultiplexPacker-->>Client: assoc array {id, result}
Client-->>CallerCode: result value
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.2.2)PHPStan was skipped because the user-provided config is missing the required Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
New Features
Documentation
Chores