This package tries to leverage the power of Message Pack and msgpack.php
Mainly this uses https://github.com/msgpack-rpc/msgpack-rpc-php while updating the underlying code & upgrading to the above mentioned msgpack.php package.
There are 3 possible use cases for this repository due to it's server & client perspectives
- Client (my main use case)
$client = new Client('localhost', '1985');
$messages = $client->call("SyncJob", $job, $payload);
echo array_pop($messages);
aside from the obvious host
and port
arguments for the Client
class, let's see the arguments for the call function:
- first argument is a string naming the function to be called on the server side (see
tests/server.php
) - the
call
method is a variadic function, hence the following arguments are concatenated to an array on the server
- Server (not thoroughly tested)
try {
$server = new Server('1985', new App());
echo 'Server is listening on port 1985...';
$server->recv();
} catch (Exception $e) {
echo $e->getMessage();
}
see tests/server.php
for full example
- Client and Server
this would be a good use case if you use multiple services or you need back and forth communication
*if you need this between the same 2 services maybe best to take into account switching to http/2 where
$backChannel = new BackChannel();
$client = new Client('localhost', '1986', $backChannel);
$messages = $client->call("SyncJob", $job, $payload);
echo array_pop($messages);
try {
$server = new Server('1985', new App(), $backChannel);
echo 'Server is listening on port 1985...';
$server->recv();
} catch (Exception $e) {
echo $e->getMessage();
}
yes, in this case as it was the case for the original package, it makes sense to use the BackChannel combined
Other options
The package provides necessary interfaces & Traits in order to have your own Server or Client enhancements without the need to modify the base classes whom one can mainly use as references rather than implementations as it makes only for the most basic use case.
a few words on the impact of switching to MessagePack from Gearman
I expected the time to first byte to be affected, but given that they both communicate at a low level the benchmarks were almost the same to the byte.
There is a huge change in availability as I expected however, which is solving one big problem for my system.
I am curious to hear what was your experience and how you used it or looking to use it for, please comment below.
Links
https://github.com/funeralzone/MsgPackPhp/blob/master/README.md
Posted on Utopian.io - Rewarding Open Source Contributors
You got a 1.76% upvote from @postpromoter courtesy of @decebal2dac!
Want to promote your posts too? Check out the Steem Bot Tracker website for more info. If you would like to support the development of @postpromoter and the bot tracker please vote for @yabapmatt for witness!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @decebal2dac I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
What is that bro??
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Why do we fall..?
So that we can learn to pick ourselves up.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit