Skip to content

Commit

Permalink
rename UuidGenerator => Uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Nov 19, 2018
1 parent f9fbb80 commit c2dccf9
Show file tree
Hide file tree
Showing 64 changed files with 160 additions and 160 deletions.
8 changes: 4 additions & 4 deletions src/EventId.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Prooph\EventStoreClient;

use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;
use Ramsey\Uuid\UuidInterface;

class EventId
Expand All @@ -23,17 +23,17 @@ class EventId

public static function generate(): EventId
{
return new self(UuidGenerator::generate());
return new self(Uuid::generate());
}

public static function fromString(string $eventId): EventId
{
return new self(UuidGenerator::fromString($eventId));
return new self(Uuid::fromString($eventId));
}

public static function fromBinary(string $bytes): EventId
{
return new self(UuidGenerator::fromBytes($bytes));
return new self(Uuid::fromBytes($bytes));
}

private function __construct(UuidInterface $eventId)
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/EventStoreAsyncNodeConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
use Prooph\EventStoreClient\SystemSettings;
use Prooph\EventStoreClient\UserCredentials;
use Prooph\EventStoreClient\Util\Json;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;
use Throwable;

final class EventStoreAsyncNodeConnection implements
Expand All @@ -91,7 +91,7 @@ public function __construct(
) {
$this->settings = $settings;
$this->clusterSettings = $clusterSettings;
$this->connectionName = $connectionName ?? UuidGenerator::generateWithoutDash();
$this->connectionName = $connectionName ?? Uuid::generateWithoutDash();
$this->endPointDiscoverer = $endPointDiscoverer;
$this->handler = new EventStoreConnectionLogicHandler($this, $settings);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Internal/EventStoreConnectionLogicHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
use Prooph\EventStoreClient\SystemData\TcpFlags;
use Prooph\EventStoreClient\SystemData\TcpPackage;
use Prooph\EventStoreClient\Transport\Tcp\TcpPackageConnection;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;
use Throwable;

/** @internal */
Expand Down Expand Up @@ -316,7 +316,7 @@ private function establishTcpConnection(NodeEndPoints $endPoints): void
$this->connection = new TcpPackageConnection(
$this->settings->log(),
$endPoint,
UuidGenerator::generateWithoutDash(),
Uuid::generateWithoutDash(),
$this->settings->useSslConnection(),
$this->settings->targetHost(),
$this->settings->validateServer(),
Expand Down Expand Up @@ -386,7 +386,7 @@ private function tcpConnectionClosed(TcpPackageConnection $connection): void
) {
$this->logDebug('IGNORED (state: %s, internal conn.ID: {1:B}, conn.ID: %s): TCP connection to [%s] closed',
$this->state,
null === $this->connection ? UuidGenerator::empty() : $this->connection->connectionId(),
null === $this->connection ? Uuid::empty() : $this->connection->connectionId(),
$connection->connectionId(),
$connection->remoteEndPoint()
);
Expand Down Expand Up @@ -421,7 +421,7 @@ private function tcpConnectionEstablished(TcpPackageConnection $connection): voi
) {
$this->logDebug('IGNORED (state %s, internal conn.Id %s, conn.Id %s, conn.closed %s): TCP connection to [%s] established',
$this->state,
null === $this->connection ? UuidGenerator::empty() : $this->connection->connectionId(),
null === $this->connection ? Uuid::empty() : $this->connection->connectionId(),
$connection->connectionId(),
$connection->isClosed() ? 'yes' : 'no',
$connection->remoteEndPoint()
Expand All @@ -438,7 +438,7 @@ private function tcpConnectionEstablished(TcpPackageConnection $connection): voi
if ($this->settings->defaultUserCredentials() !== null) {
$this->connectingPhase = ConnectingPhase::authentication();

$this->authInfo = new AuthInfo(UuidGenerator::generateWithoutDash(), $elapsed);
$this->authInfo = new AuthInfo(Uuid::generateWithoutDash(), $elapsed);

$login = null;
$pass = null;
Expand All @@ -464,7 +464,7 @@ private function tcpConnectionEstablished(TcpPackageConnection $connection): voi
private function goToIdentifyState(): void
{
$this->connectingPhase = ConnectingPhase::identification();
$this->identityInfo = new IdentifyInfo(UuidGenerator::generateWithoutDash(), $this->stopWatch->elapsed());
$this->identityInfo = new IdentifyInfo(Uuid::generateWithoutDash(), $this->stopWatch->elapsed());

$message = new IdentifyClient();
$message->setVersion(self::CLIENT_VERSION);
Expand Down Expand Up @@ -582,7 +582,7 @@ private function manageHeartbeats(): void
$this->connection->enqueueSend(new TcpPackage(
TcpCommand::heartbeatRequestCommand(),
TcpFlags::none(),
UuidGenerator::generateWithoutDash()
Uuid::generateWithoutDash()
));

$this->heartbeatInfo = new HeartbeatInfo($this->heartbeatInfo->lastPackageNumber(), false, $elapsed);
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/OperationItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use DateTimeImmutable;
use Prooph\EventStoreClient\ClientOperations\ClientOperation;
use Prooph\EventStoreClient\Util\DateTime;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;

/** @internal */
class OperationItem
Expand Down Expand Up @@ -49,7 +49,7 @@ public function __construct(ClientOperation $operation, int $maxRetries, int $ti
$this->maxRetries = $maxRetries;
$this->timeout = $timeout;
$this->created = DateTime::utcNow();
$this->correlationId = UuidGenerator::generateWithoutDash();
$this->correlationId = Uuid::generateWithoutDash();
$this->retryCount = 0;
$this->lastUpdated = $this->created;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/OperationsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Prooph\EventStoreClient\Exception\RetriesLimitReachedException;
use Prooph\EventStoreClient\Transport\Tcp\TcpPackageConnection;
use Prooph\EventStoreClient\Util\DateTime;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;
use SplQueue;

/** @internal */
Expand Down Expand Up @@ -141,7 +141,7 @@ public function checkTimeoutsAndRetry(TcpPackageConnection $connection): void

foreach ($this->retryPendingOperations as $operation) {
$oldCorrId = $operation->correlationId();
$operation->setCorrelationId(UuidGenerator::generateWithoutDash());
$operation->setCorrelationId(Uuid::generateWithoutDash());
$operation->incRetryCount();
$this->logDebug('retrying, old corrId %s, operation %s', $oldCorrId, $operation);
$this->scheduleOperation($operation, $connection);
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/SubscriptionItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use DateTimeImmutable;
use Prooph\EventStoreClient\ClientOperations\SubscriptionOperation;
use Prooph\EventStoreClient\Util\DateTime;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;

/** @internal */
class SubscriptionItem
Expand Down Expand Up @@ -47,7 +47,7 @@ public function __construct(SubscriptionOperation $operation, int $maxRetries, i
$this->maxRetries = $maxRetries;
$this->timeout = $timeout;
$this->created = DateTime::utcNow();
$this->correlationId = UuidGenerator::generateWithoutDash();
$this->correlationId = Uuid::generateWithoutDash();
$this->retryCount = 0;
$this->lastUpdated = $this->created;
$this->isSubscribed = false;
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/SubscriptionsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Prooph\EventStoreClient\SubscriptionDropReason;
use Prooph\EventStoreClient\Transport\Tcp\TcpPackageConnection;
use Prooph\EventStoreClient\Util\DateTime;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;
use SplQueue;

/** @internal */
Expand Down Expand Up @@ -201,7 +201,7 @@ public function startSubscription(SubscriptionItem $subscription, TcpPackageConn
return;
}

$correlationId = UuidGenerator::generateWithoutDash();
$correlationId = Uuid::generateWithoutDash();
$subscription->setCorrelationId($correlationId);
$subscription->setConnectionId($connection->connectionId());
$subscription->setLastUpdated(DateTime::utcNow());
Expand Down
2 changes: 1 addition & 1 deletion src/Util/UuidGenerator.php → src/Util/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Ramsey\Uuid\UuidFactory;
use Ramsey\Uuid\UuidInterface;

class UuidGenerator
class Uuid
{
/** @var UuidFactory */
private static $factory;
Expand Down
6 changes: 3 additions & 3 deletions tests/ProjectionSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Prooph\EventStoreClient\ExpectedVersion;
use Prooph\EventStoreClient\Projections\ProjectionsManager;
use Prooph\EventStoreClient\UserCredentials;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;
use ProophTest\EventStoreClient\Helper\TestConnection;
use Throwable;
use function Amp\call;
Expand Down Expand Up @@ -87,14 +87,14 @@ protected function postEvent(string $stream, string $eventType, string $data): P

protected function createOneTimeProjection(string $type): Promise
{
$query = $this->createStandardQuery(UuidGenerator::generateWithoutDash());
$query = $this->createStandardQuery(Uuid::generateWithoutDash());

return $this->projectionsManager->createOneTimeAsync($query, $type, $this->credentials);
}

protected function createContinuousProjection(string $projectionName, string $type): Promise
{
$query = $this->createStandardQuery(UuidGenerator::generateWithoutDash());
$query = $this->createStandardQuery(Uuid::generateWithoutDash());

return $this->projectionsManager->createContinuousAsync(
$projectionName,
Expand Down
6 changes: 3 additions & 3 deletions tests/SpecificationWithLinkToToDeletedEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Prooph\EventStoreClient\Common\SystemEventTypes;
use Prooph\EventStoreClient\EventData;
use Prooph\EventStoreClient\ExpectedVersion;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;

trait SpecificationWithLinkToToDeletedEvents
{
Expand All @@ -31,8 +31,8 @@ trait SpecificationWithLinkToToDeletedEvents
protected function given(): Generator
{
$creds = DefaultData::adminCredentials();
$this->linkedStreamName = UuidGenerator::generateWithoutDash();
$this->deletedStreamName = UuidGenerator::generateWithoutDash();
$this->linkedStreamName = Uuid::generateWithoutDash();
$this->deletedStreamName = Uuid::generateWithoutDash();

yield $this->conn->appendToStreamAsync(
$this->deletedStreamName,
Expand Down
6 changes: 3 additions & 3 deletions tests/SpecificationWithLinkToToMaxCountDeletedEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Prooph\EventStoreClient\EventId;
use Prooph\EventStoreClient\ExpectedVersion;
use Prooph\EventStoreClient\StreamMetadata;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;

trait SpecificationWithLinkToToMaxCountDeletedEvents
{
Expand All @@ -34,8 +34,8 @@ protected function given(): Generator
{
$creds = DefaultData::adminCredentials();

$this->deletedStreamName = UuidGenerator::generateWithoutDash();
$this->linkedStreamName = UuidGenerator::generateWithoutDash();
$this->deletedStreamName = Uuid::generateWithoutDash();
$this->linkedStreamName = Uuid::generateWithoutDash();

yield $this->conn->appendToStreamAsync(
$this->deletedStreamName,
Expand Down
22 changes: 11 additions & 11 deletions tests/SystemData/clientapi_tcp_package.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Prooph\EventStoreClient\SystemData\TcpCommand;
use Prooph\EventStoreClient\SystemData\TcpFlags;
use Prooph\EventStoreClient\SystemData\TcpPackage;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;

class clientapi_tcp_package extends TestCase
{
Expand All @@ -27,37 +27,37 @@ public function should_throw_argument_null_exception_when_created_as_authorized_
{
$this->expectException(InvalidArgumentException::class);

new TcpPackage(TcpCommand::badRequest(), TcpFlags::authenticated(), UuidGenerator::generateWithoutDash(), '');
new TcpPackage(TcpCommand::badRequest(), TcpFlags::authenticated(), Uuid::generateWithoutDash(), '');
}

/** @test */
public function should_throw_argument_null_exception_when_created_as_authorized_but_password_not_provided(): void
{
$this->expectException(InvalidArgumentException::class);

new TcpPackage(TcpCommand::badRequest(), TcpFlags::authenticated(), UuidGenerator::generateWithoutDash(), '', 'login');
new TcpPackage(TcpCommand::badRequest(), TcpFlags::authenticated(), Uuid::generateWithoutDash(), '', 'login');
}

/** @test */
public function should_throw_argument_exception_when_created_as_not_authorized_but_login_is_provided(): void
{
$this->expectException(InvalidArgumentException::class);

new TcpPackage(TcpCommand::badRequest(), TcpFlags::none(), UuidGenerator::generateWithoutDash(), '', 'login', null);
new TcpPackage(TcpCommand::badRequest(), TcpFlags::none(), Uuid::generateWithoutDash(), '', 'login', null);
}

/** @test */
public function should_throw_argument_exception_when_created_as_not_authorized_but_password_is_provided(): void
{
$this->expectException(InvalidArgumentException::class);

new TcpPackage(TcpCommand::badRequest(), TcpFlags::none(), UuidGenerator::generateWithoutDash(), '', null, 'pa$$');
new TcpPackage(TcpCommand::badRequest(), TcpFlags::none(), Uuid::generateWithoutDash(), '', null, 'pa$$');
}

/** @test */
public function not_authorized_with_data_should_serialize_and_deserialize_correctly(): void
{
$corrId = UuidGenerator::generateWithoutDash();
$corrId = Uuid::generateWithoutDash();
$refPkg = new TcpPackage(TcpCommand::badRequest(), TcpFlags::none(), $corrId, 'data');
$bytes = $refPkg->asBytes();
$pkg = TcpPackage::fromRawData($bytes);
Expand All @@ -73,7 +73,7 @@ public function not_authorized_with_data_should_serialize_and_deserialize_correc
/** @test */
public function not_authorized_with_empty_data_should_serialize_and_deserialize_correctly(): void
{
$corrId = UuidGenerator::generateWithoutDash();
$corrId = Uuid::generateWithoutDash();
$refPkg = new TcpPackage(TcpCommand::badRequest(), TcpFlags::none(), $corrId);
$bytes = $refPkg->asBytes();
$pkg = TcpPackage::fromRawData($bytes);
Expand All @@ -89,7 +89,7 @@ public function not_authorized_with_empty_data_should_serialize_and_deserialize_
/** @test */
public function authorized_with_data_should_serialize_and_deserialize_correctly(): void
{
$corrId = UuidGenerator::generateWithoutDash();
$corrId = Uuid::generateWithoutDash();
$refPkg = new TcpPackage(TcpCommand::badRequest(), TcpFlags::authenticated(), $corrId, 'data', 'login', 'password');
$bytes = $refPkg->asBytes();
$pkg = TcpPackage::fromRawData($bytes);
Expand All @@ -105,7 +105,7 @@ public function authorized_with_data_should_serialize_and_deserialize_correctly(
/** @test */
public function authorized_with_empty_data_should_serialize_and_deserialize_correctly(): void
{
$corrId = UuidGenerator::generateWithoutDash();
$corrId = Uuid::generateWithoutDash();
$refPkg = new TcpPackage(TcpCommand::badRequest(), TcpFlags::authenticated(), $corrId, '', 'login', 'password');
$bytes = $refPkg->asBytes();
$pkg = TcpPackage::fromRawData($bytes);
Expand All @@ -121,7 +121,7 @@ public function authorized_with_empty_data_should_serialize_and_deserialize_corr
/** @test */
public function should_throw_argument_exception_on_serialization_when_login_too_long(): void
{
$corrId = UuidGenerator::generateWithoutDash();
$corrId = Uuid::generateWithoutDash();
$pkg = new TcpPackage(TcpCommand::badRequest(), TcpFlags::authenticated(), $corrId, '', \str_repeat('*', 256), 'password');

$this->expectException(InvalidArgumentException::class);
Expand All @@ -132,7 +132,7 @@ public function should_throw_argument_exception_on_serialization_when_login_too_
/** @test */
public function should_throw_argument_exception_on_serialization_when_password_too_long(): void
{
$corrId = UuidGenerator::generateWithoutDash();
$corrId = Uuid::generateWithoutDash();
$pkg = new TcpPackage(TcpCommand::badRequest(), TcpFlags::authenticated(), $corrId, '', 'login', \str_repeat('*', 256));

$this->expectException(InvalidArgumentException::class);
Expand Down
4 changes: 2 additions & 2 deletions tests/UserManagement/TestWithUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ProophTest\EventStoreClient\UserManagement;

use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;
use ProophTest\EventStoreClient\DefaultData;

abstract class TestWithUser extends TestWithNode
Expand All @@ -25,7 +25,7 @@ protected function setUp(): void
{
parent::setUp();

$this->username = UuidGenerator::generateString();
$this->username = Uuid::generateString();

$this->manager->createUser(
$this->username,
Expand Down
4 changes: 2 additions & 2 deletions tests/UserManagement/creating_a_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Exception;
use Prooph\EventStoreClient\Exception\InvalidArgumentException;
use Prooph\EventStoreClient\Util\UuidGenerator;
use Prooph\EventStoreClient\Util\Uuid;
use ProophTest\EventStoreClient\DefaultData;

class creating_a_user extends TestWithNode
Expand Down Expand Up @@ -70,7 +70,7 @@ public function fetching_user_with_empty_name_throws(): void
/** @test */
public function creating_a_user_with_parameters_can_be_read(): void
{
$login = UuidGenerator::generateString();
$login = Uuid::generateString();

$this->manager->createUser(
$login,
Expand Down

0 comments on commit c2dccf9

Please sign in to comment.