Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Dec 3, 2023
1 parent 0d00e39 commit 16e1726
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 39 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [Unreleased]

### Changed

- Requires `innmind/immutable:~5.2`
- Requires `innmind/operating-system:~4.1`
- Requires `innmind/filesystem:~7.0`
- Requires `innmind/io:~2.3`

## 4.3.0 - 2023-09-23

### Added
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
},
"require": {
"php": "~8.2",
"innmind/immutable": "~4.15|~5.0",
"innmind/immutable": "~5.2",
"innmind/time-continuum": "~3.1",
"innmind/math": "~6.0",
"innmind/url": "~4.1",
"ramsey/uuid": "~4.0",
"innmind/operating-system": "~3.1",
"innmind/operating-system": "~4.1",
"innmind/media-type": "~2.0",
"innmind/filesystem": "~5.2|~6.0",
"innmind/stream": "~4.0"
"innmind/filesystem": "~7.0",
"innmind/stream": "~4.0",
"innmind/io": "~2.3"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 2 additions & 5 deletions src/Model/Basic/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
PointInTime,
ElapsedPeriod,
};
use Innmind\Filesystem\{
File\Content,
Chunk,
};
use Innmind\Filesystem\File\Content;
use Innmind\Immutable\{
Map,
Str,
Expand Down Expand Up @@ -122,7 +119,7 @@ public static function of(Str $body): self
*/
public static function file(Content $content): self
{
$chunks = (new Chunk)($content)->map(
$chunks = $content->chunks()->map(
static fn($chunk) => $chunk->toEncoding(Str\Encoding::ascii),
);
/** @var int<0, max> */
Expand Down
15 changes: 12 additions & 3 deletions src/Transport/Connection/MessageReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
Transport\Frame\Value,
Failure,
};
use Innmind\TimeContinuum\Earth\ElapsedPeriod;
use Innmind\TimeContinuum\{
Earth,
ElapsedPeriod,
};
use Innmind\Filesystem\File\Content;
use Innmind\IO\IO;
use Innmind\Stream\{
Capabilities,
Bidirectional,
Expand Down Expand Up @@ -182,7 +186,7 @@ private function addProperties(
static fn(Maybe $value, Message $message) => $value
->keep(Instance::of(Value\ShortString::class))
->map(static fn($value) => (int) $value->original()->toString())
->flatMap(ElapsedPeriod::maybe(...))
->flatMap(Earth\ElapsedPeriod::maybe(...))
->map(static fn($expiration) => $message->withExpiration($expiration)),
],
[
Expand Down Expand Up @@ -266,9 +270,14 @@ private function readMessage(
);
}

$io = IO::of(fn(?ElapsedPeriod $timeout) => match ($timeout) {
null => $this->streams->watch()->waitForever(),
default => $this->streams->watch()->timeoutAfter($timeout),
});

return $read->map(static fn($in) => ReceivedMessage::of(
$in[0],
Message::file(Content\OfStream::of($in[1])),
Message::file(Content::io($io->readable()->wrap($in[1]))),
));
}

Expand Down
13 changes: 11 additions & 2 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ElapsedPeriod,
Period\Millisecond,
};
use Innmind\Filesystem\File\Content;
use Innmind\Filesystem\Name;
use Innmind\Server\Control\Server\{
Signal,
Command,
Expand Down Expand Up @@ -444,14 +444,23 @@ public function testGetMessageWithAllProperties()

public function testPublishContentOfAFile()
{
$file = $this
->os
->filesystem()
->mount(Path::of(__DIR__.'/'))
->get(Name::of(\basename(__FILE__)))
->match(
static fn($file) => $file->content(),
fn() => $this->fail(),
);
$result = $this
->client
->with(DeclareExchange::of('foo', Type::direct))
->with(DeclareQueue::of('bar'))
->with(Bind::of('foo', 'bar'))
->with(Purge::of('bar'))
->with(Qos::of(10))
->with(Publish::one(Message::file(Content\AtPath::of(Path::of(__FILE__))))->to('foo'))
->with(Publish::one(Message::file($file))->to('foo'))
->with(
Get::of('bar')->handle(function($state, $message, $continuation, $details) {
$this->assertNull($state);
Expand Down
47 changes: 22 additions & 25 deletions tests/Transport/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@
};
use Innmind\Socket\Internet\Transport;
use Innmind\Url\Url;
use Innmind\TimeContinuum\Earth\{
ElapsedPeriod,
Clock,
};
use Innmind\OperatingSystem\{
Remote,
Sockets,
};
use Innmind\Server\Control\Server;
use Innmind\TimeContinuum\Earth\ElapsedPeriod;
use Innmind\OperatingSystem\Factory;
use Innmind\Immutable\{
Sequence,
SideEffect,
Expand All @@ -34,14 +27,15 @@ class ConnectionTest extends TestCase
{
public function testInterface()
{
$os = Factory::build();
$connection = Connection::open(
Transport::tcp(),
Url::of('//guest:guest@localhost:5672/'),
$protocol = new Protocol(new Clock, $this->createMock(ArgumentTranslator::class)),
$protocol = new Protocol($os->clock(), $this->createMock(ArgumentTranslator::class)),
new ElapsedPeriod(1000),
new Clock,
Remote\Generic::of($this->createMock(Server::class), new Clock),
Sockets\Unix::of(),
$os->clock(),
$os->remote(),
$os->sockets(),
)->match(
static fn($connection) => $connection,
static fn() => null,
Expand Down Expand Up @@ -74,14 +68,15 @@ public function testInterface()

public function testClose()
{
$os = Factory::build();
$connection = Connection::open(
Transport::tcp(),
Url::of('//guest:guest@localhost:5672/'),
$protocol = new Protocol(new Clock, $this->createMock(ArgumentTranslator::class)),
$protocol = new Protocol($os->clock(), $this->createMock(ArgumentTranslator::class)),
new ElapsedPeriod(1000),
new Clock,
Remote\Generic::of($this->createMock(Server::class), new Clock),
Sockets\Unix::of(),
$os->clock(),
$os->remote(),
$os->sockets(),
)->match(
static fn($connection) => $connection,
static fn() => null,
Expand All @@ -95,14 +90,15 @@ public function testClose()

public function testReturnFailureWhenReceivedFrameIsNotTheExpectedOne()
{
$os = Factory::build();
$connection = Connection::open(
Transport::tcp(),
Url::of('//guest:guest@localhost:5672/'),
new Protocol(new Clock, $this->createMock(ArgumentTranslator::class)),
new Protocol($os->clock(), $this->createMock(ArgumentTranslator::class)),
new ElapsedPeriod(1000),
new Clock,
Remote\Generic::of($this->createMock(Server::class), new Clock),
Sockets\Unix::of(),
$os->clock(),
$os->remote(),
$os->sockets(),
)->match(
static fn($connection) => $connection,
static fn() => null,
Expand All @@ -123,14 +119,15 @@ public function testReturnFailureWhenReceivedFrameIsNotTheExpectedOne()

public function testReturnFailureWhenConnectionClosedByServer()
{
$os = Factory::build();
$connection = Connection::open(
Transport::tcp(),
Url::of('//guest:guest@localhost:5672/'),
$protocol = new Protocol(new Clock, $this->createMock(ArgumentTranslator::class)),
$protocol = new Protocol($os->clock(), $this->createMock(ArgumentTranslator::class)),
new ElapsedPeriod(1000),
new Clock,
Remote\Generic::of($this->createMock(Server::class), new Clock),
Sockets\Unix::of(),
$os->clock(),
$os->remote(),
$os->sockets(),
)->match(
static fn($connection) => $connection,
static fn() => null,
Expand Down

0 comments on commit 16e1726

Please sign in to comment.