Giter VIP home page Giter VIP logo

event-store-http-client's People

Contributors

codeliner avatar enumag avatar prolic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

event-store-http-client's Issues

Another date time string bug

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.

Missing classes

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:

use Prooph\EventStore\Data\EventId;
use Prooph\EventStore\Data\EventRecord;
use Prooph\EventStore\Data\PersistentSubscriptionNakEventAction;
use Prooph\EventStore\Internal\PersistentSubscriptionOperations as BasePersistentSubscriptionOperations;

Client doesn't match event store interfaces?

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

ErrorException: Undefined variable: nextPosition when reading all events

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());

Could not create DateTimeImmutable from string while getting stream events

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

subscribeToStreamFrom() is not resolving linkTos?

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();

ResolvedEvent inconsistency

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
...

Undefined index: eventNumber

Encountered this error here.

Not sure what is correct here. I'm guessing it should be $json['positionEventNumber'] or $entry['eventNumber'], not sure which.

PHP 8 support, please?

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

Schema inconsistency

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.

Notice: Undefined index: lastCheckpoint

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.

Common value objects

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?

Fatal error in ProjectionDetails::__construct()

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

Examples are not up to date?

https://github.com/prooph/event-store-http-client/blob/master/examples/demo-subscribe-to-stream-from.php

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.

Suggestion: Improve ProjectionCommandFailed exception message

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

Bug in deletePersistentSubscription

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.