viloveul/transport

Simple connection manager for handling other engine

v1.0.3 2021-07-19 03:01 UTC

This package is auto-updated.

Last update: 2022-05-19 06:19:52 UTC


README

composer require viloveul/transport

SETUP

initilize bus connection for data transport

require_once __DIR__ . '/vendor/autoload.php';

$bus = new Viloveul\Transport\Bus();
$bus->initialize();
$bus->addConnection('amqp://localhost:5672//');

declaring class passenger (for whatever your data)

use Viloveul\Transport\Passenger;

class TaskPassenger extends Passenger
{
	public function point(): string
	{
		return 'exchange name';
	}

	public function route(): string
	{
		return 'routing.key';
	}

	public function data(): string
	{
		return 'string-data';
	}

	public function handle(): void
	{
		$this->setAttribute('data', [
			'foo' => 'bar'
		]);
	}
}

BROKER MESSAGE (RabbitMQ)

run rabbit under docker

docker run --rm -p 5672:5672 rabbitmq:3
# rabbitmq listen for port 5672

processing task

$bus->process(new TaskPassenger);

BACKEND (using Celery)

cd sample/celery
celery -A tasks worker --loglevel=info

BACKEND (websocket)

cd sample/socket.io
npm install
npm start