Skip to content

Commit c24a447

Browse files
committed
Rename package and entities
1 parent 37a630b commit c24a447

9 files changed

+73
-93
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ First of all you need to create initiator data and place it to holder:
1919

2020
```php
2121

22-
use Ensi\InitiatorPropagation\InitiatorHolder;
23-
use Ensi\InitiatorPropagation\InitiatorDTO;
22+
use Ensi\InitialEventPropagation\InitialEventHolder;
23+
use Ensi\InitialEventPropagation\InitialEventDTO;
2424

25-
InitiatorHolder::getInstance()
25+
InitialEventHolder::getInstance()
2626
->setInitiator(
27-
InitiatorDTO::fromScratch(
27+
InitialEventDTO::fromScratch(
2828
userId: "1",
2929
userType: "admin",
3030
app: "mobile-api-gateway",
@@ -37,27 +37,27 @@ If you are not in initial entrypoint context to need to get Initiator from `X-In
3737

3838
```php
3939

40-
use Ensi\InitiatorPropagation\Config;
41-
use Ensi\InitiatorPropagation\InitiatorHolder;
42-
use Ensi\InitiatorPropagation\InitiatorDTO;
40+
use Ensi\InitialEventPropagation\Config;
41+
use Ensi\InitialEventPropagation\InitialEventHolder;
42+
use Ensi\InitialEventPropagation\InitialEventDTO;
4343

44-
InitiatorHolder::getInstance()
44+
InitialEventHolder::getInstance()
4545
->setInitiator(
46-
InitiatorDTO::fromSerializedString($request->header(Config::REQUEST_HEADER))
46+
InitialEventDTO::fromSerializedString($request->header(Config::REQUEST_HEADER))
4747
);
4848
```
4949

50-
Next, extract DTO from holder (`InitiatorHolder::getInstance()->getInitiator`) and pass it to any futher outcomming requests (Guzzle, RabbitMQ, Kafka etc)
50+
Next, extract DTO from holder (`InitialEventHolder::getInstance()->getInitiator`) and pass it to any futher outcomming requests (Guzzle, RabbitMQ, Kafka etc)
5151
For example:
5252
```php
5353

54-
use Ensi\InitiatorPropagation\Config;
55-
use Ensi\InitiatorPropagation\InitiatorHolder;
54+
use Ensi\InitialEventPropagation\Config;
55+
use Ensi\InitialEventPropagation\InitialEventHolder;
5656

5757
function some_middleware(callable $handler)
5858
{
5959
return function (RequestInterface $request, $options) use ($handler) {
60-
$inititiator = InitiatorHolder::getInstance()->getInitiator();
60+
$inititiator = InitialEventHolder::getInstance()->getInitiator();
6161

6262
return $handler(
6363
$inititiator ? $request->withHeader(Config::REQUEST_HEADER, $inititiator->serialize()) : $request,
@@ -69,7 +69,7 @@ function some_middleware(callable $handler)
6969

7070
### Guzzle
7171

72-
You can use built-in `Ensi\InitiatorPropagation\PropagateInitiatorGuzzleMiddleware` to propagate `X-Initiator` header to every outcomming guzzle request made by the given Guzzle handler: `$stack->push(new PropagateInitiatorGuzzleMiddleware());`
72+
You can use built-in `Ensi\InitialEventPropagation\PropagateInitiatorGuzzleMiddleware` to propagate `X-Initiator` header to every outcomming guzzle request made by the given Guzzle handler: `$stack->push(new PropagateInitiatorGuzzleMiddleware());`
7373

7474

7575
## Contributing

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
},
2424
"autoload": {
2525
"psr-4": {
26-
"Ensi\\InitiatorPropagation\\": "src"
26+
"Ensi\\InitialEventPropagation\\": "src"
2727
}
2828
},
2929
"autoload-dev": {
3030
"psr-4": {
31-
"Ensi\\InitiatorPropagation\\Tests\\": "tests"
31+
"Ensi\\InitialEventPropagation\\Tests\\": "tests"
3232
}
3333
},
3434
"scripts": {

composer.lock

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Ensi\InitiatorPropagation;
3+
namespace Ensi\InitialEventPropagation;
44

55
class Config
66
{
7-
public const REQUEST_HEADER = 'X-Initiator';
7+
public const REQUEST_HEADER = 'X-Initial-Event';
88
}

src/EmptySerializedFieldException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Ensi\InitiatorPropagation;
3+
namespace Ensi\InitialEventPropagation;
44

55
use InvalidArgumentException;
66
use Throwable;
@@ -9,7 +9,7 @@ class EmptySerializedFieldException extends InvalidArgumentException
99
{
1010
public function __construct(string $field, int $code = 0, ?Throwable $previous = null)
1111
{
12-
$message = "Initiator propagation error: \"{$field}\" is not set in serialized string";
12+
$message = "Initial event propagation error: \"{$field}\" is not set in serialized string";
1313
parent::__construct($message, $code, $previous);
1414
}
1515
}

src/InitiatorDTO.php renamed to src/InitialEventDTO.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22

3-
namespace Ensi\InitiatorPropagation;
3+
namespace Ensi\InitialEventPropagation;
44

55
use DateTime;
66
use DateTimeZone;
77
use Ramsey\Uuid\Uuid;
88

9-
class InitiatorDTO
9+
class InitialEventDTO
1010
{
1111
public function __construct(
1212
public string $correlationId,
13-
public string $startedAt,
13+
public string $timestamp,
1414
public string $app,
1515
public string $entrypoint,
1616
public string $userId = '',
@@ -28,11 +28,11 @@ public static function fromScratch(
2828
string $realUserId = '',
2929
string $realUserType = '',
3030
string $correlationId = '',
31-
string $startedAt = ''
31+
string $timestamp = ''
3232
): static {
3333
return new static(
3434
correlationId: $correlationId ?: Uuid::uuid4()->toString(),
35-
startedAt: $startedAt ?: (new DateTime())->setTimezone(new DateTimeZone("UTC"))->format('Y-m-d\TH:i:s.u\Z'),
35+
timestamp: $timestamp ?: (new DateTime())->setTimezone(new DateTimeZone("UTC"))->format('Y-m-d\TH:i:s.u\Z'),
3636
app: $app,
3737
entrypoint: $entrypoint,
3838
userId: $userId,
@@ -55,7 +55,7 @@ public static function fromSerializedString(string $serializedData): static
5555

5656
return new static(
5757
correlationId: $params['correlationId'] ?? throw new EmptySerializedFieldException("correlationId"),
58-
startedAt: $params['startedAt'] ?? throw new EmptySerializedFieldException("startedAt"),
58+
timestamp: $params['timestamp'] ?? throw new EmptySerializedFieldException("timestamp"),
5959
app: $params['app'] ?? throw new EmptySerializedFieldException("app"),
6060
entrypoint: $params['entrypoint'] ?? throw new EmptySerializedFieldException("entrypoint"),
6161
userId: $params['userId'] ?? '',
@@ -81,7 +81,7 @@ public function toArray(): array
8181
{
8282
return [
8383
'correlationId' => $this->correlationId,
84-
'startedAt' => $this->startedAt,
84+
'timestamp' => $this->timestamp,
8585
'app' => $this->app,
8686
'entrypoint' => $this->entrypoint,
8787
'userId' => $this->userId,

src/InitiatorHolder.php renamed to src/InitialEventHolder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace Ensi\InitiatorPropagation;
3+
namespace Ensi\InitialEventPropagation;
44

5-
class InitiatorHolder
5+
class InitialEventHolder
66
{
77
private static array $instances = [];
88

9-
protected ?InitiatorDTO $initiator = null;
9+
protected ?InitialEventDTO $initiator = null;
1010

1111
public static function getInstance(): static
1212
{
@@ -18,14 +18,14 @@ public static function getInstance(): static
1818
return self::$instances[$className];
1919
}
2020

21-
public function setInitiator(InitiatorDTO $initiator): static
21+
public function setInitiator(InitialEventDTO $initiator): static
2222
{
2323
$this->initiator = $initiator;
2424

2525
return $this;
2626
}
2727

28-
public function getInitiator(): ?InitiatorDTO
28+
public function getInitiator(): ?InitialEventDTO
2929
{
3030
return $this->initiator;
3131
}

src/PropagateInitiatorGuzzleMiddleware.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)