prooph / event-store-http-client Goto Github PK
View Code? Open in Web Editor NEWPHP 7.2 Event Store HTTP Client Implementation
License: BSD 3-Clause "New" or "Revised" License
PHP 7.2 Event Store HTTP Client Implementation
License: BSD 3-Clause "New" or "Revised" License
Today I encountered an error Notice: Undefined index: lastCheckpoint
on this line. It started right after I added a reorderEvents
option to my projection (see docs). When I dumped $entry
it contains this:
array (
'coreProcessingTime' => 0,
'version' => -1,
'epoch' => -1,
'effectiveName' => 'everything',
'writesInProgress' => 0,
'readsInProgress' => 0,
'partitionsCached' => 0,
'status' => 'Faulted',
'stateReason' => 'Event reordering requires processing lag at least of 50ms',
'name' => 'everything',
'mode' => 'Continuous',
'position' => '',
'progress' => 0.0,
'eventsProcessedAfterRestart' => 0,
'statusUrl' => 'http://eventstore-ci:2113/projection/everything',
'stateUrl' => 'http://eventstore-ci:2113/projection/everything/state',
'resultUrl' => 'http://eventstore-ci:2113/projection/everything/result',
'queryUrl' => 'http://eventstore-ci:2113/projection/everything/query%3Fconfig=yes',
'enableCommandUrl' => 'http://eventstore-ci:2113/projection/everything/command/enable',
'disableCommandUrl' => 'http://eventstore-ci:2113/projection/everything/command/disable',
'bufferedEvents' => 0,
'writePendingEventsBeforeCheckpoint' => 0,
'writePendingEventsAfterCheckpoint' => 0,
)
Notably aside from lastCheckpoint
key the checkpointStatus
key is missing as well.
Obviously there is an error, see status
and stateReason
but it should not crash like this with undefined index in my opinion. An exception would be better.
The HTTP client doesn't match recent changes to the event store library?
Fatal error: Could not check compatibility between Prooph\EventStoreHttpClient\Internal\EventStoreHttpConnection::subscribeToStream(string $stream, bool $resolveLinkTos, Prooph\EventStore\EventAppearedOnSubscription $eventAppeared, ?Prooph\EventStore\SubscriptionDropped $subscriptionDropped = NULL, ?Prooph\EventStore\UserCredentials $userCredentials = NULL): Prooph\EventStore\EventStoreSubscription and Prooph\EventStore\EventStoreConnection::subscribeToStream(string $stream, bool $resolveLinkTos, Closure $eventAppeared, ?Closure $subscriptionDropped = NULL, ?Prooph\EventStore\UserCredentials $userCredentials = NULL): Prooph\EventStore\EventStoreSubscription, because class Prooph\EventStore\SubscriptionDropped is not available in \event-sourcing-test-app\vendor\prooph\event-store-http-client\src\Internal\EventStoreHttpConnection.php on line 1090
There are some undefined classes from Prooph\EventStore\
namespace used in the code but they are not present in this package nor included as a composer dependency.
Example:
PHP Fatal error: Uncaught Error: Class 'Prooph\EventStoreHttpClient\Internal\RuntimeException' not found in \src\Internal\EventStoreAllCatchUpSubscription.php:106
It's missing the use statement or the \ in front of the exception class in line 106.
prooph/event-store-http-client dev-master requires php ^7.4 -> your php version (8.0.6) does not satisfy that requirement.
The same problem is also present in the regular (non HTTP) client:
prooph/event-store-client
Hi,
I found the problem with $by_correlation_id in ES version 5, when using this library to append events through HTTP API (https://groups.google.com/forum/#!topic/event-store/1_e1yZfeWP0). The library sends json with escaped quotes in data and metadata, so the projection is not working.
Is it problem of the library or EventStore?
Thanks,
Jakub Koci
Edit: see also EventStore/EventStore#1875
The dependency php-http/discovery
is only used in factories. We should use it as Composer suggestion instead of a dependency.
Would it be possible to either change this message and add a sentence like "Make sure your event store has projections enabled." Or even better throw a "ProjectionsNotEnabled" exception?
Uncaught Prooph\EventStoreHttpClient\Exception\ProjectionCommandFailed: Server returned 404 (Not Found) for GET on /projection/TEST_PROJECTION/result in src\Projections\ProjectionsManager.php:541
I'm getting this error message:
PHP Notice: Undefined variable: nextPosition in \vendor\prooph\event-store-http-client\src\Internal\EventStoreHttpConnection.php on line 632
PHP Stack trace:
Using this code, it's a slightly altered version of one of the examples from this repository:
https://gist.github.com/burzum/da5787dde0a1ddcc45c9f03412babb5f
I'm using dev-master
and commit id is a658025
I'm not sure how to fix this... when using deletePersistentSubscription
I got an exception Unknown enum name given
thrown here.
It was called from here but the value of $json['result']
is 'DoesNotExist'
instead of the two expected values.
I'd send a PR but I'm not exactly sure what to do.
TypeError:
Argument 9 passed to Prooph\EventStore\Projections\ProjectionDetails::__construct()
must be of the type string, null given, called in
/usr/app/vendor/prooph/event-store-http-client/src/Projections/ProjectionsManager.php
on line 522
Encountered this error here.
Not sure what is correct here. I'm guessing it should be $json['positionEventNumber']
or $entry['eventNumber']
, not sure which.
ConnectionSettings
used by EventStoreHttpConnection
has $useSslConnection
parameter which is resolved to http or https here.
ProjectionsManagerFactory
on the other hand is using EndpointExtensions
constants.
I expect you'll want to unify this somehow.
For now I'll have to use both the HTTP client (for reading and appending to streams) and the TCP client (for connectToPersistentSubscription). So I need to be able to transform the RecordedEvent
intances to real domain events in both modes.
It's easy to do of course, just slightly annoying since RecordedEvent
is implemented in each client separately. There are quite a few other objects that appear in both of the libraries - it might make sense to share these between both libraries.
What do you think?
Uncaught Error: Interface 'Prooph\EventStore\EventAppearedOnCatchupSubscription' not found
When I fix these, I'm getting a lot of these
Fatal error: Uncaught Error: Typed property Prooph\EventStoreHttpClient\Internal\EventStoreCatchUpSubscription::$subscription
which are easy to fix. I've got stuck at this point:
Fatal error: Uncaught Error: Interface 'Prooph\EventStore\EventAppearedOnSubscription' not found in \vendor\prooph\event-store-http-client\src\Internal\EventStoreCatchUpSubscription.php:167
I'm not sure what I need to change here to make it work again.
When I'm trying to get events from stream, I'm getting the error Could not create DateTimeImmutable from string "2020-12-13T23:00:57.1574786Z".
where 2020-12-13T23:00:57.1574786Z
is the string representation of date in updated
field
Here is a sample snippet code :
$connection = EventStoreConnectionFactory::create(
new ConnectionSettings(
new EndPoint('localhost', 2113),
'http',
),
$this->httpClient,
null
);
$connection->appendToStream(
'newstream',
ExpectedVersion::ANY,
[
new EventData(
EventId::generate(),
'test-type',
true,
json_encode(['a' => '2']),
'meta'
)
]
));
return $connection->readStreamEventsForward('newstream',0, 100));
and it's failing in Prooph\EventStoreHttpClient\Internal\ResolvedEventParser
line 87, when creating RecordedEvent
object.
I'm new to this package and to eventstore DB in general, so sorry if a question is stupid and issue is on my side, but I do not see how it can be on my side, as I do not rpovide any datetes while saving event, so I'm assuming issues is on package or eventstore configuration
use Prooph\EventStore\EndPoint;
use Prooph\EventStore\UserCredentials;
use Prooph\EventStoreHttpClient\ConnectionSettings;
use Prooph\EventStore\UserCredentials;
use Prooph\EventStoreHttpClient\EventStoreConnectionFactory;
use Prooph\EventStore\Position;
$creds = new UserCredentials('admin', 'changeit');
$settings = new ConnectionSettings(
new EndPoint('localhost', '2113'),
'http',
$creds
);
$connection = EventStoreConnectionFactory::create($settings);
$from = Position::start();
do {
$slice = $connection->readAllEventsForward($from, 4096);
foreach ($slice->events() as $event) {
$event = $event->event();
var_dump("/streams/{$event->eventStreamId()}/{$event->eventNumber()}");
}
$from = $slice->nextPosition();
}
while (!$slice->isEndOfStream());
I'm using the built in by $by_category projection of the event store.
The events in this stream look like this:
{
"$v": "2:-1:1:3",
"$c": 303378,
"$p": 303378,
"$causedBy": "296c90a3-3ddd-e248-8c97-b2c8fa515edf"
}
I'm trying to use a catchup subscription with this stream. I assume that the resolveLinkTos argument should somehow resolve the above to the original link? If this is correct then it doesn't work. I'm just getting the above link back.
The client version is the master branch at c996ad3.
/**
* @var $eventStore \Prooph\EventStore\EventStoreConnection
*/
$eventStore = ConnectionManager::get('eventStore');
$stream = '$category-Account';
$settings = new \Prooph\EventStore\CatchUpSubscriptionSettings(
50,
50,
false,
true // resolveLinkTos
);
$subscription = $eventStore->subscribeToStreamFrom(
$stream,
null,
$settings,
new \App\Infrastructure\Projection\AccountProjection(
true
)
);
echo 'Processing stream ' . $stream . PHP_EOL;
$subscription->start();
Here is the exception with relevant part of the stack trace.
In DateTime.php line 36:
[InvalidArgumentException]
Could not create DateTimeImmutable from string "2020-01-23T15:04:13Z".
Exception trace:
at .../vendor/prooph/event-store/src/Util/DateTime.php:36
Prooph\EventStore\Util\DateTime::create() at .../vendor/prooph/event-store-http-client/src/Internal/ResolvedEventParser.php:87
Prooph\EventStoreHttpClient\Internal\ResolvedEventParser::parse() at .../vendor/prooph/event-store-http-client/src/Internal/EventStoreHttpConnection.php:428
Prooph\EventStoreHttpClient\Internal\EventStoreHttpConnection->readStreamEventsForwardPolling() at .../vendor/prooph/event-store-http-client/src/Internal/EventStoreHttpConnection.php:337
Prooph\EventStoreHttpClient\Internal\EventStoreHttpConnection->readStreamEventsForward() at ...
I don't have DateTimeStringBugWorkaround
in my project since it's not released. Howerver I tried if this particular string would work with that workaround and it would not.
Original string: 2020-01-23T15:04:13Z
After workaround: 2020-01-23T15:04:13Z000000Z
Which is still invalid.
I insert data into EventStore and then read the same data by two different ways. There is still something wrong in the link/event distinction. The results should be the same but in fact link/event is swapped in one of them.
I'm not sure which is correct. Anyway there is a bug in one of the prooph repos somewhere. I can dig further but I need a confirmation what is correct first.
Code A: (using HTTP client)
$slice = $this->connection->readStreamEventsForward(
'everything',
0,
200,
true,
$credentials
);
foreach ($slice->events() as $resolvedEvent) {
$link = $resolvedEvent->link();
assert($link);
$event = $resolvedEvent->event();
assert($event);
$output->writeln('link: ' . sprintf('%s@%s', $link->eventNumber(), $link->eventStreamId()));
$output->writeln('event: ' . sprintf('%s@%s', $event->eventNumber(), $event->eventStreamId()));
}
Code A result:
link: 0@CodeListsManagement.ZipCode-7ad864ae-88bc-d948-87ce-973e0fbb8a73
event: 0@everything
link: 0@CodeListsManagement.ZipCode-19b8f7cb-5146-144c-aa01-cac23e670a4d
event: 1@everything
link: 0@CodeListsManagement.UnitAttribute-963a08a3-4640-5e47-9fe2-fb2143b338d6
event: 2@everything
link: 0@CodeListsManagement.UnitAttribute-f4c82854-49e6-4b46-ba89-263867c5f1ea
event: 3@everything
link: 0@CodeListsManagement.UnitAttributeSet-d7c15e02-5caf-4dd5-bac3-b3746cb2c954
event: 4@everything
link: 1@CodeListsManagement.UnitAttributeSet-d7c15e02-5caf-4dd5-bac3-b3746cb2c954
event: 5@everything
link: 0@CodeListsManagement.FeeName-27858a0b-ab34-ea4e-9f10-04336e9c6ce2
event: 6@everything
link: 0@CodeListsManagement.FeeName-5c31c488-8f47-1a4a-a468-8992771ed332
event: 7@everything
...
Code B: (part of my persistent subscription testing, using TCP client)
private function createEventAppearedHandler(OutputInterface $output): EventAppearedOnPersistentSubscription
{
$callback = function (
EventStorePersistentSubscription $subscription,
ResolvedEvent $resolvedEvent,
?int $retryCount = null
) use ($output): Promise {
$link = $resolvedEvent->link();
assert($link);
$event = $resolvedEvent->event();
assert($event);
$output->writeln('link: ' . sprintf('%s@%s', $link->eventNumber(), $link->eventStreamId()));
$output->writeln('event: ' . sprintf('%s@%s', $event->eventNumber(), $event->eventStreamId()));
return new Success();
};
}
Code B result:
link: 0@everything
event: 0@CodeListsManagement.ZipCode-7ad864ae-88bc-d948-87ce-973e0fbb8a73
link: 1@everything
event: 0@CodeListsManagement.ZipCode-19b8f7cb-5146-144c-aa01-cac23e670a4d
link: 2@everything
event: 0@CodeListsManagement.UnitAttribute-963a08a3-4640-5e47-9fe2-fb2143b338d6
link: 3@everything
event: 0@CodeListsManagement.UnitAttribute-f4c82854-49e6-4b46-ba89-263867c5f1ea
link: 4@everything
event: 0@CodeListsManagement.UnitAttributeSet-d7c15e02-5caf-4dd5-bac3-b3746cb2c954
link: 5@everything
event: 1@CodeListsManagement.UnitAttributeSet-d7c15e02-5caf-4dd5-bac3-b3746cb2c954
link: 6@everything
event: 0@CodeListsManagement.FeeName-27858a0b-ab34-ea4e-9f10-04336e9c6ce2
link: 7@everything
event: 0@CodeListsManagement.FeeName-5c31c488-8f47-1a4a-a468-8992771ed332
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.