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/mongodb
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bf0849b
Choose a base ref
...
head repository: php-enqueue/mongodb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c5eb5d5
Choose a head ref

Commits on May 8, 2018

  1. Copy the full SHA
    c1121b1 View commit details
  2. Update MongodbConsumer.php

    makasim authored May 8, 2018
    Copy the full SHA
    2784b15 View commit details

Commits on Jun 8, 2018

  1. [mongodb] fix test

    makasim committed Jun 8, 2018
    Copy the full SHA
    9386630 View commit details

Commits on Aug 8, 2018

  1. fix deps.

    makasim committed Aug 8, 2018
    Copy the full SHA
    e4d7a8f View commit details
  2. Copy the full SHA
    39db8f5 View commit details
  3. fix travis for mongodb

    makasim committed Aug 8, 2018
    Copy the full SHA
    eacff06 View commit details
  4. Copy the full SHA
    f3598fb View commit details
  5. Copy the full SHA
    60573ce View commit details
  6. fix mongodb tests.

    makasim committed Aug 8, 2018
    Copy the full SHA
    249e55c View commit details
  7. Copy the full SHA
    1dc213e View commit details

Commits on Aug 9, 2018

  1. Copy the full SHA
    bd77de8 View commit details

Commits on Aug 12, 2018

  1. Get rid of path repository.

    makasim committed Aug 12, 2018
    Copy the full SHA
    2a39b86 View commit details

Commits on Aug 14, 2018

  1. fix tests.

    makasim committed Aug 14, 2018
    Copy the full SHA
    16816ec View commit details

Commits on Aug 22, 2018

  1. Migrate mongodb transport.

    makasim committed Aug 22, 2018
    Copy the full SHA
    bf7a6ea View commit details
  2. upd spec version.

    makasim committed Aug 22, 2018
    Copy the full SHA
    cf972c2 View commit details

Commits on Aug 25, 2018

  1. Copy the full SHA
    949dd3f View commit details

Commits on Sep 4, 2018

  1. Copy the full SHA
    baca096 View commit details

Commits on Sep 28, 2018

  1. Copy the full SHA
    139c649 View commit details
  2. Copy the full SHA
    e9d8364 View commit details

Commits on Oct 17, 2018

  1. Copy the full SHA
    208f27c View commit details
  2. Copy the full SHA
    7d4c27f View commit details

Commits on Oct 18, 2018

  1. Copy the full SHA
    7de21e0 View commit details
  2. Copy the full SHA
    e2fa63a View commit details
  3. Copy the full SHA
    0b42c72 View commit details
  4. Merge pull request #565 from rosamarsky/mongodb-subscription-consumer

    MongoDB Subscription Consumer feature
    makasim authored Oct 18, 2018
    Copy the full SHA
    4ca9288 View commit details

Commits on Oct 22, 2018

  1. Copy the full SHA
    223b689 View commit details

Commits on Oct 27, 2018

  1. Copy the full SHA
    44a0e09 View commit details

Commits on Nov 6, 2018

  1. Copy the full SHA
    826ced9 View commit details
  2. Copy the full SHA
    c747f04 View commit details

Commits on Nov 16, 2018

  1. multi client configuration

    ASKozienko committed Nov 16, 2018
    Copy the full SHA
    e68c03c View commit details

Commits on Nov 22, 2018

  1. Do not export non source files

    (cherry picked from commit 404fae1)
    webmake committed Nov 22, 2018
    Copy the full SHA
    e7c5d1e View commit details
  2. Copy the full SHA
    cddf55f View commit details

Commits on Dec 6, 2018

  1. fix: polling_interval is an integer

    Jak Spalding committed Dec 6, 2018
    Copy the full SHA
    0ac064b View commit details

Commits on Dec 13, 2018

  1. Copy the full SHA
    e4b1c39 View commit details

Commits on May 27, 2019

  1. Prefer github pages in packages' readme files

    Paweł Niedzielski committed May 27, 2019
    Copy the full SHA
    82b2121 View commit details

Commits on Jun 7, 2019

  1. Fix Code Style in all files

    Steveb-p committed Jun 7, 2019
    Copy the full SHA
    ec59b9e View commit details

Commits on Dec 12, 2019

  1. Reduced dependency to voryx/Thruway

    Mathieu Lemoine committed Dec 12, 2019
    Copy the full SHA
    a6f398b View commit details
  2. drop support for Symfony < 4.3

    Mathieu Lemoine committed Dec 12, 2019
    Copy the full SHA
    58c46d7 View commit details

Commits on Dec 19, 2019

  1. master is 0.10

    makasim committed Dec 19, 2019
    Copy the full SHA
    777c40e View commit details

Commits on Jan 26, 2020

  1. Copy the full SHA
    1a8a2da View commit details

Commits on Mar 18, 2020

  1. fix(mongodb): Exception throwing fatal error, Broken handling of Mong…

    …odbConnectionFactory config, Incorrect MongodbConnectionFactory documentation
    
    Closes: #1031, #1027
    josefsabl committed Mar 18, 2020
    Copy the full SHA
    8bf43ce View commit details

Commits on Mar 19, 2020

  1. Copy the full SHA
    f49955c View commit details

Commits on Aug 5, 2020

  1. Copy the full SHA
    385d00e View commit details

Commits on Jan 22, 2021

  1. Fix more setUp signatures

    andrewmy committed Jan 22, 2021
    Copy the full SHA
    ba313bf View commit details

Commits on Jan 24, 2021

  1. Copy the full SHA
    4bb0dd9 View commit details
  2. Copy the full SHA
    2ae4c5e View commit details

Commits on Jan 25, 2021

  1. Fix CS

    andrewmy committed Jan 25, 2021
    Copy the full SHA
    adf80a7 View commit details
  2. Copy the full SHA
    3466d29 View commit details

Commits on Feb 9, 2021

  1. Fix package CI

    - Add push to master trigger;
    - Replace the clunky cache + composer install steps with an Action;
    - Replace Travis with GH WF in packages;
    - Add the missing CI to amqp-tools;
    - Replace the shields.
    andrewmy committed Feb 9, 2021
    Copy the full SHA
    b9a9c66 View commit details
  2. Copy the full SHA
    69f8d48 View commit details
Showing with 847 additions and 1,316 deletions.
  1. +5 −0 .gitattributes
  2. +30 −0 .github/workflows/ci.yml
  3. +0 −186 Client/MongodbDriver.php
  4. +7 −20 JSON.php
  5. +24 −13 MongodbConnectionFactory.php
  6. +29 −60 MongodbConsumer.php
  7. +79 −23 MongodbContext.php
  8. +10 −21 MongodbDestination.php
  9. +38 −126 MongodbMessage.php
  10. +26 −52 MongodbProducer.php
  11. +133 −0 MongodbSubscriptionConsumer.php
  12. +16 −7 README.md
  13. +0 −119 Symfony/MongodbTransportFactory.php
  14. +0 −351 Tests/Client/MongodbDriverTest.php
  15. +2 −2 Tests/Functional/MongodbConsumerTest.php
  16. +20 −5 Tests/MongodbConnectionFactoryTest.php
  17. +41 −34 Tests/MongodbConsumerTest.php
  18. +39 −15 Tests/MongodbContextTest.php
  19. +9 −8 Tests/MongodbDestinationTest.php
  20. +2 −1 Tests/MongodbMessageTest.php
  21. +8 −26 Tests/MongodbProducerTest.php
  22. +178 −0 Tests/MongodbSubscriptionConsumerTest.php
  23. +2 −5 Tests/Spec/MongodbConnectionFactoryTest.php
  24. +2 −5 Tests/Spec/MongodbContextTest.php
  25. +2 −5 Tests/Spec/MongodbMessageTest.php
  26. +2 −5 Tests/Spec/MongodbProducerTest.php
  27. +2 −5 Tests/Spec/MongodbQueueTest.php
  28. +0 −3 Tests/Spec/MongodbRequeueMessageTest.php
  29. +0 −3 Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php
  30. +4 −6 Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php
  31. +0 −3 Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php
  32. +0 −3 Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php
  33. +0 −3 Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php
  34. +0 −3 Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php
  35. +0 −3 Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php
  36. +40 −0 Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php
  37. +40 −0 Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php
  38. +40 −0 Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php
  39. +2 −5 Tests/Spec/MongodbTopicTest.php
  40. +0 −164 Tests/Symfony/MongodbTransportFactoryTest.php
  41. +9 −15 composer.json
  42. +6 −11 phpunit.xml.dist
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/Tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpunit.xml.dist export-ignore
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']

name: PHP ${{ matrix.php }} tests

steps:
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: mongodb

- uses: "ramsey/composer-install@v1"
with:
composer-options: "--prefer-source"

- run: vendor/bin/phpunit --exclude-group=functional
186 changes: 0 additions & 186 deletions Client/MongodbDriver.php

This file was deleted.

27 changes: 7 additions & 20 deletions JSON.php
Original file line number Diff line number Diff line change
@@ -14,10 +14,7 @@ class JSON
public static function decode($string)
{
if (!is_string($string)) {
throw new \InvalidArgumentException(sprintf(
'Accept only string argument but got: "%s"',
is_object($string) ? get_class($string) : gettype($string)
));
throw new \InvalidArgumentException(sprintf('Accept only string argument but got: "%s"', is_object($string) ? $string::class : gettype($string)));
}

// PHP7 fix - empty string and null cause syntax error
@@ -26,32 +23,22 @@ public static function decode($string)
}

$decoded = json_decode($string, true);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf(
'The malformed json given. Error %s and message %s',
json_last_error(),
json_last_error_msg()
));
if (\JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}

return $decoded;
}

/**
* @param mixed $value
*
* @return string
*/
public static function encode($value)
{
$encoded = json_encode($value, JSON_UNESCAPED_UNICODE);

if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf(
'Could not encode value into json. Error %s and message %s',
json_last_error(),
json_last_error_msg()
));
$encoded = json_encode($value, \JSON_UNESCAPED_UNICODE);

if (\JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg()));
}

return $encoded;
37 changes: 24 additions & 13 deletions MongodbConnectionFactory.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

declare(strict_types=1);

namespace Enqueue\Mongodb;

use Interop\Queue\PsrConnectionFactory;
use Interop\Queue\ConnectionFactory;
use Interop\Queue\Context;
use MongoDB\Client;

class MongodbConnectionFactory implements PsrConnectionFactory
class MongodbConnectionFactory implements ConnectionFactory
{
/**
* @var array
@@ -24,7 +27,7 @@ class MongodbConnectionFactory implements PsrConnectionFactory
*
* or
*
* mongodb://127.0.0.1:27017/dbname?polling_interval=1000&enqueue_collection=enqueue
* mongodb://127.0.0.1:27017/defaultauthdb?polling_interval=1000&enqueue_database=enqueue&enqueue_collection=enqueue
*
* @param array|string|null $config
*/
@@ -35,6 +38,10 @@ public function __construct($config = 'mongodb:')
} elseif (is_string($config)) {
$config = $this->parseDsn($config);
} elseif (is_array($config)) {
$config = array_replace(
$config,
$this->parseDsn(empty($config['dsn']) ? 'mongodb:' : $config['dsn'])
);
} else {
throw new \LogicException('The config must be either an array of options, a DSN string or null');
}
@@ -47,14 +54,17 @@ public function __construct($config = 'mongodb:')
$this->config = $config;
}

public function createContext()
/**
* @return MongodbContext
*/
public function createContext(): Context
{
$client = new Client($this->config['dsn']);

return new MongodbContext($client, $this->config);
}

public static function parseDsn($dsn)
public static function parseDsn(string $dsn): array
{
$parsedUrl = parse_url($dsn);
if (false === $parsedUrl) {
@@ -67,35 +77,36 @@ public static function parseDsn($dsn)
'mongodb' => true,
];
if (false == isset($parsedUrl['scheme'])) {
throw new \LogicException(sprintf(
'The given DSN schema "%s" is not supported. There are supported schemes: "%s".',
$parsedUrl['scheme'],
implode('", "', array_keys($supported))
));
throw new \LogicException(sprintf('The given DSN schema "%s" is not supported. There are supported schemes: "%s".', $parsedUrl['scheme'], implode('", "', array_keys($supported))));
}
if ('mongodb:' === $dsn) {
return [
'dsn' => 'mongodb://127.0.0.1/',
];
}
$config['dsn'] = $dsn;
// FIXME this is NOT a dbname but rather authdb. But removing this would be a BC break.
// see: https://github.com/php-enqueue/enqueue-dev/issues/1027
if (isset($parsedUrl['path']) && '/' !== $parsedUrl['path']) {
$pathParts = explode('/', $parsedUrl['path']);
//DB name
// DB name
if ($pathParts[1]) {
$config['dbname'] = $pathParts[1];
}
}
if (isset($parsedUrl['query'])) {
$queryParts = null;
parse_str($parsedUrl['query'], $queryParts);
//get enqueue attributes values
// get enqueue attributes values
if (!empty($queryParts['polling_interval'])) {
$config['polling_interval'] = $queryParts['polling_interval'];
$config['polling_interval'] = (int) $queryParts['polling_interval'];
}
if (!empty($queryParts['enqueue_collection'])) {
$config['collection_name'] = $queryParts['enqueue_collection'];
}
if (!empty($queryParts['enqueue_database'])) {
$config['dbname'] = $queryParts['enqueue_database'];
}
}

return $config;
Loading