Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  specify next release
  update changelog
  update dependencies
  use stream capabilities
  • Loading branch information
Baptouuuu committed Jan 29, 2023
2 parents bd674b7 + 18acc13 commit 9efee2b
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 24 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 3.5.0 - 2023-01-29

### Added

- `Innmind\OperatingSystem\Config::useStreamCapabilities()`
- `Innmind\OperatingSystem\Config::withEnvironmentPath()`

### Changed

- Requires `innmind/server-status:~4.0`
- Requires `innmind/server-control:~5.0`
- Requires `innmind/filesystem:~6.2`
- Requires `innmind/socket:~6.0`
- Requires `innmind/http-transport:~6.3`
- Requires `innmind/file-watch:~3.1`
- Requires `innmind/stream:~4.0`

## 3.4.0 - 2023-01-02

### Added
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"require": {
"php": "~8.1",
"innmind/time-continuum": "~3.0",
"innmind/server-status": "~3.0",
"innmind/server-control": "^4.0.1",
"innmind/filesystem": "~6.1",
"innmind/socket": "~4.0|~5.0",
"innmind/http-transport": "~6.2",
"innmind/server-status": "~4.0",
"innmind/server-control": "~5.0",
"innmind/filesystem": "~6.2",
"innmind/socket": "~6.0",
"innmind/http-transport": "~6.3",
"innmind/time-warp": "~3.0",
"innmind/signals": "~3.0",
"innmind/file-watch": "~3.0",
"innmind/stream": "~3.2",
"innmind/file-watch": "~3.1",
"innmind/stream": "~4.0",
"formal/access-layer": "^2.0"
},
"autoload": {
Expand Down
71 changes: 67 additions & 4 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,71 @@
namespace Innmind\OperatingSystem;

use Innmind\Filesystem\CaseSensitivity;
use Innmind\Server\Status\EnvironmentPath;
use Innmind\Stream\{
Capabilities,
Streams,
};

final class Config
{
private CaseSensitivity $caseSensitivity;
private Capabilities $streamCapabilities;
private EnvironmentPath $path;

private function __construct(CaseSensitivity $caseSensitivity)
{
private function __construct(
CaseSensitivity $caseSensitivity,
Capabilities $streamCapabilities,
EnvironmentPath $path,
) {
$this->caseSensitivity = $caseSensitivity;
$this->streamCapabilities = $streamCapabilities;
$this->path = $path;
}

public static function of(): self
{
return new self(CaseSensitivity::sensitive);
return new self(
CaseSensitivity::sensitive,
Streams::fromAmbientAuthority(),
EnvironmentPath::of(\getenv('PATH') ?: ''),
);
}

/**
* @psalm-mutation-free
*/
public function caseInsensitiveFilesystem(): self
{
return new self(CaseSensitivity::insensitive);
return new self(
CaseSensitivity::insensitive,
$this->streamCapabilities,
$this->path,
);
}

/**
* @psalm-mutation-free
*/
public function useStreamCapabilities(Capabilities $capabilities): self
{
return new self(
$this->caseSensitivity,
$capabilities,
$this->path,
);
}

/**
* @psalm-mutation-free
*/
public function withEnvironmentPath(EnvironmentPath $path): self
{
return new self(
$this->caseSensitivity,
$this->streamCapabilities,
$path,
);
}

/**
Expand All @@ -31,4 +78,20 @@ public function filesystemCaseSensitivity(): CaseSensitivity
{
return $this->caseSensitivity;
}

/**
* @internal
*/
public function streamCapabilities(): Capabilities
{
return $this->streamCapabilities;
}

/**
* @internal
*/
public function environmentPath(): EnvironmentPath
{
return $this->path;
}
}
7 changes: 4 additions & 3 deletions src/Filesystem/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ public function mount(Path $path): Adapter
}
}

$adapter = Adapter\Filesystem::mount($path)->withCaseSensitivity(
$this->config->filesystemCaseSensitivity(),
);
$adapter = Adapter\Filesystem::mount($path, $this->config->streamCapabilities())
->withCaseSensitivity(
$this->config->filesystemCaseSensitivity(),
);
$this->mounted[$adapter] = $path->toString();

return $adapter;
Expand Down
15 changes: 11 additions & 4 deletions src/OperatingSystem/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
};
use Innmind\TimeContinuum\Clock;
use Innmind\TimeWarp\Halt\Usleep;
use Innmind\Stream\Watch\Select;

final class Unix implements OperatingSystem
{
Expand Down Expand Up @@ -64,14 +63,18 @@ public function filesystem(): Filesystem

public function status(): ServerStatus
{
return $this->status ??= ServerFactory::build($this->clock());
return $this->status ??= ServerFactory::build(
$this->clock(),
$this->control(),
$this->config->environmentPath(),
);
}

public function control(): ServerControl
{
return $this->control ??= Servers\Unix::of(
$this->clock(),
Select::timeoutAfter(...),
$this->config->streamCapabilities(),
new Usleep,
);
}
Expand All @@ -88,7 +91,11 @@ public function sockets(): Sockets

public function remote(): Remote
{
return $this->remote ??= Remote\Generic::of($this->control(), $this->clock());
return $this->remote ??= Remote\Generic::of(
$this->control(),
$this->clock(),
$this->config,
);
}

public function process(): CurrentProcess
Expand Down
25 changes: 19 additions & 6 deletions src/Remote/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

namespace Innmind\OperatingSystem\Remote;

use Innmind\OperatingSystem\Remote;
use Innmind\OperatingSystem\{
Remote,
Config,
};
use Innmind\Server\Control\{
Server,
Servers,
};
use Innmind\Filesystem\Chunk;
use Innmind\TimeContinuum\Clock;
use Innmind\Socket\{
Internet\Transport,
Expand All @@ -29,17 +33,22 @@ final class Generic implements Remote
{
private Server $server;
private Clock $clock;
private Config $config;
private ?HttpTransport $http = null;

private function __construct(Server $server, Clock $clock)
private function __construct(Server $server, Clock $clock, Config $config)
{
$this->server = $server;
$this->clock = $clock;
$this->config = $config;
}

public static function of(Server $server, Clock $clock): self
{
return new self($server, $clock);
public static function of(
Server $server,
Clock $clock,
Config $config = null,
): self {
return new self($server, $clock, $config ?? Config::of());
}

public function ssh(Url $server): Server
Expand All @@ -66,7 +75,11 @@ public function socket(Transport $transport, Authority $authority): Maybe

public function http(): HttpTransport
{
return $this->http ??= Curl::of($this->clock);
return $this->http ??= Curl::of(
$this->clock,
new Chunk,
$this->config->streamCapabilities(),
);
}

public function sql(Url $server): Connection
Expand Down

0 comments on commit 9efee2b

Please sign in to comment.