Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Load Balancer] Direct socket communication to the workers #9

Open
ammarfaizi2 opened this issue Sep 10, 2020 · 0 comments
Open

[Load Balancer] Direct socket communication to the workers #9

ammarfaizi2 opened this issue Sep 10, 2020 · 0 comments

Comments

@ammarfaizi2
Copy link
Member

Currently, the master daemon needs to receive full data from client before it forwards the received data to the logger and responder workers.

The problem is that we need to notice the client which communicates with master daemon, whether the data is received successfully by the worker or not.

function conn_handler($conn)
{
stream_set_timeout($conn, 5);
$rawData = fread($conn, 4096);
$dataLen = unpack("S", substr($rawData, 0, 2))[1];
$receivedLen = strlen($rawData);
/* Read more if the payload has not been received completely. */
while ($dataLen > $receivedLen) {
$rawData .= fread($conn, 4096);
$receivedLen = strlen($rawData);
}
// go(function () use ($conn, $rawData, $receivedLen) {
// send_to_responder($conn, $rawData, $receivedLen);
// });
go(function () use ($conn, $rawData, $receivedLen) {
send_to_logger($conn, $rawData, $receivedLen);
});
fwrite($conn, "ok");
fclose($conn);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant