An open API service indexing awesome lists of open source software.

https://github.com/ytake/phluxor-remote

Phluxor Remote is a library that allows you to create remote actor systems in Phluxor.
https://github.com/ytake/phluxor-remote

actor-library actor-model actorsystem microservice php

Last synced: 3 months ago
JSON representation

Phluxor Remote is a library that allows you to create remote actor systems in Phluxor.

Awesome Lists containing this project

README

        

# Phluxor Remote

## About

Phluxor Remoteは、Phluxorアクターシステムを活用したリモートアクターシステムを作成するためのライブラリです。

Phluxor Remote is a library that allows you to create remote actor systems in Phluxor.

It is inspired by the [Proto.Remote](https://proto.actor/docs/remote/).

with Phluxor Remote you can create a remote actor system that can communicate with other actor systems over network.

Phluxor Remote uses [Swoole](https://www.swoole.com/).

Between the two nodes, use the `ProtoBuf` serialization format.
Websocket is used as the transport layer.

## Usage

### Install

```bash
$ composer require phluxor/phluxor-remote
```

### Node1

```php
start();
$props = ActorSystem\Props::fromFunction(
new ActorSystem\Message\ReceiveFunction(
function (ActorSystem\Context\ContextInterface $context) {
$message = $context->message();
if ($message instanceof HelloRequest) {
$context->respond(new HelloResponse([
'Message' => 'Hello from remote node',
]));
}
}
)
);
$system->root()->spawnNamed($props, 'hello');
});
});
```

### Node2

```php
start();
$future = $system->root()->requestFuture(
new ActorSystem\Ref(new ActorSystem\ProtoBuf\Pid([
'address' => 'localhost:50053',
'id' => 'hello',
])),
new HelloRequest(),
1
);
$r = $future->result()->value();
$r->getMessage(); // Hello from remote node!
});
});
```