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.
- Host: GitHub
- URL: https://github.com/ytake/phluxor-remote
- Owner: ytake
- License: apache-2.0
- Created: 2024-09-01T14:34:58.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-10-02T13:51:53.000Z (8 months ago)
- Last Synced: 2024-10-05T22:03:33.117Z (8 months ago)
- Topics: actor-library, actor-model, actorsystem, microservice, php
- Language: PHP
- Homepage:
- Size: 88.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
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!
});
});
```