Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fbf3dcd
AddsThrow NoNodesAvailableException when cannot select any node (#6)
huangdijia Jul 20, 2022
0aed51e
Create release.yaml
huangdijia Aug 8, 2024
f48dbda
Cs Fix
huangdijia Aug 8, 2024
ee8a400
chore: Comment out unnecessary setup services and test cases
huangdijia Aug 8, 2024
3e4ca13
chore: Update badges in README.md to use shields.io for consistency
huangdijia Aug 8, 2024
a01b6df
chore: Update tests.yaml to setup Consul and services for testing
huangdijia Aug 9, 2024
4185b78
chore: Increase max-parallel value in tests.yaml to 20
huangdijia Aug 9, 2024
f5785e6
chore: Update README.md and tests.yaml for consistency and setup impr…
huangdijia Aug 11, 2024
7cefb4a
chore: Add .bashrc to .gitignore
huangdijia Aug 11, 2024
8d78a67
Siam/multiplex rpc (#12)
xuanyanwow Aug 9, 2024
537b6e7
Adds namespace for helper functions
huangdijia Aug 11, 2024
08faed4
chore: Update phpstan/phpstan dependency to version 1.0
huangdijia Aug 11, 2024
d0c36ca
chore: Update tests.yaml to include fail-fast option
huangdijia Aug 11, 2024
91a3051
Update JsonMultiplexPacker to accept string type for unpack method
huangdijia Aug 11, 2024
ad1bd96
feat: Add return type annotations to helper functions
huangdijia Aug 11, 2024
7bddf89
chore: Update PHP requirement to version 7.1
huangdijia Aug 11, 2024
1efa531
Split UserAgent (#18)
huangdijia Aug 11, 2024
ac30e2f
Cs Fix
huangdijia Aug 11, 2024
4abc360
Cs fix
huangdijia Aug 11, 2024
d34146f
Split Arr and Str (#19)
huangdijia Aug 11, 2024
be7a172
Optimized timeout of transporter (#22)
huangdijia Aug 11, 2024
9b84299
Optimize config of GuzzleHttpClient (#24)
huangdijia Aug 11, 2024
779f0fd
feat: Update GuzzleHttpTransporter configuration handling
huangdijia Aug 11, 2024
987f436
feat: Update GuzzleHttpTransporter configuration handling
huangdijia Aug 11, 2024
dd72661
feat: Update setProtocol, setTransporter, setPacker, setDataFormatter…
huangdijia Aug 13, 2024
2547b65
Adds MetadataManager (#27)
huangdijia Aug 14, 2024
14e18c8
Optimized Metadata (#30)
huangdijia Aug 14, 2024
a37189f
Updated phpdoc
huangdijia Aug 14, 2024
e1593c1
Optimized ClientFactory
huangdijia Aug 16, 2024
b7b43f3
feat: Update return type annotation in StreamSocketTransporter.php
huangdijia Aug 28, 2024
275708b
feat: Retry connection in StreamSocketTransporter.php (#35)
huangdijia Aug 28, 2024
401bcf5
Fix: Ensure unpacked data is an array before using array_key_exists()…
guandeng Oct 9, 2025
91fed24
✨ feat(transporter): add MultiplexRpcTransporter
huangdijia Jun 22, 2026
d72db5c
add tests
addcn-ai-10969 Jun 22, 2026
39c844f
Update TestCase.php
addcn-ai-10969 Jun 22, 2026
414abf8
Update phpunit.xml.dist
addcn-ai-10969 Jun 22, 2026
1447d0c
Update MultiplexRpcTransporter.php
addcn-ai-10969 Jun 22, 2026
e946ffb
Update ClientTest.php
addcn-ai-10969 Jun 22, 2026
e428749
Update MultiplexRpcTransporter.php
addcn-ai-10969 Jun 22, 2026
c80c966
Update phpunit.xml.dist
addcn-ai-10969 Jun 22, 2026
abaa1b0
Update tests.yaml
addcn-ai-10969 Jun 22, 2026
795a74a
Update tests.yaml
addcn-ai-10969 Jun 22, 2026
074c186
Update ClientTest.php
addcn-ai-10969 Jun 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.github export-ignore
/.vscode export-ignore
/tests export-ignore
.gitattributes export-ignore
/bin export-ignore
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get the version
id: get_version
if: startsWith(github.ref, 'refs/tags/')
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}

- name: Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref }}
name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
generate_release_notes: true
8 changes: 5 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
matrix:
os: [ubuntu-latest]
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0']
max-parallel: 3
max-parallel: 20
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -25,10 +26,11 @@ jobs:
- name: Run Analyse
run: |
composer analyse src
- name: Setup Consul
run: docker run -d --name=dev-consul -e CONSUL_BIND_INTERFACE=eth0 --net=host consul:1.15.4
- name: Setup Services
run: |
docker run -d --name jsonrpc -p 9501:9501 -p 9502:9502 -p 9503:9503 -p 9504:9504 limingxinleo/hyperf-jsonrpc-demo:latest
docker run -d --name dev-consul -e CONSUL_BIND_INTERFACE=eth0 --network host consul
docker run -d --name jsonrpc -p 9501:9501 -p 9502:9502 -p 9503:9503 -p 9504:9504 -p 9505:9505 iisiam/hyperf-rpc-demo:latest
sleep 10
php ./tests/register.php
- name: Run Test Cases
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ composer.lock
*.bak
/phpunit.xml
/.phpunit.result.cache
.idea
.bashrc
3 changes: 1 addition & 2 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

$header = <<<'EOF'
This file is part of jet.
This file is part of friendsofhyperf/jet.

@link https://github.com/friendsofhyperf/jet
@document https://github.com/friendsofhyperf/jet/blob/main/README.md
@contact huangdijia@gmail.com
@license https://github.com/friendsofhyperf/jet/blob/main/LICENSE
EOF;

return (new PhpCsFixer\Config())
Expand Down
5 changes: 5 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"words": [
"Laravel"
]
}
94 changes: 60 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Jet

[![Latest Test](https://github.com/friendsofhyperf/jet/workflows/tests/badge.svg)](https://github.com/friendsofhyperf/jet/actions)
[![Latest Stable Version](https://poser.pugx.org/friendsofhyperf/jet/version.png)](https://packagist.org/packages/friendsofhyperf/jet)
[![Total Downloads](https://poser.pugx.org/friendsofhyperf/jet/d/total.png)](https://packagist.org/packages/friendsofhyperf/jet)
[![Latest Stable Version](https://img.shields.io/packagist/v/friendsofhyperf/jet)](https://packagist.org/packages/friendsofhyperf/jet)
[![Total Downloads](https://img.shields.io/packagist/dt/friendsofhyperf/jet)](https://packagist.org/packages/friendsofhyperf/jet)
[![GitHub license](https://img.shields.io/github/license/friendsofhyperf/jet)](https://github.com/friendsofhyperf/jet)

Another jet client for Hyperf
Expand All @@ -11,52 +11,52 @@ Another jet client for Hyperf

### Composer

~~~php
```php
composer require "friendsofhyperf/jet:^2.0"
~~~
```

## Quickstart
## QuickStart

### Register with metadata

~~~php
```php
use FriendsOfHyperf\Jet\Metadata;
use FriendsOfHyperf\Jet\ServiceManager;
use FriendsOfHyperf\Jet\Registry\ConsulRegistry;
use FriendsOfHyperf\Jet\Transporter\GuzzleHttpTransporter;

$metadata = new Metadata('CalculatorService');
$metadata->setTransporter(new GuzzleHttpTransporter('127.0.0.1', 9502));
$metadata->setRegistry(new ConsulRegistry(['uri' => 'http://127.0.0.1:8500']));
$metadata = (new Metadata('CalculatorService'))
->withTransporter(new GuzzleHttpTransporter('127.0.0.1', 9502))
->withRegistry(new ConsulRegistry(['uri' => 'http://127.0.0.1:8500']));

ServiceManager::register('CalculatorService', $metadata);
~~~
```

### Register default registry

~~~php
```php
use FriendsOfHyperf\Jet\RegistryManager;
use FriendsOfHyperf\Jet\Registry\ConsulRegistry;

RegistryManager::register(RegistryManager::DEFAULT, new ConsulRegistry(['uri' => $uri, 'timeout' => 1]));
~~~
```

> In Laravel project, Add to `boot()` in `App/Providers/AppServiceProvider.php`

## Call RPC method

### Call by ClientFactory

~~~php
```php
use FriendsOfHyperf\Jet\ClientFactory;

$client = ClientFactory::create('CalculatorService');
var_dump($client->add(1, 20));
~~~
```

### Call by custom client

~~~php
```php
use FriendsOfHyperf\Jet\Client;
use FriendsOfHyperf\Jet\Transporter\GuzzleHttpTransporter;
use FriendsOfHyperf\Jet\Registry\ConsulRegistry;
Expand All @@ -68,25 +68,21 @@ class CalculatorService extends Client
{
public function __construct($service = 'CalculatorService')
{
$metadata = new Metadata($service);

// Custom transporter
$metadata->setTransporter(new GuzzleHttpTransporter('127.0.0.1', 9502));

// Custom registry
$metadata->setRegistry(new ConsulRegistry(['uri' => 'http://127.0.0.1:8500']));
$metadata = (new Metadata($service))
->withTransporter(new GuzzleHttpTransporter('127.0.0.1', 9502))
->withRegistry(new ConsulRegistry(['uri' => 'http://127.0.0.1:8500']));

parent::__construct($metadata);
}
}

$service = new CalculatorService;
var_dump($service->add(3, 10));
~~~
```

### Call by custom facade

~~~php
```php
use FriendsOfHyperf\Jet\Facade;
use FriendsOfHyperf\Jet\ClientFactory;

Expand All @@ -103,22 +99,52 @@ class Calculator extends Facade
}

var_dump(Calculator::add(rand(0, 100), rand(0, 100)));
~~~
```

## Coroutine support in Hyperf

~~~php
// config/autoload/annotations.php
- Aspect

```php
<?php

namespace App\Aspect;

use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\Guzzle\ClientFactory;

class GuzzleHttpTransporterAspect extends AbstractAspect
{
public array $classes = [
'FriendsOfHyperf\Jet\Transporter\GuzzleHttpTransporter::getClient',
];

protected ClientFactory $clientFactory;

public function __construct(ClientFactory $clientFactory)
{
$this->clientFactory = $clientFactory;
}

public function process(ProceedingJoinPoint $proceedingJoinPoint)
{
$instance = $proceedingJoinPoint->getInstance();
$config = (function () { return $this->config; })->call($instance);

return $this->clientFactory->create($config);
}
}
```

- Config `config/autoload/aspects.php`

```php
<?php

declare(strict_types=1);

return [
'scan' => [
// ...
'class_map' => [
GuzzleHttp\Client::class => BASE_PATH . '/vendor/friendsofhyperf/jet/classmap/GuzzleHttp/Client.php',
],
],
'App\Aspect\GuzzleHttpTransporterAspect',
];
~~~
```
3 changes: 1 addition & 2 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

declare(strict_types=1);
/**
* This file is part of jet.
* This file is part of friendsofhyperf/jet.
*
* @link https://github.com/friendsofhyperf/jet
* @document https://github.com/friendsofhyperf/jet/blob/main/README.md
* @contact huangdijia@gmail.com
* @license https://github.com/friendsofhyperf/jet/blob/main/LICENSE
*/
! defined('BASE_PATH') && define('BASE_PATH', __DIR__);

Expand Down
Loading
Loading