Skip to content

Commit

Permalink
Merge pull request #12 from prooph/noooooooo
Browse files Browse the repository at this point in the history
I DO NOT WANT TO DO THIS, UPPERCASE IS UTTERLY STUPID
  • Loading branch information
prolic committed Aug 21, 2018
2 parents d2042fe + 56ea455 commit 676f837
Show file tree
Hide file tree
Showing 87 changed files with 700 additions and 684 deletions.
4 changes: 2 additions & 2 deletions examples/demo-async-cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

\var_dump($m);

$r = yield $connection->setStreamMetadataAsync('foo-bar', ExpectedVersion::Any, new StreamMetadata(
$r = yield $connection->setStreamMetadataAsync('foo-bar', ExpectedVersion::ANY, new StreamMetadata(
null, null, null, null, null, [
'foo' => 'bar',
]
Expand All @@ -78,7 +78,7 @@

\var_dump($m);

$wr = yield $connection->appendToStreamAsync('foo-bar', ExpectedVersion::Any, [
$wr = yield $connection->appendToStreamAsync('foo-bar', ExpectedVersion::ANY, [
new EventData(EventId::generate(), 'test-type', false, 'jfkhksdfhsds', 'meta'),
new EventData(EventId::generate(), 'test-type2', false, 'kldjfls', 'meta'),
new EventData(EventId::generate(), 'test-type3', false, 'aaa', 'meta'),
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-async-dns-cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

\var_dump($m);

$r = yield $connection->setStreamMetadataAsync('foo-bar', ExpectedVersion::Any, new StreamMetadata(
$r = yield $connection->setStreamMetadataAsync('foo-bar', ExpectedVersion::ANY, new StreamMetadata(
null, null, null, null, null, [
'foo' => 'bar',
]
Expand All @@ -75,7 +75,7 @@

\var_dump($m);

$wr = yield $connection->appendToStreamAsync('foo-bar', ExpectedVersion::Any, [
$wr = yield $connection->appendToStreamAsync('foo-bar', ExpectedVersion::ANY, [
new EventData(EventId::generate(), 'test-type', false, 'jfkhksdfhsds', 'meta'),
new EventData(EventId::generate(), 'test-type2', false, 'kldjfls', 'meta'),
new EventData(EventId::generate(), 'test-type3', false, 'aaa', 'meta'),
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-async-with-logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

\var_dump(\get_class($m));

$r = yield $connection->setStreamMetadataAsync('foo-bar', ExpectedVersion::Any, new StreamMetadata(
$r = yield $connection->setStreamMetadataAsync('foo-bar', ExpectedVersion::ANY, new StreamMetadata(
null, null, null, null, null, [
'foo' => 'bar',
]
Expand All @@ -74,7 +74,7 @@

\var_dump(\get_class($m));

$wr = yield $connection->appendToStreamAsync('foo-bar', ExpectedVersion::Any, [
$wr = yield $connection->appendToStreamAsync('foo-bar', ExpectedVersion::ANY, [
new EventData(EventId::generate(), 'test-type', false, 'jfkhksdfhsds', 'meta'),
new EventData(EventId::generate(), 'test-type2', false, 'kldjfls', 'meta'),
new EventData(EventId::generate(), 'test-type3', false, 'aaa', 'meta'),
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-async.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

\var_dump($m);

$r = yield $connection->setStreamMetadataAsync('foo-bar', ExpectedVersion::Any, new StreamMetadata(
$r = yield $connection->setStreamMetadataAsync('foo-bar', ExpectedVersion::ANY, new StreamMetadata(
null, null, null, null, null, [
'foo' => 'bar',
]
Expand All @@ -69,7 +69,7 @@

\var_dump($m);

$wr = yield $connection->appendToStreamAsync('foo-bar', ExpectedVersion::Any, [
$wr = yield $connection->appendToStreamAsync('foo-bar', ExpectedVersion::ANY, [
new EventData(EventId::generate(), 'test-type', false, 'jfkhksdfhsds', 'meta'),
new EventData(EventId::generate(), 'test-type2', false, 'kldjfls', 'meta'),
new EventData(EventId::generate(), 'test-type3', false, 'aaa', 'meta'),
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

\var_dump($m);

$wr = $connection->appendToStream('foo-bar', ExpectedVersion::Any, [
$wr = $connection->appendToStream('foo-bar', ExpectedVersion::ANY, [
new EventData(EventId::generate(), 'test-type', false, 'jfkhksdfhsds', 'meta'),
new EventData(EventId::generate(), 'test-type2', false, 'kldjfls', 'meta'),
new EventData(EventId::generate(), 'test-type3', false, 'aaa', 'meta'),
Expand Down
8 changes: 4 additions & 4 deletions src/CatchUpSubscriptionSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public function __construct(
throw new InvalidArgumentException('Max live queue size must be positive');
}

if ($readBatchSize > Consts::MaxReadSize) {
if ($readBatchSize > Consts::MAX_READ_SIZE) {
throw new InvalidArgumentException(\sprintf(
'Read batch size should be less than \'%s\'. For larger reads you should page',
Consts::MaxReadSize
Consts::MAX_READ_SIZE
));
}

Expand All @@ -73,8 +73,8 @@ public function __construct(
public static function default(): self
{
return new self(
Consts::CatchUpDefaultMaxPushQueueSize,
Consts::CatchUpDefaultReadBatchSize,
Consts::CATCH_UP_DEFAULT_MAX_PUSH_QUEUE_SIZE,
Consts::CATCH_UP_DEFAULT_READ_BATCH_SIZE,
false,
true,
''
Expand Down
6 changes: 3 additions & 3 deletions src/ClientOperations/AbstractOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ public function inspectPackage(TcpPackage $package): InspectionResult
}

switch ($package->command()->value()) {
case TcpCommand::NotAuthenticatedException:
case TcpCommand::NOT_AUTHENTICATED_EXCEPTION:
return $this->inspectNotAuthenticated($package);
case TcpCommand::BadRequest:
case TcpCommand::BAD_REQUEST:
return $this->inspectBadRequest($package);
case TcpCommand::NotHandled:
case TcpCommand::NOT_HANDLED:
return $this->inspectNotHandled($package);
default:
return $this->inspectUnexpectedCommand($package, $this->responseCommand);
Expand Down
8 changes: 4 additions & 4 deletions src/ClientOperations/AbstractSubscriptionOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function inspectPackage(TcpPackage $package): InspectionResult
}

switch ($package->command()->value()) {
case TcpCommand::SubscriptionDropped:
case TcpCommand::SUBSCRIPTION_DROPPED:
$message = new SubscriptionDroppedMessage();
$message->parseFromString($package->data());

Expand Down Expand Up @@ -183,15 +183,15 @@ public function inspectPackage(TcpPackage $package): InspectionResult
}

return new InspectionResult(InspectionDecision::endOperation(), 'SubscriptionDropped: ' . $message->getReason());
case TcpCommand::NotAuthenticatedException:
case TcpCommand::NOT_AUTHENTICATED_EXCEPTION:
$this->dropSubscription(SubscriptionDropReason::notAuthenticated(), new NotAuthenticatedException());

return new InspectionResult(InspectionDecision::endOperation(), 'NotAuthenticated');
case TcpCommand::BadRequest:
case TcpCommand::BAD_REQUEST:
$this->dropSubscription(SubscriptionDropReason::serverError(), new ServerError());

return new InspectionResult(InspectionDecision::endOperation(), 'BadRequest');
case TcpCommand::NotHandled:
case TcpCommand::NOT_HANDLED:
if (null !== $this->subscription) {
throw new \Exception('NotHandledException command appeared while we were already subscribed');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function createRequestDto(): ProtobufMessage
$message->setReadBatchSize($this->settings->readBatchSize());
$message->setBufferSize($this->settings->bufferSize());
$message->setMaxRetryCount($this->settings->maxRetryCount());
$message->setPreferRoundRobin($this->settings->namedConsumerStrategy()->name() === SystemConsumerStrategies::RoundRobin);
$message->setPreferRoundRobin($this->settings->namedConsumerStrategy()->name() === SystemConsumerStrategies::ROUND_ROBIN);
$message->setCheckpointAfterTime($this->settings->checkPointAfterMilliseconds());
$message->setCheckpointMaxCount($this->settings->maxCheckPointCount());
$message->setCheckpointMinCount($this->settings->minCheckPointCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function createRequestDto(): ProtobufMessage
$message->setReadBatchSize($this->settings->readBatchSize());
$message->setBufferSize($this->settings->bufferSize());
$message->setMaxRetryCount($this->settings->maxRetryCount());
$message->setPreferRoundRobin($this->settings->namedConsumerStrategy()->name() === SystemConsumerStrategies::RoundRobin);
$message->setPreferRoundRobin($this->settings->namedConsumerStrategy()->name() === SystemConsumerStrategies::ROUND_ROBIN);
$message->setCheckpointAfterTime($this->settings->checkPointAfterMilliseconds());
$message->setCheckpointMaxCount($this->settings->maxCheckPointCount());
$message->setCheckpointMinCount($this->settings->minCheckPointCount());
Expand Down
6 changes: 3 additions & 3 deletions src/Common/SystemConsumerStrategies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
class SystemConsumerStrategies
{
// Distributes events to a single client until it is full. Then round robin to the next client.
public const DispatchToSingle = 'DispatchToSingle';
public const DISPATCH_TO_SINGLE = 'DispatchToSingle';
// Distribute events to each client in a round robin fashion.
public const RoundRobin = 'RoundRobin';
public const ROUND_ROBIN = 'RoundRobin';
// Distribute events of the same streamId to the same client until it disconnects on a best efforts basis.
// Designed to be used with indexes such as the category projection.
public const Pinned = 'Pinned';
public const PINNED = 'Pinned';
}
10 changes: 5 additions & 5 deletions src/Common/SystemEventTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
class SystemEventTypes
{
// event type for stream deleted
public const StreamDeleted = '$streamDeleted';
public const STREAM_DELETED = '$streamDeleted';
// event type for statistics
public const StatsCollection = '$statsCollected';
public const STATS_COLLECTED = '$statsCollected';
// event type for linkTo
public const LinkTo = '$>';
public const LINK_TO = '$>';
// event type for stream metadata
public const StreamMetadata = '$metadata';
public const STREAM_METADATA = '$metadata';
// event type for the system settings
public const Settings = '$settings';
public const SETTINGS = '$settings';
}
24 changes: 12 additions & 12 deletions src/Common/SystemMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ class SystemMetadata
{
// The definition of the MaxAge value assigned to stream metadata
// Setting this allows all events older than the limit to be deleted
public const MaxAge = '$maxAge';
public const MAX_AGE = '$maxAge';
// The definition of the MaxCount value assigned to stream metadata
// setting this allows all events with a sequence less than current -maxcount to be deleted
public const MaxCount = '$maxCount';
public const MAX_COUNT = '$maxCount';
// The definition of the Truncate Before value assigned to stream metadata
// setting this allows all events prior to the integer value to be deleted
public const TruncateBefore = '$tb';
public const TRUNCATE_BEFORE = '$tb';
// Sets the cache control in seconds for the head of the stream.
public const CacheControl = '$cacheControl';
public const CACHE_CONTROL = '$cacheControl';
// The acl definition in metadata
public const Acl = '$acl';
public const ACL = '$acl';
// to read from a stream
public const AclRead = '$r';
public const ACL_READ = '$r';
// to write to a stream
public const AclWrite = '$w';
public const ACL_WRITE = '$w';
// to delete a stream
public const AclDelete = '$d';
public const ACL_DELETE = '$d';
// to read metadata
public const AclMetaRead = '$mr';
public const ACL_META_READ = '$mr';
// to write metadata
public const AclMetaWrite = '$mw';
public const ACL_META_WRITE = '$mw';
// The user default acl stream
public const UserStreamAcl = '$userStreamAcl';
public const USER_STREAM_ACL = '$userStreamAcl';
// the system stream defaults acl stream
public const SystemStreamAcl = '$systemStreamAcl';
public const SYSTEM_STREAM_ACL = '$systemStreamAcl';
}
6 changes: 3 additions & 3 deletions src/Common/SystemRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class SystemRoles
{
public const All = '$all';
public const Admins = '$admins';
public const Ops = '$ops';
public const ALL = '$all';
public const ADMINS = '$admins';
public const OPS = '$ops';
}
12 changes: 6 additions & 6 deletions src/Common/SystemStreams.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

class SystemStreams
{
public const PersistentSubscriptionConfig = '$persistentSubscriptionConfig';
public const AllStream = '$all';
public const StreamsStream = '$streams';
public const SettingsStream = '$settings';
public const StatsStreamPrefix = '$stats';
public const ScavengesStream = '$scavenges';
public const PERSISTENT_SUBSCRIPTION_CONFIG = '$persistentSubscriptionConfig';
public const ALL_STREAM = '$all';
public const STREAMS_STREAM = '$streams';
public const SETTINGS_STREAM = '$settings';
public const STATS_STREAM_PREFIX = '$stats';
public const SCAVANGE_STREAM = '$scavenges';

public static function metastreamOf(string $streamId): string
{
Expand Down
6 changes: 3 additions & 3 deletions src/ConditionalWriteStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class ConditionalWriteStatus
'StreamDeleted' => 2,
];

public const Succeeded = 0;
public const VersionMismatch = 1;
public const StreamDeleted = 2;
public const SUCCEEDED = 0;
public const VERSION_MISMATCH = 1;
public const STREAM_DELETED = 2;

private $name;
private $value;
Expand Down
20 changes: 10 additions & 10 deletions src/ConnectionSettingsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ class ConnectionSettingsBuilder
/** @var bool */
private $verboseLogging = false;
/** @var int */
private $maxQueueSize = Consts::DefaultMaxQueueSize;
private $maxQueueSize = Consts::DEFAULT_MAX_QUEUE_SIZE;
/** @var int */
private $maxConcurrentItems = Consts::DefaultMaxConcurrentItems;
private $maxConcurrentItems = Consts::DEFAULT_MAX_CONCURRENT_ITEMS;
/** @var int */
private $maxRetries = Consts::DefaultMaxOperationRetries;
private $maxRetries = Consts::DEFAULT_MAX_OPERATIONS_RETRY;
/** @var int */
private $maxReconnections = Consts::DefaultMaxReconnections;
private $maxReconnections = Consts::DEFAULT_MAX_RECONNECTIONS;
/** @var bool */
private $requireMaster = Consts::DefaultRequireMaster;
private $requireMaster = Consts::DEFAULT_REQUIRE_MASTER;
/** @var int */
private $reconnectionDelay = Consts::DefaultReconnectionDelay;
private $reconnectionDelay = Consts::DEFAULT_RECONNECTION_DELAY;
/** @var int */
private $operationTimeout = Consts::DefaultOperationTimeout;
private $operationTimeout = Consts::DEFAULT_OPERATION_TIMEOUT;
/** @var int */
private $operationTimeoutCheckPeriod = Consts::DefaultOperationTimeoutCheckPeriod;
private $operationTimeoutCheckPeriod = Consts::DEFAULT_OPERATION_TIMEOUT_CHECK_PERIOD;
/** @var UserCredentials|null */
private $defaultUserCredentials;
/** @var bool */
Expand All @@ -67,9 +67,9 @@ class ConnectionSettingsBuilder
/** @var string */
private $clusterDns = '';
/** @var int */
private $maxDiscoverAttempts = Consts::DefaultMaxClusterDiscoverAttempts;
private $maxDiscoverAttempts = Consts::DEFAULT_MAX_CLUSTER_DISCOVER_ATTEMPTS;
/** @var int */
private $gossipExternalHttpPort = Consts::DefaultClusterManagerExternalHttpPort;
private $gossipExternalHttpPort = Consts::DEFAULT_CLUSTER_MANAGER_EXTERNAL_HTTP_PORT;
/** @var int */
private $gossipTimeout = 1000;
/** @var GossipSeed[] */
Expand Down
4 changes: 2 additions & 2 deletions src/EventNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

class EventNumber
{
public const DeletedStream = \PHP_INT_MAX;
public const Invalid = -\PHP_INT_MAX - 1;
public const DELETED_STREAM = \PHP_INT_MAX;
public const INVALID = -\PHP_INT_MAX - 1;
}
8 changes: 4 additions & 4 deletions src/EventReadStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class EventReadStatus
'StreamDeleted' => 3,
];

public const Success = 0;
public const NotFound = 1;
public const NoStream = 2;
public const StreamDeleted = 3;
public const SUCCESS = 0;
public const NOT_FOUND = 1;
public const NO_STREAM = 2;
public const STREAM_DELETED = 3;

private $name;
private $value;
Expand Down
5 changes: 3 additions & 2 deletions src/EventStoreConnectionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Prooph\EventStoreClient\EventStoreSyncConnection as SyncConnection;
use Prooph\EventStoreClient\Exception\InvalidArgumentException;
use Prooph\EventStoreClient\Internal\ClusterDnsEndPointDiscoverer;
use Prooph\EventStoreClient\Internal\Consts;
use Prooph\EventStoreClient\Internal\EventStoreAsyncNodeConnection;
use Prooph\EventStoreClient\Internal\EventStoreSyncNodeConnection;
use Prooph\EventStoreClient\Internal\SingleEndpointDiscoverer;
Expand All @@ -35,6 +34,8 @@ class EventStoreConnectionBuilder
*/
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~\pL';

private const TCP_PORT_DEFAULT = 1113;

/** @throws \Exception */
public static function createAsyncFromBuilder(
string $connectionString = null,
Expand Down Expand Up @@ -222,7 +223,7 @@ private static function parseUri(string $connectionString): array

$scheme = isset($parts['scheme']) ? self::filterScheme($parts['scheme']) : '';
$host = isset($parts['host']) ? \strtolower($parts['host']) : '';
$port = isset($parts['port']) ? (int) $parts['port'] : Consts::TcpPortDefault;
$port = isset($parts['port']) ? (int) $parts['port'] : self::TCP_PORT_DEFAULT;
$user = isset($parts['user']) ? self::filterUserInfoPart($parts['user']) : '';
$pass = $parts['pass'] ?? '';

Expand Down
8 changes: 4 additions & 4 deletions src/ExpectedVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
class ExpectedVersion
{
// This write should not conflict with anything and should always succeed.
public const Any = -2;
public const ANY = -2;
// The stream being written to should not yet exist. If it does exist treat that as a concurrency problem.
public const NoStream = -1;
public const NO_STREAM = -1;
// The stream should exist and should be empty. If it does not exist or is not empty treat that as a concurrency problem.
public const EmptyStream = -1;
public const EMPTY_STREAM = -1;
// The stream should exist. If it or a metadata stream does not exist treat that as a concurrency problem.
public const StreamExists = -4;
public const STREAM_EXISTS = -4;
}

0 comments on commit 676f837

Please sign in to comment.