Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  use the underlying OS way to halt the process
  • Loading branch information
Baptouuuu committed Jan 1, 2023
2 parents 6db7ced + 480f109 commit 85938e8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 3.3.0 - 2023-01-01

### Changed

- `Innmind\OperatingSystem\Remote\Resilient::halt` now use the underlying operating system way to halt the process

## 3.2.0 - 2022-12-18

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"innmind/server-control": "^4.0.1",
"innmind/filesystem": "~5.0|~6.0",
"innmind/socket": "~4.0|~5.0",
"innmind/http-transport": "~6.0",
"innmind/http-transport": "~6.2",
"innmind/time-warp": "~3.0",
"innmind/signals": "~3.0",
"innmind/file-watch": "~3.0",
Expand Down
5 changes: 4 additions & 1 deletion src/OperatingSystem/Resilient.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ public function sockets(): Sockets

public function remote(): Remote
{
return Remote\Resilient::of($this->os->remote());
return Remote\Resilient::of(
$this->os->remote(),
$this->os->process(),
);
}

public function process(): CurrentProcess
Expand Down
16 changes: 10 additions & 6 deletions src/Remote/Resilient.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

namespace Innmind\OperatingSystem\Remote;

use Innmind\OperatingSystem\Remote;
use Innmind\OperatingSystem\{
Remote,
CurrentProcess,
};
use Innmind\Server\Control\Server;
use Innmind\Socket\{
Internet\Transport,
Expand All @@ -17,22 +20,23 @@
Transport as HttpTransport,
ExponentialBackoff,
};
use Innmind\TimeWarp\Halt\Usleep;
use Innmind\Immutable\Maybe;
use Formal\AccessLayer\Connection;

final class Resilient implements Remote
{
private Remote $remote;
private CurrentProcess $process;

private function __construct(Remote $remote)
private function __construct(Remote $remote, CurrentProcess $process)
{
$this->remote = $remote;
$this->process = $process;
}

public static function of(Remote $remote): self
public static function of(Remote $remote, CurrentProcess $process): self
{
return new self($remote);
return new self($remote, $process);
}

public function ssh(Url $server): Server
Expand All @@ -49,7 +53,7 @@ public function http(): HttpTransport
{
return ExponentialBackoff::of(
$this->remote->http(),
new Usleep,
$this->process->halt(...),
);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Remote/ResilientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use Innmind\OperatingSystem\{
Remote\Resilient,
Remote,
CurrentProcess,
};
use Innmind\TimeContinuum\Clock;
use Innmind\HttpTransport\ExponentialBackoff;
use Innmind\Server\Control\Server;
use Innmind\Socket\{
Expand Down Expand Up @@ -36,7 +36,7 @@ public function testInterface()
Remote::class,
Resilient::of(
$this->createMock(Remote::class),
$this->createMock(Clock::class),
$this->createMock(CurrentProcess::class),
),
);
}
Expand All @@ -48,7 +48,7 @@ public function testSsh()
->then(function($url) {
$remote = Resilient::of(
$inner = $this->createMock(Remote::class),
$this->createMock(Clock::class),
$this->createMock(CurrentProcess::class),
);
$inner
->expects($this->once())
Expand Down Expand Up @@ -76,7 +76,7 @@ public function testSocket()
->then(function($transport, $authority) {
$remote = Resilient::of(
$inner = $this->createMock(Remote::class),
$this->createMock(Clock::class),
$this->createMock(CurrentProcess::class),
);
$inner
->expects($this->once())
Expand All @@ -92,7 +92,7 @@ public function testHttp()
{
$remote = Resilient::of(
$this->createMock(Remote::class),
$this->createMock(Clock::class),
$this->createMock(CurrentProcess::class),
);

$this->assertInstanceOf(ExponentialBackoff::class, $remote->http());
Expand All @@ -105,7 +105,7 @@ public function testSql()
->then(function($server) {
$remote = Resilient::of(
$this->createMock(Remote::class),
$this->createMock(Clock::class),
$this->createMock(CurrentProcess::class),
);

$this->assertInstanceOf(Connection::class, $remote->sql($server));
Expand Down

0 comments on commit 85938e8

Please sign in to comment.