Skip to content

Commit

Permalink
fix: add streaming call
Browse files Browse the repository at this point in the history
  • Loading branch information
rishtigupta committed Jan 3, 2024
1 parent 371faf3 commit 2512bab
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/Topic/Internal/ScsTopicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,27 @@ private function processCall(UnaryCall $call)

private function processStreamingCall(ServerStreamingCall $call): void
{
// Retrieve metadata and status using the metadata() method
list($response, $status) = $call->responses();
foreach ($call->responses() as $response) {
// Process each response individually
$this->logger->info("Received message: " . json_encode($response));

// Optionally, you can log any metadata received during the initial setup.
$metadata = $call->getMetadata();
$this->logger->info("Initial metadata received: " . json_encode($metadata));

// Optionally, log the start of the streaming process.
$this->logger->info("Streaming call initiated successfully.");
}

// Handle the end of the streaming process
$status = $call->getStatus();
if ($status->code !== 0) {
$this->logger->error("Error during streaming call setup: {$status->details}");
$this->logger->error("Error during streaming: {$status->details}");
throw _ErrorConverter::convert($status->code, $status->details, $call->getMetadata());
}

// Optionally, you can log any metadata received during the initial setup.
$metadata = $call->getMetadata();
$this->logger->info("Initial metadata received: " . json_encode($metadata));

// Optionally, log the start of the streaming process.
$this->logger->info("Streaming call initiated successfully.");
}





public function publish(string $cacheName, string $topicName, string $value): TopicPublishResponse
{
$this->logger->info("Publishing to topic: $topicName in cache $cacheName\n");
Expand Down

0 comments on commit 2512bab

Please sign in to comment.