Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: php-enqueue/enqueue-dev
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.10.21
Choose a base ref
...
head repository: php-enqueue/enqueue-dev
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.10.22
Choose a head ref
  • 3 commits
  • 6 files changed
  • 2 contributors

Commits on Aug 12, 2024

  1. release 0.10.21

    makasim committed Aug 12, 2024
    Copy the full SHA
    2d41b6e View commit details

Commits on Aug 13, 2024

  1. GPS: revert the attributes and use the headers instead.

    p-pichet committed Aug 13, 2024
    Copy the full SHA
    c8c4993 View commit details
  2. Merge pull request #1355 from ubitransports/pubsub/use-headers-instea…

    …d-of-attributes
    
    GPS: revert the attributes and use the headers instead.
    makasim authored Aug 13, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    0b3555a View commit details
Showing with 37 additions and 42 deletions.
  1. +21 −0 CHANGELOG.md
  2. +4 −2 bin/release
  3. +2 −19 pkg/gps/GpsMessage.php
  4. +2 −2 pkg/gps/GpsProducer.php
  5. +4 −15 pkg/gps/Tests/GpsMessageTest.php
  6. +4 −4 pkg/gps/Tests/GpsProducerTest.php
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Change Log

## [0.10.21](https://github.com/php-enqueue/enqueue-dev/tree/0.10.21) (2024-08-12)
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.20...0.10.21)

**Merged pull requests:**

- feat\(GPS\): allow send attributes in Google PubSub message. [\#1349](https://github.com/php-enqueue/enqueue-dev/pull/1349) ([p-pichet](https://github.com/p-pichet))

## [0.10.19](https://github.com/php-enqueue/enqueue-dev/tree/0.10.19) (2023-07-15)
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.18...0.10.19)

**Merged pull requests:**

- fix: do not reset attemps header when message is requeue [\#1301](https://github.com/php-enqueue/enqueue-dev/pull/1301) ([eortiz-tracktik](https://github.com/eortiz-tracktik))
- Allow doctrine/persistence 3.1 version [\#1300](https://github.com/php-enqueue/enqueue-dev/pull/1300) ([xNarkon](https://github.com/xNarkon))
- Add support for rediss and phpredis [\#1297](https://github.com/php-enqueue/enqueue-dev/pull/1297) ([splagemann](https://github.com/splagemann))
- Replaced `json\_array` with `json` due to Doctrine Dbal 3.0 [\#1294](https://github.com/php-enqueue/enqueue-dev/pull/1294) ([NovakHonza](https://github.com/NovakHonza))
- pkg PHP 8.1 and 8.2 support [\#1292](https://github.com/php-enqueue/enqueue-dev/pull/1292) ([snapshotpl](https://github.com/snapshotpl))
- Update doctrine/persistence [\#1290](https://github.com/php-enqueue/enqueue-dev/pull/1290) ([jlabedo](https://github.com/jlabedo))
- Add PHP 8.1 and 8.2, Symfony 6.2 to CI [\#1285](https://github.com/php-enqueue/enqueue-dev/pull/1285) ([andrewmy](https://github.com/andrewmy))
- \[SNSQS\] added possibility to send FIFO-related parameters using snsqs transport [\#1278](https://github.com/php-enqueue/enqueue-dev/pull/1278) ([onatskyy](https://github.com/onatskyy))

## [0.10.18](https://github.com/php-enqueue/enqueue-dev/tree/0.10.18) (2023-03-18)
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.10.17...0.10.18)

6 changes: 4 additions & 2 deletions bin/release
Original file line number Diff line number Diff line change
@@ -43,7 +43,8 @@ do
if [[ -z "$LAST_RELEASE" ]]; then
echo "There has not been any releases. Releasing $1";

git tag $1 -a -s -m "Release $1"
#git tag $1 -a -s -m "Release $1"
git tag $1 -a -m "Release $1"
git push origin --tags
else
echo "Last release $LAST_RELEASE";
@@ -53,7 +54,8 @@ do
if [[ ! -z "$CHANGES_SINCE_LAST_RELEASE" ]]; then
echo "There are changes since last release. Releasing $1";

git tag $1 -s -m "Release $1"
#git tag $1 -s -m "Release $1"
git tag $1 -m "Release $1"
git push origin --tags
else
echo "No change since last release.";
21 changes: 2 additions & 19 deletions pkg/gps/GpsMessage.php
Original file line number Diff line number Diff line change
@@ -24,11 +24,6 @@ class GpsMessage implements Message, \JsonSerializable
*/
private $headers;

/**
* @var array
*/
private $attributes;

/**
* @var bool
*/
@@ -39,12 +34,11 @@ class GpsMessage implements Message, \JsonSerializable
*/
private $nativeMessage;

public function __construct(string $body = '', array $properties = [], array $headers = [], array $attributes = [])
public function __construct(string $body = '', array $properties = [], array $headers = [])
{
$this->body = $body;
$this->properties = $properties;
$this->headers = $headers;
$this->attributes = $attributes;

$this->redelivered = false;
}
@@ -157,7 +151,6 @@ public function jsonSerialize(): array
'body' => $this->getBody(),
'properties' => $this->getProperties(),
'headers' => $this->getHeaders(),
'attributes' => $this->getAttributes(),
];
}

@@ -168,7 +161,7 @@ public static function jsonUnserialize(string $json): self
throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}

return new self($data['body'] ?? $json, $data['properties'] ?? [], $data['headers'] ?? [], $data['attributes'] ?? []);
return new self($data['body'] ?? $json, $data['properties'] ?? [], $data['headers'] ?? []);
}

public function getNativeMessage(): ?GoogleMessage
@@ -180,14 +173,4 @@ public function setNativeMessage(?GoogleMessage $message = null): void
{
$this->nativeMessage = $message;
}

public function setAttributes(array $attributes): void
{
$this->attributes = $attributes;
}

public function getAttributes(): array
{
return $this->attributes;
}
}
4 changes: 2 additions & 2 deletions pkg/gps/GpsProducer.php
Original file line number Diff line number Diff line change
@@ -40,8 +40,8 @@ public function send(Destination $destination, Message $message): void

$params = ['data' => json_encode($message)];

if (count($message->getAttributes()) > 0) {
$params['attributes'] = $message->getAttributes();
if (count($message->getHeaders()) > 0) {
$params['attributes'] = $message->getHeaders();
}

$topic->publish($params);
19 changes: 4 additions & 15 deletions pkg/gps/Tests/GpsMessageTest.php
Original file line number Diff line number Diff line change
@@ -18,14 +18,14 @@ public function testCouldSetGetNativeMessage()

public function testColdBeSerializedToJson()
{
$message = new GpsMessage('theBody', ['thePropFoo' => 'thePropFooVal'], ['theHeaderFoo' => 'theHeaderFooVal'], ['theAttributeFoo' => 'theAttributeFooVal']);
$message = new GpsMessage('theBody', ['thePropFoo' => 'thePropFooVal'], ['theHeaderFoo' => 'theHeaderFooVal']);

$this->assertEquals('{"body":"theBody","properties":{"thePropFoo":"thePropFooVal"},"headers":{"theHeaderFoo":"theHeaderFooVal"},"attributes":{"theAttributeFoo":"theAttributeFooVal"}}', json_encode($message));
$this->assertEquals('{"body":"theBody","properties":{"thePropFoo":"thePropFooVal"},"headers":{"theHeaderFoo":"theHeaderFooVal"}}', json_encode($message));
}

public function testCouldBeUnserializedFromJson()
{
$message = new GpsMessage('theBody', ['thePropFoo' => 'thePropFooVal'], ['theHeaderFoo' => 'theHeaderFooVal'], ['theAttributeFoo' => 'theAttributeFooVal']);
$message = new GpsMessage('theBody', ['thePropFoo' => 'thePropFooVal'], ['theHeaderFoo' => 'theHeaderFooVal']);

$json = json_encode($message);

@@ -40,7 +40,7 @@ public function testCouldBeUnserializedFromJson()

public function testMessageEntityCouldBeUnserializedFromJson()
{
$json = '{"body":"theBody","properties":{"thePropFoo":"thePropFooVal"},"headers":{"theHeaderFoo":"theHeaderFooVal"},"attributes":{"theAttributeFoo":"theAttributeFooVal"}}';
$json = '{"body":"theBody","properties":{"thePropFoo":"thePropFooVal"},"headers":{"theHeaderFoo":"theHeaderFooVal"}}';

$unserializedMessage = GpsMessage::jsonUnserialize($json);

@@ -49,7 +49,6 @@ public function testMessageEntityCouldBeUnserializedFromJson()
$this->assertEquals($decoded['body'], $unserializedMessage->getBody());
$this->assertEquals($decoded['properties'], $unserializedMessage->getProperties());
$this->assertEquals($decoded['headers'], $unserializedMessage->getHeaders());
$this->assertEquals($decoded['attributes'], $unserializedMessage->getAttributes());
}

public function testMessagePayloadCouldBeUnserializedFromJson()
@@ -62,7 +61,6 @@ public function testMessagePayloadCouldBeUnserializedFromJson()
$this->assertEquals($json, $unserializedMessage->getBody());
$this->assertEquals([], $unserializedMessage->getProperties());
$this->assertEquals([], $unserializedMessage->getHeaders());
$this->assertEquals([], $unserializedMessage->getAttributes());
}

public function testThrowIfMalformedJsonGivenOnUnsterilizedFromJson()
@@ -72,13 +70,4 @@ public function testThrowIfMalformedJsonGivenOnUnsterilizedFromJson()

GpsMessage::jsonUnserialize('{]');
}

public function testGetAttributes()
{
$message = new GpsMessage('the body', [], [], ['key1' => 'value1']);

$attributes = $message->getAttributes();

$this->assertSame(['key1' => 'value1'], $attributes);
}
}
8 changes: 4 additions & 4 deletions pkg/gps/Tests/GpsProducerTest.php
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public function testShouldSendMessage()
->expects($this->once())
->method('publish')
->with($this->identicalTo([
'data' => '{"body":"","properties":[],"headers":[],"attributes":[]}',
'data' => '{"body":"","properties":[],"headers":[]}',
]));

$client = $this->createPubSubClientMock();
@@ -56,16 +56,16 @@ public function testShouldSendMessage()
$producer->send($topic, $message);
}

public function testShouldSendMessageWithAttributes()
public function testShouldSendMessageWithHeaders()
{
$topic = new GpsTopic('topic-name');
$message = new GpsMessage('', [], [], ['key1' => 'value1']);
$message = new GpsMessage('', [], ['key1' => 'value1']);

$gtopic = $this->createGTopicMock();
$gtopic
->expects($this->once())
->method('publish')
->with($this->identicalTo(['data' => '{"body":"","properties":[],"headers":[],"attributes":{"key1":"value1"}}', 'attributes' => ['key1' => 'value1']]))
->with($this->identicalTo(['data' => '{"body":"","properties":[],"headers":{"key1":"value1"}}', 'attributes' => ['key1' => 'value1']]))
;

$client = $this->createPubSubClientMock();