-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Ignatev
authored
May 21, 2022
1 parent
bc862df
commit d50d822
Showing
19 changed files
with
629 additions
and
459 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,2 +1,41 @@ | ||
.idea/ | ||
build/ | ||
*.lo | ||
*.la | ||
.libs | ||
acinclude.m4 | ||
aclocal.m4 | ||
autom4te.cache | ||
build | ||
config.guess | ||
config.h | ||
config.h.in | ||
config.log | ||
config.nice | ||
config.status | ||
config.sub | ||
configure | ||
configure.ac | ||
configure.in | ||
include | ||
install-sh | ||
libtool | ||
ltmain.sh | ||
Makefile | ||
Makefile.fragments | ||
Makefile.global | ||
Makefile.objects | ||
missing | ||
mkinstalldirs | ||
modules | ||
php_test_results_*.txt | ||
phpt.* | ||
run-test-info.php | ||
run-tests.php | ||
tests/**/*.diff | ||
tests/**/*.out | ||
tests/**/*.php | ||
tests/**/*.exp | ||
tests/**/*.log | ||
tests/**/*.sh | ||
tests/**/*.db | ||
tests/**/*.mem | ||
tmp-php.ini |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,2 @@ | ||
aeron | ||
nomnoms12 |
This file contains 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 |
---|---|---|
@@ -1,44 +1,65 @@ | ||
# aeron_php8 | ||
<img src="https://user-images.githubusercontent.com/44947427/169660344-9298aef6-773f-4451-89e9-cb8de7dfe4af.svg" height="101" alt="php"> | ||
|
||
Расширение для PHP, позволяющее использовать протокол [Aeron](https://github.com/real-logic/aeron). Добавляет в код | ||
классы `AeronPublisher` и `AeronSubscriber`: | ||
# aeron-php | ||
|
||
```php | ||
function handler(string $message) {} | ||
$subscriber = new AeronSubscriber('handler', 'aeron:ipc'); | ||
[](https://github.com/RoboTradeCode/aeron-php/actions/workflows/build.yml) | ||
[](https://www.php.net/downloads) | ||
[](https://ru.wikipedia.org/wiki/Linux) | ||
|
||
$publisher = new AeronPublisher('aeron:ipc'); | ||
$publisher->offer('Hello, World!'); | ||
``` | ||
Неофициальное расширение для PHP, позволяющее использовать протокол [Aeron](https://github.com/real-logic/aeron). | ||
|
||
*Описания классов и примеры использования смотрите в папке [examples](examples).* | ||
## Установка | ||
|
||
## Установка и сборка | ||
### Предварительные требования | ||
|
||
Установите php версии 8 для вашего дистрибутива Linux, и проверьте версию: | ||
Перед установкой и использованием данного расширения, у вас должен быть установлен Aeron. Вы можете воспользоваться | ||
[статьёй в Wiki](https://github.com/RoboTradeCode/aeron-python/wiki/Установка-Aeron) для его установки. | ||
|
||
### Сборка и установка расширения | ||
|
||
```shell | ||
phpize | ||
./configure | ||
make | ||
sudo make install | ||
``` | ||
php -version | ||
``` | ||
|
||
Клонируйте код репозитория: | ||
> Дополнительно добавьте `extension=aeron.so` в ваш файл `php.ini` | ||
## Использование | ||
|
||
### Отправка сообщений | ||
|
||
```bash | ||
git clone --recurse-submodules https://github.com/RoboTradeCode/aeron-php.git | ||
# или так | ||
git clone --recurse-submodules [email protected]:RoboTradeCode/aeron-php.git | ||
```php | ||
use Aeron\Publisher; | ||
|
||
$publisher = new Publisher( | ||
channel: 'aeron:udp?endpoint=localhost:20121', // string | ||
stream_id: 1001, // int | ||
); | ||
|
||
$result = $publisher->offer(message: 'Hello, World!'); | ||
$publisher->close(); | ||
``` | ||
|
||
### Получение сообщений | ||
|
||
```php | ||
use Aeron\Subscriber; | ||
|
||
> Обратите внимание на параметр `--recurse-submodules`. Он нужен, чтобы рекурсивно установить все зависимости | ||
> репозитория, описанные в файле [.gitmodules](.gitmodules) | ||
> | ||
Далее, необходимо перейти в склонированный проект и осуществить его сборку. Сборка осуществляется с использованием утилиты [CMake](https://ru.wikipedia.org/wiki/CMake). Для её упрощения вы можете | ||
воспользоваться скриптом [build.sh](build.sh). После его исполнения собранный код будет находиться в директории | ||
build/Debug: | ||
function handler(string $message): void | ||
{ | ||
echo "<<$message>>", PHP_EOL; | ||
} | ||
|
||
```shell | ||
cd /home/user/cpp/other/aeron-php | ||
./build.sh | ||
$subscriber = new Subscriber( | ||
handler: 'handler', // callable | ||
channel: 'aeron:udp?endpoint=localhost:20121', // string | ||
stream_id: 1001, // int | ||
); | ||
|
||
$fragments_read = $subscriber->poll(); | ||
$subscriber->close(); | ||
``` | ||
|
||
> Убедитесь, что у вас запущен медиа-драйвер Aeron перед использованием классов расширения |
Oops, something went wrong.