Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Standalone usage #278

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Classes/Command/ProjectionCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use Neos\EventSourcing\EventListener\Exception\EventCouldNotBeAppliedException;
use Neos\EventSourcing\Projection\Projection;
use Neos\EventSourcing\Projection\ProjectionManager;
use Neos\EventSourcing\Projection\ProjectionManagerInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Neos\Flow\Cli\Exception\StopCommandException;
Expand All @@ -28,7 +28,7 @@ class ProjectionCommandController extends CommandController
{
/**
* @Flow\Inject
* @var ProjectionManager
* @var ProjectionManagerInterface
*/
protected $projectionManager;

Expand Down
22 changes: 22 additions & 0 deletions Classes/Event/Resolver/FullyQualifiedClassNameResolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php


namespace Neos\EventSourcing\Event\Resolver;


use Neos\EventSourcing\Event\DomainEventInterface;
use Neos\EventSourcing\Event\EventTypeResolverInterface;

class FullyQualifiedClassNameResolver implements EventTypeResolverInterface
{

public function getEventType(DomainEventInterface $event): string
{
return get_class($event);
}

public function getEventClassNameByType(string $eventType): string
{
return $eventType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

/**
* Doctrine DBAL adapter for the AppliedEventsStorageInterface
*
* TODO: we should have one doctrine applied events storage table PER BOUNDED CONTEXT, i.e. per storage.
*/
final class DoctrineAppliedEventsStorage implements AppliedEventsStorageInterface
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/Projection/ProjectionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @api
* @Flow\Scope("singleton")
*/
class ProjectionManager
class ProjectionManager implements ProjectionManagerInterface
{
/**
* @var ObjectManagerInterface
Expand Down
85 changes: 85 additions & 0 deletions Classes/Projection/ProjectionManagerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
namespace Neos\EventSourcing\Projection;

/*
* This file is part of the Neos.EventSourcing package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

use Closure;
use Doctrine\ORM\EntityManagerInterface;
use Neos\EventSourcing\EventListener\EventListenerInvoker;
use Neos\EventSourcing\EventListener\Exception\EventCouldNotBeAppliedException;
use Neos\EventSourcing\EventListener\Mapping\DefaultEventToListenerMappingProvider;
use Neos\EventSourcing\EventStore\EventStoreFactory;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
use Neos\Flow\Reflection\ClassReflection;
use Neos\Flow\Reflection\Exception\ClassLoadingForReflectionFailedException;
use Neos\Flow\Reflection\ReflectionService;

interface ProjectionManagerInterface
{
/**
* Return all detected projections
*
* @return Projection[]
* @api
*/
public function getProjections(): array;

/**
* Returns information about a specific projection in form of a Projection DTO
*
* @param string $projectionIdentifier The short or full projection identifier
* @return Projection
* @api
*/
public function getProjection(string $projectionIdentifier): Projection;

/**
* Replay events of the specified projection
*
* @param string $projectionIdentifier unambiguous identifier of the projection to replay
* @param Closure|null $progressCallback If set, this callback is invoked for every applied event during replay with the arguments $sequenceNumber and $eventStreamVersion
* @return void
* @throws EventCouldNotBeAppliedException
* @api
*/
public function replay(string $projectionIdentifier, Closure $progressCallback = null): void;

/**
* Replay events of the specified projection until the specified event sequence number
*
* @param string $projectionIdentifier unambiguous identifier of the projection to replay
* @param int $maximumSequenceNumber The sequence number of the event until which events should be replayed. The specified event will be included in the replay.
* @param Closure|null $progressCallback If set, this callback is invoked for every applied event during replay with the arguments $sequenceNumber and $eventStreamVersion
* @throws EventCouldNotBeAppliedException
*/
public function replayUntilSequenceNumber(string $projectionIdentifier, int $maximumSequenceNumber, Closure $progressCallback = null): void;

/**
* Catch up on events for the specified projection
*
* @param string $projectionIdentifier unambiguous identifier of the projection to catch up for
* @param Closure|null $progressCallback If set, this callback is invoked for every applied event during catch-up with the arguments $sequenceNumber and $eventStreamVersion
* @throws EventCouldNotBeAppliedException
*/
public function catchUp(string $projectionIdentifier, Closure $progressCallback = null): void;

/**
* Catch up on events for the specified projection up to the specified event
*
* @param string $projectionIdentifier unambiguous identifier of the projection to catch up for
* @param int $maximumSequenceNumber The sequence number of the event until which events should be applied. The specified event will be included in the replay.
* @param Closure|null $progressCallback If set, this callback is invoked for every applied event during catch-up with the arguments $sequenceNumber and $eventStreamVersion
* @throws EventCouldNotBeAppliedException
*/
public function catchUpUntilSequenceNumber(string $projectionIdentifier, int $maximumSequenceNumber, Closure $progressCallback = null): void;
}
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
"license": "MIT",
"require": {
"php": ">=7.2",
"neos/flow": "^5.3 || ^6.0",
"flowpack/jobqueue-common": "^3.0 || dev-master",
"symfony/serializer": "^5.1",
"symfony/property-access": "^5.1",
"neos/error-messages": "*",
"neos/utility-objecthandling": "*",
"ramsey/uuid": "^3.9"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"dg/bypass-finals": "^1.2"
},
"suggest": {
"flowpack/jobqueue-common": "Needed for Neos/Flow usage only"
},
"autoload": {
"psr-4": {
"Neos\\EventSourcing\\": "Classes"
Expand Down