Skip to content

Commit

Permalink
Merge fd30ee2 into 676f837
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Aug 23, 2018
2 parents 676f837 + fd30ee2 commit f047c49
Show file tree
Hide file tree
Showing 26 changed files with 741 additions and 92 deletions.
2 changes: 1 addition & 1 deletion examples/demo-async-cluster.php
Expand Up @@ -24,7 +24,7 @@
new IpEndPoint('eventstore3', 2133),
]);

$connection = EventStoreConnectionBuilder::createAsyncFromSettings(
$connection = EventStoreAsyncConnectionBuilder::createFromSettings(
null,
$builder->build(),
'cluster-connection'
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-async-dns-cluster.php
Expand Up @@ -21,7 +21,7 @@
$builder->setClusterDns('escluster.net');
$builder->setClusterGossipPort(2113);

$connection = EventStoreConnectionBuilder::createAsyncFromSettings(
$connection = EventStoreAsyncConnectionBuilder::createFromSettings(
null,
$builder->build(),
'dns-cluster-connection'
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-async-with-logger.php
Expand Up @@ -21,7 +21,7 @@
$builder->enableVerboseLogging();
$builder->useConsoleLogger();

$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113),
$builder->build()
);
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-async.php
Expand Up @@ -17,7 +17,7 @@
require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113)
);

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-subscription-with-logger.php
Expand Up @@ -25,7 +25,7 @@
$builder->enableVerboseLogging();
$builder->useConsoleLogger();

$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113),
$builder->build()
);
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-subscription1.php
Expand Up @@ -22,7 +22,7 @@
require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113)
);

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-subscription2.php
Expand Up @@ -22,7 +22,7 @@
require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113)
);

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-subscription3.php
Expand Up @@ -22,7 +22,7 @@
require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113)
);

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-subscription4.php
Expand Up @@ -22,7 +22,7 @@
require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113)
);

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-subscription5.php
Expand Up @@ -25,7 +25,7 @@
require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113)
);

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-subscription6.php
Expand Up @@ -24,7 +24,7 @@
require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
$connection = EventStoreConnectionBuilder::createAsyncFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113)
);

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-sync.php
Expand Up @@ -14,7 +14,7 @@

require __DIR__ . '/../vendor/autoload.php';

$connection = EventStoreConnectionBuilder::createFromIpEndPoint(
$connection = EventStoreAsyncConnectionBuilder::createFromIpEndPoint(
new IpEndPoint('eventstore', 1113)
);

Expand Down
2 changes: 2 additions & 0 deletions src/ClientOperations/StartAsyncTransactionOperation.php
Expand Up @@ -72,6 +72,8 @@ protected function createRequestDto(): ProtobufMessage
$message->setRequireMaster($this->requireMaster);
$message->setEventStreamId($this->stream);
$message->setExpectedVersion($this->expectedVersion);

return $message;
}

protected function inspectResponse(ProtobufMessage $response): InspectionResult
Expand Down
12 changes: 12 additions & 0 deletions src/EventStoreAsyncConnection.php
Expand Up @@ -122,6 +122,18 @@ public function getStreamMetadataAsync(string $stream, UserCredentials $userCred
/** @return Promise<WriteResult> */
public function setSystemSettingsAsync(SystemSettings $settings, UserCredentials $userCredentials = null): Promise;

/** @return Promise<EventStoreAsyncTransaction> */
public function startTransactionAsync(
string $stream,
int $expectedVersion,
UserCredentials $userCredentials = null
): Promise;

public function continueTransaction(
int $transactionId,
UserCredentials $userCredentials = null
): EventStoreAsyncTransaction;

/** @return Promise<PersistentSubscriptionCreateResult> */
public function createPersistentSubscriptionAsync(
string $stream,
Expand Down
Expand Up @@ -13,15 +13,13 @@
namespace Prooph\EventStoreClient;

use Prooph\EventStoreClient\EventStoreAsyncConnection as AsyncConnection;
use Prooph\EventStoreClient\EventStoreSyncConnection as SyncConnection;
use Prooph\EventStoreClient\Exception\InvalidArgumentException;
use Prooph\EventStoreClient\Internal\ClusterDnsEndPointDiscoverer;
use Prooph\EventStoreClient\Internal\EventStoreAsyncNodeConnection;
use Prooph\EventStoreClient\Internal\EventStoreSyncNodeConnection;
use Prooph\EventStoreClient\Internal\SingleEndpointDiscoverer;
use Prooph\EventStoreClient\Internal\StaticEndPointDiscoverer;

class EventStoreConnectionBuilder
class EventStoreAsyncConnectionBuilder
{
/**
* Sub-delimiters used in user info, query strings and fragments.
Expand All @@ -37,18 +35,18 @@ class EventStoreConnectionBuilder
private const TCP_PORT_DEFAULT = 1113;

/** @throws \Exception */
public static function createAsyncFromBuilder(
public static function createFromBuilder(
string $connectionString = null,
ConnectionSettingsBuilder $builder = null,
string $connectionName = ''
): AsyncConnection {
$builder = $builder ?? new ConnectionSettingsBuilder();

return self::createAsyncFromSettings($connectionString, $builder->build(), $connectionName);
return self::createFromSettings($connectionString, $builder->build(), $connectionName);
}

/** @throws \Exception */
public static function createAsyncFromSettings(
public static function createFromSettings(
string $connectionString = null,
ConnectionSettings $settings = null,
string $connectionName = ''
Expand Down Expand Up @@ -113,7 +111,7 @@ public static function createAsyncFromSettings(
throw new \Exception('Must specify uri, ClusterDNS or gossip seeds');
}

public static function createAsyncFromIpEndPoint(
public static function createFromIpEndPoint(
IpEndPoint $endPoint,
ConnectionSettings $settings = null,
string $connectionName = null
Expand All @@ -128,50 +126,6 @@ public static function createAsyncFromIpEndPoint(
);
}

/** @throws \Exception */
public static function createFromBuilder(
string $connectionString = null,
ConnectionSettingsBuilder $builder = null,
string $connectionName = ''
): SyncConnection {
$connection = self::createAsyncFromBuilder(
$connectionString,
$builder,
$connectionName
);

return new EventStoreSyncNodeConnection($connection);
}

/** @throws \Exception */
public static function createFromSettings(
string $connectionString = null,
ConnectionSettings $settings = null,
string $connectionName = ''
): SyncConnection {
$connection = self::createAsyncFromSettings(
$connectionString,
$settings,
$connectionName
);

return new EventStoreSyncNodeConnection($connection);
}

public static function createFromIpEndPoint(
IpEndPoint $endPoint,
ConnectionSettings $settings = null,
string $connectionName = null
): SyncConnection {
$connection = self::createAsyncFromIpEndPoint(
$endPoint,
$settings,
$connectionName
);

return new EventStoreSyncNodeConnection($connection);
}

private static function createWithClusterDnsEndPointDiscoverer(
ConnectionSettings $settings,
string $connectionName = null
Expand Down
2 changes: 1 addition & 1 deletion src/EventStoreAsyncTransaction.php
Expand Up @@ -44,7 +44,7 @@ public function transactionId(): int
}

/** @return Promise<WriteResult> */
public function commit(): Promise
public function commitAsync(): Promise
{
if ($this->isRolledBack) {
throw new \RuntimeException('Cannot commit a rolledback transaction');
Expand Down
11 changes: 11 additions & 0 deletions src/EventStoreSyncConnection.php
Expand Up @@ -112,6 +112,17 @@ public function getStreamMetadata(string $stream, UserCredentials $userCredentia

public function setSystemSettings(SystemSettings $settings, UserCredentials $userCredentials = null): WriteResult;

public function startTransaction(
string $stream,
int $expectedVersion,
UserCredentials $userCredentials = null
): EventStoreSyncTransaction;

public function continueTransaction(
int $transactionId,
UserCredentials $userCredentials = null
): EventStoreSyncTransaction;

public function onConnected(callable $handler): ListenerHandler;

public function onDisconnected(callable $handler): ListenerHandler;
Expand Down

0 comments on commit f047c49

Please sign in to comment.