Skip to content

Commit

Permalink
v0.2.0 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Ignatev authored May 21, 2022
1 parent bc862df commit d50d822
Show file tree
Hide file tree
Showing 19 changed files with 629 additions and 459 deletions.
21 changes: 8 additions & 13 deletions .github/workflows/main.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
# This is a basic workflow to help you get started with Actions
name: Build

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
run:
runs-on: ${{ matrix.operating-system }}
build:

runs-on: ubuntu-latest
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.4', '8.0', '8.1', '8.2']
php-versions: ['8.0', '8.1', '8.2']

steps:
- uses: actions/checkout@v3
- name: Setup PHP
Expand All @@ -42,4 +36,5 @@ jobs:
./configure
make
- name: Run tests
run: make test
run: |
TEST_PHP_ARGS="-q" make test
43 changes: 41 additions & 2 deletions .gitignore
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
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

42 changes: 0 additions & 42 deletions CMakeLists.txt

This file was deleted.

2 changes: 2 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aeron
nomnoms12
77 changes: 49 additions & 28 deletions README.md
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');
[![Build](https://github.com/RoboTradeCode/aeron-php/actions/workflows/build.yml/badge.svg)](https://github.com/RoboTradeCode/aeron-php/actions/workflows/build.yml)
[![PHP](https://img.shields.io/badge/php-%5E8.0-blue)](https://www.php.net/downloads)
[![Linux](https://img.shields.io/badge/platform-linux-lightgrey)](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 перед использованием классов расширения
Loading

0 comments on commit d50d822

Please sign in to comment.