diff --git a/baseline.xml b/baseline.xml
index 53f5d4abc..c5358ae73 100644
--- a/baseline.xml
+++ b/baseline.xml
@@ -113,6 +113,11 @@
+
+
+
+
+
@@ -126,6 +131,10 @@
+
+
+
+
@@ -135,6 +144,12 @@
+
+
+
+ ]]>
+
+
@@ -354,4 +369,12 @@
+
+
+
+
+
+
+
+
diff --git a/src/Debug/Trace/Trace.php b/src/Debug/Trace/Trace.php
deleted file mode 100644
index b142225f4..000000000
--- a/src/Debug/Trace/Trace.php
+++ /dev/null
@@ -1,15 +0,0 @@
-traceStack->get();
-
- if ($traces === []) {
- return $message;
- }
-
- return $message->withHeader(new TraceHeader(
- array_map(
- static fn (Trace $trace) => [
- 'name' => $trace->name,
- 'category' => $trace->category,
- ],
- $traces,
- ),
- ));
- }
-}
diff --git a/src/Debug/Trace/TraceHeader.php b/src/Debug/Trace/TraceHeader.php
deleted file mode 100644
index c0406f1de..000000000
--- a/src/Debug/Trace/TraceHeader.php
+++ /dev/null
@@ -1,15 +0,0 @@
- $traces */
- public function __construct(
- public readonly array $traces,
- ) {
- }
-}
diff --git a/src/Debug/Trace/TraceStack.php b/src/Debug/Trace/TraceStack.php
deleted file mode 100644
index f1135d68a..000000000
--- a/src/Debug/Trace/TraceStack.php
+++ /dev/null
@@ -1,35 +0,0 @@
- */
- private array $traces = [];
-
- public function add(Trace $trace): void
- {
- $this->traces[self::key($trace)] = $trace;
- }
-
- /** @return list */
- public function get(): array
- {
- return array_values($this->traces);
- }
-
- public function remove(Trace $trace): void
- {
- unset($this->traces[self::key($trace)]);
- }
-
- private static function key(Trace $trace): string
- {
- return $trace->category . '#' . $trace->name;
- }
-}
diff --git a/src/Debug/Trace/TraceableSubscriberAccessor.php b/src/Debug/Trace/TraceableSubscriberAccessor.php
deleted file mode 100644
index 1dfe42399..000000000
--- a/src/Debug/Trace/TraceableSubscriberAccessor.php
+++ /dev/null
@@ -1,78 +0,0 @@
-parent->id();
- }
-
- public function group(): string
- {
- return $this->parent->group();
- }
-
- public function runMode(): RunMode
- {
- return $this->parent->runMode();
- }
-
- public function setupMethod(): Closure|null
- {
- return $this->parent->setupMethod();
- }
-
- public function teardownMethod(): Closure|null
- {
- return $this->parent->teardownMethod();
- }
-
- /**
- * @param class-string $eventClass
- *
- * @return list
- */
- public function subscribeMethods(string $eventClass): array
- {
- return array_map(
- /**
- * @param Closure(Message):void $closure
- *
- * @return Closure(Message):void
- */
- fn (Closure $closure) => function (Message $message) use ($closure): void {
- $trace = new Trace(
- $this->id(),
- 'event_sourcing/subscriber/' . $this->group(),
- );
-
- $this->traceStack->add($trace);
-
- try {
- $closure($message);
- } finally {
- $this->traceStack->remove($trace);
- }
- },
- $this->parent->subscribeMethods($eventClass),
- );
- }
-}
diff --git a/src/Debug/Trace/TraceableSubscriberAccessorRepository.php b/src/Debug/Trace/TraceableSubscriberAccessorRepository.php
deleted file mode 100644
index 0681f4b90..000000000
--- a/src/Debug/Trace/TraceableSubscriberAccessorRepository.php
+++ /dev/null
@@ -1,52 +0,0 @@
- */
- private array $subscribersMap = [];
-
- public function __construct(
- private readonly SubscriberAccessorRepository $parent,
- private readonly TraceStack $traceStack,
- ) {
- }
-
- /** @return iterable */
- public function all(): iterable
- {
- return array_values($this->subscriberAccessorMap());
- }
-
- public function get(string $id): TraceableSubscriberAccessor|null
- {
- $map = $this->subscriberAccessorMap();
-
- return $map[$id] ?? null;
- }
-
- /** @return array */
- private function subscriberAccessorMap(): array
- {
- if ($this->subscribersMap !== []) {
- return $this->subscribersMap;
- }
-
- foreach ($this->parent->all() as $subscriberAccessor) {
- $this->subscribersMap[$subscriberAccessor->id()] = new TraceableSubscriberAccessor(
- $subscriberAccessor,
- $this->traceStack,
- );
- }
-
- return $this->subscribersMap;
- }
-}
diff --git a/src/Metadata/Message/MessageHeaderRegistry.php b/src/Metadata/Message/MessageHeaderRegistry.php
index 948dd40aa..55ed11306 100644
--- a/src/Metadata/Message/MessageHeaderRegistry.php
+++ b/src/Metadata/Message/MessageHeaderRegistry.php
@@ -5,7 +5,6 @@
namespace Patchlevel\EventSourcing\Metadata\Message;
use Patchlevel\EventSourcing\Aggregate\AggregateHeader;
-use Patchlevel\EventSourcing\Debug\Trace\TraceHeader;
use Patchlevel\EventSourcing\Store\ArchivedHeader;
use Patchlevel\EventSourcing\Store\StreamHeader;
use Patchlevel\EventSourcing\Store\StreamStartHeader;
@@ -76,7 +75,6 @@ public static function createWithInternalHeaders(array $headerNameToClassMap = [
$internalHeaders = [
'stream' => StreamHeader::class,
'aggregate' => AggregateHeader::class,
- 'trace' => TraceHeader::class,
'archived' => ArchivedHeader::class,
'newStreamStart' => StreamStartHeader::class,
];
diff --git a/src/Subscription/Subscriber/MetadataSubscriberAccessor.php b/src/Subscription/Subscriber/MetadataSubscriberAccessor.php
index a97ac8a52..ab1ac328d 100644
--- a/src/Subscription/Subscriber/MetadataSubscriberAccessor.php
+++ b/src/Subscription/Subscriber/MetadataSubscriberAccessor.php
@@ -16,12 +16,16 @@
use function array_map;
use function array_merge;
+/** @template T of object */
final class MetadataSubscriberAccessor implements SubscriberAccessor, RealSubscriberAccessor
{
/** @var array> */
private array $subscribeCache = [];
- /** @param list $argumentResolvers */
+ /**
+ * @param T $subscriber
+ * @param list $argumentResolvers
+ */
public function __construct(
private readonly object $subscriber,
private readonly SubscriberMetadata $metadata,
@@ -29,16 +33,30 @@ public function __construct(
) {
}
+ public function metadata(): SubscriberMetadata
+ {
+ return $this->metadata;
+ }
+
+ /** @return T */
+ public function subscriber(): object
+ {
+ return $this->subscriber;
+ }
+
+ /** @deprecated use `->metadata()->id` instead */
public function id(): string
{
return $this->metadata->id;
}
+ /** @deprecated use `->metadata()->group` instead */
public function group(): string
{
return $this->metadata->group;
}
+ /** @deprecated use `->metadata()->runMode` instead */
public function runMode(): RunMode
{
return $this->metadata->runMode;
@@ -139,6 +157,11 @@ private function resolvers(string $eventClass, SubscribeMethodMetadata $method):
return $resolvers;
}
+ /**
+ * @deprecated use `->metadata()` instead
+ *
+ * @return T
+ */
public function realSubscriber(): object
{
return $this->subscriber;
diff --git a/src/Subscription/Subscriber/MetadataSubscriberAccessorRepository.php b/src/Subscription/Subscriber/MetadataSubscriberAccessorRepository.php
index 93c60968a..9d66bbb46 100644
--- a/src/Subscription/Subscriber/MetadataSubscriberAccessorRepository.php
+++ b/src/Subscription/Subscriber/MetadataSubscriberAccessorRepository.php
@@ -20,7 +20,7 @@
final class MetadataSubscriberAccessorRepository implements SubscriberAccessorRepository
{
- /** @var array */
+ /** @var array */
private array $subscribersMap = [];
/** @var list $argumentResolvers */
@@ -47,20 +47,20 @@ public function __construct(
);
}
- /** @return iterable */
+ /** @return iterable */
public function all(): iterable
{
return array_values($this->subscriberAccessorMap());
}
- public function get(string $id): SubscriberAccessor|null
+ public function get(string $id): MetadataSubscriberAccessor|null
{
$map = $this->subscriberAccessorMap();
return $map[$id] ?? null;
}
- /** @return array */
+ /** @return array */
private function subscriberAccessorMap(): array
{
if ($this->subscribersMap !== []) {
diff --git a/src/Subscription/Subscriber/RealSubscriberAccessor.php b/src/Subscription/Subscriber/RealSubscriberAccessor.php
index 1c5ead841..072ea0045 100644
--- a/src/Subscription/Subscriber/RealSubscriberAccessor.php
+++ b/src/Subscription/Subscriber/RealSubscriberAccessor.php
@@ -4,6 +4,7 @@
namespace Patchlevel\EventSourcing\Subscription\Subscriber;
+/** @deprecated will be removed, use MetadataSubscriberAccessor directly */
interface RealSubscriberAccessor
{
public function realSubscriber(): object;
diff --git a/src/Subscription/Subscriber/SubscriberAccessor.php b/src/Subscription/Subscriber/SubscriberAccessor.php
index 25af0c1e5..4e059340f 100644
--- a/src/Subscription/Subscriber/SubscriberAccessor.php
+++ b/src/Subscription/Subscriber/SubscriberAccessor.php
@@ -8,6 +8,7 @@
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Subscription\RunMode;
+/** @deprecated will be removed, use MetadataSubscriberAccessor directly */
interface SubscriberAccessor
{
public function id(): string;
diff --git a/tests/Integration/Subscription/SubscriptionTest.php b/tests/Integration/Subscription/SubscriptionTest.php
index 0557edec0..ede3f43b2 100644
--- a/tests/Integration/Subscription/SubscriptionTest.php
+++ b/tests/Integration/Subscription/SubscriptionTest.php
@@ -11,10 +11,6 @@
use Patchlevel\EventSourcing\Attribute\Subscriber;
use Patchlevel\EventSourcing\Attribute\Teardown;
use Patchlevel\EventSourcing\Clock\FrozenClock;
-use Patchlevel\EventSourcing\Debug\Trace\TraceableSubscriberAccessorRepository;
-use Patchlevel\EventSourcing\Debug\Trace\TraceDecorator;
-use Patchlevel\EventSourcing\Debug\Trace\TraceHeader;
-use Patchlevel\EventSourcing\Debug\Trace\TraceStack;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AggregateRootRegistry;
use Patchlevel\EventSourcing\Repository\DefaultRepositoryManager;
@@ -478,20 +474,14 @@ public function testProcessor(): void
$clock,
);
- $traceStack = new TraceStack();
-
$manager = new DefaultRepositoryManager(
new AggregateRootRegistry(['profile' => Profile::class]),
$store,
null,
null,
- new TraceDecorator($traceStack),
);
- $subscriberAccessorRepository = new TraceableSubscriberAccessorRepository(
- new MetadataSubscriberAccessorRepository([new ProfileProcessor($manager)]),
- $traceStack,
- );
+ $subscriberAccessorRepository = new MetadataSubscriberAccessorRepository([new ProfileProcessor($manager)]);
$repository = $manager->get(Profile::class);
@@ -547,16 +537,6 @@ public function testProcessor(): void
self::assertCount(3, $messages);
self::assertArrayHasKey(2, $messages);
-
- self::assertEquals(
- new TraceHeader([
- [
- 'name' => 'profile',
- 'category' => 'event_sourcing/subscriber/processor',
- ],
- ]),
- $messages[2]->header(TraceHeader::class),
- );
}
public function testBlueGreenDeployment(): void
diff --git a/tests/Unit/Debug/Trace/TraceDecoratorTest.php b/tests/Unit/Debug/Trace/TraceDecoratorTest.php
deleted file mode 100644
index 9974c69d6..000000000
--- a/tests/Unit/Debug/Trace/TraceDecoratorTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-expectException(HeaderNotFound::class);
-
- $stack = new TraceStack();
- $decorator = new TraceDecorator($stack);
-
- $message = new Message(new stdClass());
-
- $decoratedMessage = $decorator($message);
-
- self::assertEquals($message, $decoratedMessage);
-
- $decoratedMessage->header(TraceHeader::class);
- }
-
- public function testWithTrace(): void
- {
- $stack = new TraceStack();
- $stack->add(new Trace('name', 'category'));
-
- $decorator = new TraceDecorator($stack);
-
- $message = new Message(new stdClass());
-
- $decoratedMessage = $decorator($message);
-
- self::assertEquals(
- new TraceHeader([
- [
- 'name' => 'name',
- 'category' => 'category',
- ],
- ]),
- $decoratedMessage->header(TraceHeader::class),
- );
- }
-}
diff --git a/tests/Unit/Debug/Trace/TraceStackTest.php b/tests/Unit/Debug/Trace/TraceStackTest.php
deleted file mode 100644
index b817521ad..000000000
--- a/tests/Unit/Debug/Trace/TraceStackTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-get());
-
- $trace = new Trace('name', 'category');
-
- $stack->add($trace);
-
- self::assertEquals([$trace], $stack->get());
-
- $stack->remove($trace);
-
- self::assertEquals([], $stack->get());
- }
-}