Skip to content

Commit

Permalink
Modify Aeron publishers and subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
kleninmaxim committed May 24, 2022
1 parent 4544ed1 commit fd5715c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 3 additions & 1 deletion kernel/balancer_by_market_order.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Src\Configurator;
use Src\Core;
use Src\Gate;
use Aeron\Publisher;

require dirname(__DIR__) . '/index.php';
require dirname(__DIR__) . '/config/common_config.php';
Expand All @@ -23,7 +24,8 @@
$robotrade_api = new Api($common_config['exchange'], $common_config['algorithm'], $common_config['node'], $common_config['instance']);

// нужен publisher, отправлять команды по aeron в гейт
$publisher = new AeronPublisher($config['aeron']['publishers']['gate']['channel'], $config['aeron']['publishers']['gate']['stream_id']);
$publisher = new Publisher($config['aeron']['publishers']['gate']['channel'], $config['aeron']['publishers']['gate']['stream_id']);
sleep(1);

// класс для работы с гейтом
$gate = new Gate($publisher, $robotrade_api, $common_config['gate_sleep'] ?? 0);
Expand Down
4 changes: 3 additions & 1 deletion kernel/cross_3t.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Src\Core;
use Src\Gate;
use Src\Cross3T;
use Aeron\Publisher;

require dirname(__DIR__) . '/index.php';
require dirname(__DIR__) . '/config/common_config.php';
Expand All @@ -25,7 +26,8 @@
$robotrade_api = new Api($common_config['exchange'], $common_config['algorithm'], $common_config['node'], $common_config['instance']);

// нужен publisher, отправлять команды по aeron в гейт
$publisher = new AeronPublisher($config['aeron']['publishers']['gate']['channel'], $config['aeron']['publishers']['gate']['stream_id']);
$publisher = new Publisher($config['aeron']['publishers']['gate']['channel'], $config['aeron']['publishers']['gate']['stream_id']);
sleep(1);

// создаем класс cross 3t
$cross_3t = new Cross3T($config, $common_config);
Expand Down
9 changes: 6 additions & 3 deletions kernel/receive_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use Src\Configurator;
use Src\DiscreteTime;
use Src\Log;
use Aeron\Publisher;
use Aeron\Subscriber;

require dirname(__DIR__) . '/index.php';
require dirname(__DIR__) . '/config/common_config.php';
Expand All @@ -29,7 +31,8 @@
}

// нужен publisher, отправлять логи на сервер логов
$publisher = new AeronPublisher($config['aeron']['publishers']['log']['channel'], $config['aeron']['publishers']['log']['stream_id']);
$publisher = new Publisher($config['aeron']['publishers']['log']['channel'], $config['aeron']['publishers']['log']['stream_id']);
sleep(1);

function handler_orderbooks(string $message): void
{
Expand Down Expand Up @@ -100,13 +103,13 @@ function handler_balances(string $message): void
}

// subscribers подключения
$subscriber_orderbooks = new AeronSubscriber('handler_orderbooks', $config['aeron']['subscribers']['orderbooks']['channel'], $config['aeron']['subscribers']['orderbooks']['stream_id']);
$subscriber_orderbooks = new Subscriber('handler_orderbooks', $config['aeron']['subscribers']['orderbooks']['channel'], $config['aeron']['subscribers']['orderbooks']['stream_id']);

foreach ($config['aeron']['subscribers']['orderbooks']['destinations'] as $destination) {
$subscriber_orderbooks->addDestination($destination);
}

$subscriber_balances = new AeronSubscriber('handler_balances', $config['aeron']['subscribers']['balance']['channel'], $config['aeron']['subscribers']['balance']['stream_id']);
$subscriber_balances = new Subscriber('handler_balances', $config['aeron']['subscribers']['balance']['channel'], $config['aeron']['subscribers']['balance']['stream_id']);

foreach ($config['aeron']['subscribers']['balance']['destinations'] as $destination) {
$subscriber_balances->addDestination($destination);
Expand Down
10 changes: 5 additions & 5 deletions src/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

namespace Src;

use AeronPublisher;
use Aeron\Publisher;
use robotrade\Api;

class Gate
{

private AeronPublisher $publisher;
private Publisher $publisher;
private Api $robotrade_api;
private array $commands;
private int $sleep;

/**
* Нужно передать объект класса AeronPublisher и Robotrade Api
* Нужно передать объект класса Publisher и Robotrade Api
*
* @param AeronPublisher $publisher Gate AeronPublisher
* @param Publisher $publisher Gate Publisher
* @param Api $robotrade_api Api create message to send command to Gate
* @param int $sleep Sleep between gate commands
*/
public function __construct(AeronPublisher $publisher, Api $robotrade_api, int $sleep = 0)
public function __construct(Publisher $publisher, Api $robotrade_api, int $sleep = 0)
{

$this->publisher = $publisher;
Expand Down

0 comments on commit fd5715c

Please sign in to comment.