Skip to content
Merged
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
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
php-version: ['8.2', '8.3', '8.4']
php-version: ['8.4', '8.5']
dependencies: ['lowest', 'highest']
name: 'BlackBox (${{ matrix.os }}, ${{ matrix.php-version }}, ${{ matrix.dependencies }})'
steps:
Expand All @@ -35,7 +35,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
php-version: ['8.2', '8.3', '8.4']
php-version: ['8.4', '8.5']
dependencies: ['lowest', 'highest']
name: 'Coverage (${{ matrix.os }}, ${{ matrix.php-version }}, ${{ matrix.dependencies }})'
steps:
Expand Down Expand Up @@ -66,5 +66,3 @@ jobs:
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
cs:
uses: innmind/github-workflows/.github/workflows/cs.yml@main
with:
php-version: '8.2'
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [Unreleased]

### Changed

- Requires PHP `8.4`
- Requires `innmind/foundation:~2.1`

## 6.0.0 - 2025-08-08

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use Innmind\AMQP\{
Model\Exchange\Type,
};
use Innmind\IO\Sockets\Internet\Transport;
use Innmind\TimeContinuum\Period;
use Innmind\Time\Period;
use Innmind\OperatingSystem\Factory as OSFactory;
use Innmind\Url\Url;
use Innmind\Immutable\Str;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Transport\Connection,
};
use Innmind\IO\Sockets\Internet\Transport;
use Innmind\TimeContinuum\Period;
use Innmind\Time\Period;
use Innmind\Url\Url;
use Innmind\OperatingSystem\Factory as OSFactory;

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"issues": "http://github.com/Innmind/AMQP/issues"
},
"require": {
"php": "~8.2",
"innmind/foundation": "^1.7.1",
"php": "~8.4",
"innmind/foundation": "~2.1",
"ramsey/uuid": "~4.0"
},
"autoload": {
Expand All @@ -31,7 +31,7 @@
},
"require-dev": {
"psr/log": "~3.0",
"innmind/static-analysis": "^1.2.1",
"innmind/static-analysis": "~1.3",
"innmind/black-box": "~6.5",
"innmind/coding-standard": "~2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/Listen to signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $client
->run(null)
->match(
static fn() => null, // not reachable in this case
static fn($failure) => throw new \RuntimeException($failure::class),
static fn($failure) => $failure,
);
```

Expand Down
2 changes: 1 addition & 1 deletion fixtures/forever-consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
};
use Innmind\OperatingSystem\Factory as OSFactory;
use Innmind\IO\Sockets\Internet\Transport;
use Innmind\TimeContinuum\Period;
use Innmind\Time\Period;
use Innmind\Url\Url;

$os = OSFactory::build();
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ private function openChannel(): Attempt
static fn($protocol) => $protocol->channel()->open($channel),
Method::channelOpenOk,
)
->map(fn() => $this->signals->match(
->flatMap(fn() => $this->signals->match(
static fn($process) => $connection->listenSignals(
$process->signals(),
$channel,
),
static fn() => null,
static fn() => Attempt::result(SideEffect::identity),
))
->map(static fn() => [$connection, $channel])
->mapError(Failure::as(Failure::toOpenChannel())),
Expand Down
2 changes: 1 addition & 1 deletion src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Innmind\OperatingSystem\OperatingSystem;
use Innmind\IO\Sockets\Internet\Transport as Socket;
use Innmind\Url\Url;
use Innmind\TimeContinuum\Period;
use Innmind\Time\Period;

final class Factory
{
Expand Down
14 changes: 7 additions & 7 deletions src/Model/Basic/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
UserId,
AppId,
};
use Innmind\TimeContinuum\{
PointInTime,
use Innmind\Time\{
Point,
Period,
};
use Innmind\Filesystem\File\Content;
Expand Down Expand Up @@ -51,7 +51,7 @@ final class Message
private Maybe $expiration;
/** @var Maybe<Id> */
private Maybe $id;
/** @var Maybe<PointInTime> */
/** @var Maybe<Point> */
private Maybe $timestamp;
/** @var Maybe<Type> */
private Maybe $type;
Expand Down Expand Up @@ -92,7 +92,7 @@ private function __construct(Sequence $chunks, int $length)
$this->expiration = Maybe::nothing();
/** @var Maybe<Id> */
$this->id = Maybe::nothing();
/** @var Maybe<PointInTime> */
/** @var Maybe<Point> */
$this->timestamp = Maybe::nothing();
/** @var Maybe<Type> */
$this->type = Maybe::nothing();
Expand Down Expand Up @@ -304,7 +304,7 @@ public function withId(Id $id): self
}

/**
* @return Maybe<PointInTime>
* @return Maybe<Point>
*/
#[\NoDiscard]
public function timestamp(): Maybe
Expand All @@ -313,7 +313,7 @@ public function timestamp(): Maybe
}

#[\NoDiscard]
public function withTimestamp(PointInTime $timestamp): self
public function withTimestamp(Point $timestamp): self
{
$self = clone $this;
$self->timestamp = Maybe::just($timestamp);
Expand Down Expand Up @@ -380,7 +380,7 @@ public function body(): Str
{
return $this
->chunks
->fold(new Concat)
->fold(Concat::monoid)
->toEncoding(Str\Encoding::ascii);
}

Expand Down
17 changes: 7 additions & 10 deletions src/Model/Basic/Message/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
namespace Innmind\AMQP\Model\Basic\Message;

use Innmind\AMQP\Exception\DomainException;
use Innmind\MediaType\{
MediaType,
Exception\Exception,
};
use Innmind\MediaType\MediaType;
use Innmind\Immutable\Maybe;

/**
Expand All @@ -21,7 +18,7 @@ final class ContentType

private function __construct(MediaType $type)
{
$this->value = $type->topLevel().'/'.$type->subType();
$this->value = $type->topLevel()->name.'/'.$type->subType();
}

/**
Expand All @@ -35,11 +32,11 @@ private function __construct(MediaType $type)
#[\NoDiscard]
public static function of(string $topLevel, string $subType): self
{
try {
return new self(new MediaType($topLevel, $subType));
} catch (Exception $e) {
throw new DomainException("$topLevel/$subType");
}
$string = "$topLevel/$subType";

return self::maybe($string)
->attempt(static fn() => new DomainException($string))
->unwrap();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Connection/TuneOk.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Innmind\AMQP\Model\Connection;

use Innmind\TimeContinuum\Period;
use Innmind\Time\Period;

/**
* @psalm-immutable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
declare(strict_types = 1);

namespace Innmind\AMQP\TimeContinuum\Format;
namespace Innmind\AMQP\Time\Format;

use Innmind\TimeContinuum\Format;
use Innmind\Time\Format;

/**
* @internal
Expand Down
9 changes: 6 additions & 3 deletions src/Transport/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Frame as IOFrame,
};
use Innmind\Url\Url;
use Innmind\TimeContinuum\{
use Innmind\Time\{
Period,
Clock,
};
Expand Down Expand Up @@ -211,9 +211,12 @@ public function tune(
));
}

public function listenSignals(Signals $signals, Channel $channel): void
/**
* @return Attempt<SideEffect>
*/
public function listenSignals(Signals $signals, Channel $channel): Attempt
{
$this->signals->install($signals, $channel);
return $this->signals->install($signals, $channel);
}

private function flagActive(ReceivedFrame $received): ReceivedFrame
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/Connection/Handshake.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Model\Connection\MaxFrameSize,
Failure,
};
use Innmind\TimeContinuum\Period;
use Innmind\Time\Period;
use Innmind\Url\Authority;
use Innmind\Immutable\{
Attempt,
Expand Down
6 changes: 3 additions & 3 deletions src/Transport/Connection/Heartbeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Innmind\AMQP\{
Transport\Frame,
};
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
PointInTime,
Point,
Period,
};
use Innmind\Immutable\Sequence;
Expand All @@ -21,7 +21,7 @@ final class Heartbeat
private function __construct(
private Clock $clock,
private Period $threshold,
private PointInTime $lastReceivedData,
private Point $lastReceivedData,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Transport/Connection/MessageReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Failure,
};
use Innmind\OperatingSystem\Filesystem;
use Innmind\TimeContinuum\Period;
use Innmind\Time\Period;
use Innmind\Filesystem\File\Content;
use Innmind\IO\Stream\Size\Unit;
use Innmind\Validation\Is;
Expand Down
54 changes: 42 additions & 12 deletions src/Transport/Connection/SignalListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Innmind\Immutable\{
Attempt,
Maybe,
SideEffect,
};

/**
Expand Down Expand Up @@ -60,22 +61,51 @@ public static function uninstalled(): self
return new self;
}

public function install(Signals $signals, Channel $channel): void
/**
* @return Attempt<SideEffect>
*/
public function install(Signals $signals, Channel $channel): Attempt
{
$installed = Attempt::result(SideEffect::identity);

if (!$this->installed) {
$signals->listen(Signal::hangup, static function() {
// do nothing so it can run in background
});
$signals->listen(Signal::interrupt, $this->softClose);
$signals->listen(Signal::abort, $this->softClose);
$signals->listen(Signal::terminate, $this->softClose);
$signals->listen(Signal::terminalStop, $this->softClose);
$signals->listen(Signal::alarm, $this->softClose);
$this->signals = Maybe::just($signals);
$this->installed = true;
$installed = $signals
->listen(Signal::hangup, static function() {
// do nothing so it can run in background
})
->flatMap(fn() => $signals->listen(
Signal::interrupt,
$this->softClose,
))
->flatMap(fn() => $signals->listen(
Signal::abort,
$this->softClose,
))
->flatMap(fn() => $signals->listen(
Signal::terminate,
$this->softClose,
))
->flatMap(fn() => $signals->listen(
Signal::terminalStop,
$this->softClose,
))
->flatMap(fn() => $signals->listen(
Signal::alarm,
$this->softClose,
))
->map(function($_) use ($signals) {
$this->signals = Maybe::just($signals);
$this->installed = true;

return $_;
});
}

$this->channel = Maybe::just($channel);
return $installed->map(function($_) use ($channel) {
$this->channel = Maybe::just($channel);

return $_;
});
}

public function uninstall(): void
Expand Down
6 changes: 3 additions & 3 deletions src/Transport/Frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private function packMethod(): Str
$payload = $this
->values
->map(static fn($value) => $value->pack())
->fold(new Concat)
->fold(Concat::monoid)
->toEncoding(Str\Encoding::ascii);

return $this->doPack($payload);
Expand All @@ -183,7 +183,7 @@ private function packHeader(): Str
$payload = $this
->values
->map(static fn($value) => $value->pack())
->fold(new Concat)
->fold(Concat::monoid)
->toEncoding(Str\Encoding::ascii);

return $this->doPack($payload);
Expand Down Expand Up @@ -216,7 +216,7 @@ private function doPack(Str $payload): Str
$payload,
UnsignedOctet::internal(self::end())->pack(),
)
->fold(new Concat)
->fold(Concat::monoid)
->toEncoding(Str\Encoding::ascii);
}
}
Loading