Skip to content

Commit

Permalink
v4.0.0
Browse files Browse the repository at this point in the history
__BREAKING CHANGES__

* Require php 8.1 and allow symfony 5.x|6.x.
* Require gdbots/schemas and gdbots/query-parser 3.x
  • Loading branch information
gdbrown authored Dec 10, 2021
1 parent fe1837f commit 4686948
Show file tree
Hide file tree
Showing 42 changed files with 177 additions and 156 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG-4.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CHANGELOG for 4.x
This changelog references the relevant changes done in 4.x versions.


## v4.0.0
__BREAKING CHANGES__

* Require php 8.1 and allow symfony 5.x|6.x.
* Require gdbots/schemas and gdbots/query-parser 3.x
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
"type": "library",
"license": "Apache-2.0",
"require": {
"php": ">=7.4",
"php": ">=8.1",
"ext-json": "*",
"gdbots/query-parser": "^2.0",
"gdbots/schemas": "^2.0",
"psr/log": "^1",
"symfony/event-dispatcher": "^5.1"
"gdbots/query-parser": "^3.0",
"gdbots/schemas": "^3.0",
"psr/log": "^1|^2|^3",
"symfony/event-dispatcher": "^5.4|^6.0"
},
"require-dev": {
"phpunit/phpunit": "^9.2",
"phpunit/phpunit": "^9.5",
"aws/aws-sdk-php": "^3.138",
"gdbots/acme-schemas": "^2.0",
"ruflin/elastica": "^7.0"
"gdbots/acme-schemas": "^3.0",
"ruflin/elastica": "^7.1"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 3 additions & 3 deletions src/AbstractServiceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ final public function getEventStore(): EventStore

protected function doGetEventStore(): EventStore
{
throw new LogicException('No EventStore has been configured.', Code::UNIMPLEMENTED);
throw new LogicException('No EventStore has been configured.', Code::UNIMPLEMENTED->value);
}

final public function getEventSearch(): EventSearch
Expand All @@ -136,7 +136,7 @@ final public function getEventSearch(): EventSearch

protected function doGetEventSearch(): EventSearch
{
throw new LogicException('No EventSearch has been configured.', Code::UNIMPLEMENTED);
throw new LogicException('No EventSearch has been configured.', Code::UNIMPLEMENTED->value);
}

final public function getScheduler(): Scheduler
Expand All @@ -150,7 +150,7 @@ final public function getScheduler(): Scheduler

protected function doGetScheduler(): Scheduler
{
throw new LogicException('No Scheduler has been configured.', Code::UNIMPLEMENTED);
throw new LogicException('No Scheduler has been configured.', Code::UNIMPLEMENTED->value);
}

final protected function getDefaultTransport(): Transport
Expand Down
2 changes: 1 addition & 1 deletion src/Consumer/AbstractConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private function handleRequest(Message $request): Message
return $this->locator->getRequestBus()->receiveRequest($request);
}

final public function handleSignals(int $signo, $signinfo = null): void
final public function handleSignals(int $signo, mixed $signinfo = null): void
{
switch ($signo) {
case SIGINT:
Expand Down
2 changes: 1 addition & 1 deletion src/Event/EnrichContextEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function has(string $name): bool
return isset($this->context[$name]);
}

public function get(string $name, $default = null)
public function get(string $name, mixed $default = null): mixed
{
return $this->context[$name] ?? $default;
}
Expand Down
4 changes: 2 additions & 2 deletions src/EventSearch/Elastica/AwsAuthV4.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Aws\Signature\SignatureV4;
use Elastica\Connection;
use Elastica\Transport\Guzzle;
use GuzzleHttp;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\Utils;
use Psr\Http\Message\RequestInterface;

/**
Expand All @@ -32,7 +32,7 @@ class AwsAuthV4 extends Guzzle
protected function _getGuzzleClient(bool $persistent = true): Client
{
if (!$persistent || !self::$_guzzleClientConnection) {
$stack = HandlerStack::create(GuzzleHttp\choose_handler());
$stack = HandlerStack::create(Utils::chooseHandler());
$stack->push($this->getConnectTimeoutMiddleware(), 'connect_timeout');
$stack->push($this->getSigningMiddleware(), 'sign');

Expand Down
8 changes: 4 additions & 4 deletions src/EventSearch/Elastica/ElasticaEventSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ final public function createStorage(array $context = []): void
ClassUtil::getShortName($e),
$indexName
),
Code::INTERNAL,
Code::INTERNAL->value,
$e
);
}
Expand Down Expand Up @@ -207,7 +207,7 @@ final public function indexEvents(array $events, array $context = []): void
ClassUtil::getShortName($e),
$e->getMessage()
),
Code::INTERNAL,
Code::INTERNAL->value,
$e
);
}
Expand Down Expand Up @@ -265,7 +265,7 @@ final public function deleteEvents(array $eventIds, array $context = []): void
ClassUtil::getShortName($e),
$e->getMessage()
),
Code::INTERNAL,
Code::INTERNAL->value,
$e
);
}
Expand Down Expand Up @@ -310,7 +310,7 @@ final public function searchEvents(Message $request, ParsedQuery $parsedQuery, M
$request->get('q'),
ClassUtil::getShortName($e) . '::' . $e->getMessage()
),
Code::INTERNAL,
Code::INTERNAL->value,
$e
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/EventSearch/Elastica/IndexManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ final public function updateIndex(Client $client, string $name): void
'allow_no_indices' => true,
]);
} catch (\Throwable $e) {
if (false !== strpos($e->getMessage(), 'no such index')) {
if (str_contains($e->getMessage(), 'no such index')) {
$this->logger->info(sprintf('No index exists yet [%s] in ElasticSearch. Ignoring.', $name));
return;
}

throw new EventSearchOperationFailed(
sprintf('Failed to put mapping for index [%s] into ElasticSearch.', $name),
Code::INTERNAL,
Code::INTERNAL->value,
$e
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/EventSearch/Elastica/QueryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ final public function create(Message $request, ParsedQuery $parsedQuery, array $

protected function applyDateFilters(Message $request, ParsedQuery $parsedQuery): void
{
$required = BoolOperator::REQUIRED();
$required = BoolOperator::REQUIRED;

$dateFilters = [
[
'query' => 'occurred_after',
'field' => 'occurred_at',
'operator' => ComparisonOperator::GT(),
'operator' => ComparisonOperator::GT,
],
[
'query' => 'occurred_before',
'field' => 'occurred_at',
'operator' => ComparisonOperator::LT(),
'operator' => ComparisonOperator::LT,
],
];

Expand Down Expand Up @@ -105,7 +105,7 @@ protected function filterCuries(Message $request, Query\BoolQuery $query, array
*/
protected function createSortedQuery(AbstractQuery $query, Message $request): Query
{
switch ($request->get('sort')->getValue()) {
switch ($request->get('sort')) {
case SearchEventsSort::DATE_DESC:
$query = Query::create($query);
$query->setSort(['occurred_at' => 'desc']);
Expand Down
2 changes: 1 addition & 1 deletion src/EventSearch/EventIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class EventIndexer implements EventSubscriber
{
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
'gdbots:pbjx:mixin:indexed' => 'onIndexed',
Expand Down
36 changes: 17 additions & 19 deletions src/EventStore/DynamoDb/DynamoDbEventStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ final public function getEvent(Identifier $eventId, array $context = []): Messag
if ('ResourceNotFoundException' === $errorName) {
throw new EventNotFound();
} elseif ('ProvisionedThroughputExceededException' === $errorName) {
$code = Code::RESOURCE_EXHAUSTED;
$code = Code::RESOURCE_EXHAUSTED->value;
} else {
$code = Code::UNAVAILABLE;
$code = Code::UNAVAILABLE->value;
}
} else {
$errorName = ClassUtil::getShortName($e);
$code = Code::INTERNAL;
$code = Code::INTERNAL->value;
}

throw new EventStoreOperationFailed(
Expand Down Expand Up @@ -147,8 +147,6 @@ final public function getEvents(array $eventIds, array $context = []): array
$events[(string)$event->get('event_id')] = $event;
} catch (EventNotFound $nf) {
// missing events are not exception worthy at this time
} catch (\Throwable $e) {
throw $e;
}
}

Expand All @@ -173,13 +171,13 @@ final public function deleteEvent(Identifier $eventId, array $context = []): voi
// if it's already deleted, it's fine
return;
} elseif ('ProvisionedThroughputExceededException' === $errorName) {
$code = Code::RESOURCE_EXHAUSTED;
$code = Code::RESOURCE_EXHAUSTED->value;
} else {
$code = Code::UNAVAILABLE;
$code = Code::UNAVAILABLE->value;
}
} else {
$errorName = ClassUtil::getShortName($e);
$code = Code::INTERNAL;
$code = Code::INTERNAL->value;
}

throw new EventStoreOperationFailed(
Expand Down Expand Up @@ -258,13 +256,13 @@ final public function getStreamSlice(StreamId $streamId, ?Microtime $since = nul
if ($e instanceof AwsException) {
$errorName = $e->getAwsErrorCode() ?: ClassUtil::getShortName($e);
if ('ProvisionedThroughputExceededException' === $errorName) {
$code = Code::RESOURCE_EXHAUSTED;
$code = Code::RESOURCE_EXHAUSTED->value;
} else {
$code = Code::UNAVAILABLE;
$code = Code::UNAVAILABLE->value;
}
} else {
$errorName = ClassUtil::getShortName($e);
$code = Code::INTERNAL;
$code = Code::INTERNAL->value;
}

throw new EventStoreOperationFailed(
Expand Down Expand Up @@ -350,13 +348,13 @@ final public function putEvents(StreamId $streamId, array $events, ?string $expe
if ($e instanceof AwsException) {
$errorName = $e->getAwsErrorCode() ?: ClassUtil::getShortName($e);
if ('ProvisionedThroughputExceededException' === $errorName) {
$code = Code::RESOURCE_EXHAUSTED;
$code = Code::RESOURCE_EXHAUSTED->value;
} else {
$code = Code::DATA_LOSS;
$code = Code::DATA_LOSS->value;
}
} else {
$errorName = ClassUtil::getShortName($e);
$code = Code::INTERNAL;
$code = Code::INTERNAL->value;
}

throw new EventStoreOperationFailed(
Expand Down Expand Up @@ -538,9 +536,9 @@ protected function doPipeAllEvents(?Microtime $since = null, ?Microtime $until =

$errorName = $exception->getAwsErrorCode() ?: ClassUtil::getShortName($exception);
if ('ProvisionedThroughputExceededException' === $errorName) {
$code = Code::RESOURCE_EXHAUSTED;
$code = Code::RESOURCE_EXHAUSTED->value;
} else {
$code = Code::UNAVAILABLE;
$code = Code::UNAVAILABLE->value;
}

if ($skipErrors) {
Expand Down Expand Up @@ -709,13 +707,13 @@ protected function getItemKeyByEventId(Identifier $eventId, array $context = [])
if ($e instanceof AwsException) {
$errorName = $e->getAwsErrorCode() ?: ClassUtil::getShortName($e);
if ('ProvisionedThroughputExceededException' === $errorName) {
$code = Code::RESOURCE_EXHAUSTED;
$code = Code::RESOURCE_EXHAUSTED->value;
} else {
$code = Code::UNAVAILABLE;
$code = Code::UNAVAILABLE->value;
}
} else {
$errorName = ClassUtil::getShortName($e);
$code = Code::INTERNAL;
$code = Code::INTERNAL->value;
}

throw new EventStoreOperationFailed(
Expand Down
4 changes: 2 additions & 2 deletions src/EventStore/DynamoDb/EventStoreTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function create(DynamoDbClient $client, string $tableName): void
$tableName,
$client->getRegion()
),
Code::INTERNAL,
Code::INTERNAL->value,
$e
);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ public function describe(DynamoDbClient $client, string $tableName): string
$tableName,
$client->getRegion()
),
Code::INTERNAL,
Code::INTERNAL->value,
$e
);
}
Expand Down
34 changes: 17 additions & 17 deletions src/EventStore/EventStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public function deleteEvent(Identifier $eventId, array $context = []): void;
*
* A StreamSlice will always be returned, even when empty or when the stream doesn't exist.
*
* @param StreamId $streamId The id of the stream to read from, e.g. "acme:article:1234"
* @param Microtime $since Return events since this time (exclusive greater than if forward=true, less than if forward=false)
* @param int $count The number of events to return.
* @param bool $forward When true, the events are read from oldest to newest, otherwise newest to oldest.
* @param bool $consistent An eventually consistent read is used by default unless this is true.
* @param array $context Data that helps the EventStore decide where to read/write data from.
* @param StreamId $streamId The id of the stream to read from, e.g. "acme:article:1234"
* @param Microtime|null $since Return events since this time (exclusive greater than if forward=true, less than if forward=false)
* @param int $count The number of events to return.
* @param bool $forward When true, the events are read from oldest to newest, otherwise newest to oldest.
* @param bool $consistent An eventually consistent read is used by default unless this is true.
* @param array $context Data that helps the EventStore decide where to read/write data from.
*
* @return StreamSlice
*
Expand All @@ -89,10 +89,10 @@ public function getStreamSlice(StreamId $streamId, ?Microtime $since = null, int
/**
* Appends an array of events to a stream.
*
* @param StreamId $streamId The id of the stream to append to, e.g. "acme:article:1234"
* @param Message[] $events An array of events to append to the stream.
* @param string $expectedEtag Used to perform optimistic concurrency check.
* @param array $context Data that helps the EventStore decide where to read/write data from.
* @param StreamId $streamId The id of the stream to append to, e.g. "acme:article:1234"
* @param Message[] $events An array of events to append to the stream.
* @param string|null $expectedEtag Used to perform optimistic concurrency check.
* @param array $context Data that helps the EventStore decide where to read/write data from.
*
* @throws OptimisticCheckFailed
* @throws GdbotsPbjxException
Expand All @@ -102,10 +102,10 @@ public function putEvents(StreamId $streamId, array $events, ?string $expectedEt
/**
* Reads events (forward only) from a stream.
*
* @param StreamId $streamId The id of the stream to read from, e.g. "acme:article:1234"
* @param Microtime $since Return events greater than this time (exclusive).
* @param Microtime $until Return events less than this time (exclusive).
* @param array $context Data that helps the EventStore decide where to read/write data from.
* @param StreamId $streamId The id of the stream to read from, e.g. "acme:article:1234"
* @param Microtime|null $since Return events greater than this time (exclusive).
* @param Microtime|null $until Return events less than this time (exclusive).
* @param array $context Data that helps the EventStore decide where to read/write data from.
*
* @return \Generator
*
Expand All @@ -120,9 +120,9 @@ public function pipeEvents(StreamId $streamId, ?Microtime $since = null, ?Microt
* IMPORTANT! The order of events returned will be ordered per stream
* but not necessarily globally ordered.
*
* @param Microtime $since Return events greater than this time (exclusive).
* @param Microtime $until Return events less than this time (exclusive).
* @param array $context Data that helps the EventStore decide where to read/write data from.
* @param Microtime|null $since Return events greater than this time (exclusive).
* @param Microtime|null $until Return events less than this time (exclusive).
* @param array $context Data that helps the EventStore decide where to read/write data from.
*
* @return \Generator
*
Expand Down
Loading

0 comments on commit 4686948

Please sign in to comment.