Skip to content

Supporting protobuf message support #1329

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/gps/GpsConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function getSubscription(): Subscription

private function convertMessage(GoogleMessage $message): GpsMessage
{
$gpsMessage = GpsMessage::jsonUnserialize($message->data());
$gpsMessage = new GpsMessage($message->data(), $message->attributes(),[]);
$gpsMessage->setNativeMessage($message);

return $gpsMessage;
Expand Down
43 changes: 43 additions & 0 deletions pkg/gps/Tests/GpsConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,49 @@ public function testShouldReceiveMessage()
$this->assertSame('the body', $message->getBody());
}

public function testShouldReceiveMessageProtobufFormat()
{
$body = '2test+customer_6115118118117248@example.com"4test+customer_611511118118117248@example.com*&App\Tests\Entity\Entity497709';
$attributes = [
'ce-datacontenttype' => 'application/protobuf',
];

$nativeMessage = new Message([
'data' => $body,
'attributes' => $attributes,
], []);

$subscription = $this->createSubscriptionMock();
$subscription
->expects($this->once())
->method('pull')
->with($this->identicalTo([
'maxMessages' => 1,
'requestTimeout' => 12.345,
]))
->willReturn([$nativeMessage]);

$client = $this->createPubSubClientMock();
$client
->expects($this->once())
->method('subscription')
->willReturn($subscription);

$context = $this->createContextMock();
$context
->expects($this->once())
->method('getClient')
->willReturn($client);

$consumer = new GpsConsumer($context, new GpsQueue('queue-name'));

$message = $consumer->receive(12345);

$this->assertInstanceOf(GpsMessage::class, $message);
$this->assertSame($body, $message->getBody());
$this->assertSame($attributes, $message->getProperties());
}

/**
* @return \PHPUnit\Framework\MockObject\MockObject|GpsContext
*/
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy